aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 054cd3e9a20..8705c3cd65f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -196,7 +196,7 @@ int immediate_quit;
196int quit_char; 196int quit_char;
197 197
198/* Current depth in recursive edits. */ 198/* Current depth in recursive edits. */
199int command_loop_level; 199EMACS_INT command_loop_level;
200 200
201/* If not Qnil, this is a switch-frame event which we decided to put 201/* If not Qnil, this is a switch-frame event which we decided to put
202 off until the end of a key sequence. This should be read as the 202 off until the end of a key sequence. This should be read as the
@@ -1001,7 +1001,8 @@ static Lisp_Object
1001cmd_error (Lisp_Object data) 1001cmd_error (Lisp_Object data)
1002{ 1002{
1003 Lisp_Object old_level, old_length; 1003 Lisp_Object old_level, old_length;
1004 char macroerror[50]; 1004 char macroerror[sizeof "After..kbd macro iterations: "
1005 + INT_STRLEN_BOUND (EMACS_INT)];
1005 1006
1006#ifdef HAVE_WINDOW_SYSTEM 1007#ifdef HAVE_WINDOW_SYSTEM
1007 if (display_hourglass_p) 1008 if (display_hourglass_p)
@@ -1013,7 +1014,7 @@ cmd_error (Lisp_Object data)
1013 if (executing_kbd_macro_iterations == 1) 1014 if (executing_kbd_macro_iterations == 1)
1014 sprintf (macroerror, "After 1 kbd macro iteration: "); 1015 sprintf (macroerror, "After 1 kbd macro iteration: ");
1015 else 1016 else
1016 sprintf (macroerror, "After %d kbd macro iterations: ", 1017 sprintf (macroerror, "After %"pI"d kbd macro iterations: ",
1017 executing_kbd_macro_iterations); 1018 executing_kbd_macro_iterations);
1018 } 1019 }
1019 else 1020 else
@@ -6479,11 +6480,15 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
6479 value = Fcdr_safe (Fassq (symbol_int, name_alist_or_stem)); 6480 value = Fcdr_safe (Fassq (symbol_int, name_alist_or_stem));
6480 else if (STRINGP (name_alist_or_stem)) 6481 else if (STRINGP (name_alist_or_stem))
6481 { 6482 {
6482 int len = SBYTES (name_alist_or_stem); 6483 char *buf;
6483 char *buf = (char *) alloca (len + 50); 6484 ptrdiff_t len = (SBYTES (name_alist_or_stem)
6484 sprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem), 6485 + sizeof "-" + INT_STRLEN_BOUND (EMACS_INT));
6485 XINT (symbol_int) + 1); 6486 USE_SAFE_ALLOCA;
6487 SAFE_ALLOCA (buf, char *, len);
6488 esprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem),
6489 XINT (symbol_int) + 1);
6486 value = intern (buf); 6490 value = intern (buf);
6491 SAFE_FREE ();
6487 } 6492 }
6488 else if (name_table != 0 && name_table[symbol_num]) 6493 else if (name_table != 0 && name_table[symbol_num])
6489 value = intern (name_table[symbol_num]); 6494 value = intern (name_table[symbol_num]);
@@ -6499,7 +6504,7 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
6499 6504
6500 if (NILP (value)) 6505 if (NILP (value))
6501 { 6506 {
6502 char buf[20]; 6507 char buf[sizeof "key-" + INT_STRLEN_BOUND (EMACS_INT)];
6503 sprintf (buf, "key-%"pI"d", symbol_num); 6508 sprintf (buf, "key-%"pI"d", symbol_num);
6504 value = intern (buf); 6509 value = intern (buf);
6505 } 6510 }
@@ -10398,19 +10403,21 @@ give to the command you invoke, if it asks for an argument. */)
10398 char *newmessage; 10403 char *newmessage;
10399 int message_p = push_message (); 10404 int message_p = push_message ();
10400 int count = SPECPDL_INDEX (); 10405 int count = SPECPDL_INDEX ();
10406 ptrdiff_t newmessage_len, newmessage_alloc;
10407 USE_SAFE_ALLOCA;
10401 10408
10402 record_unwind_protect (pop_message_unwind, Qnil); 10409 record_unwind_protect (pop_message_unwind, Qnil);
10403 binding = Fkey_description (bindings, Qnil); 10410 binding = Fkey_description (bindings, Qnil);
10404 10411 newmessage_alloc =
10405 newmessage 10412 (sizeof "You can run the command `' with "
10406 = (char *) alloca (SCHARS (SYMBOL_NAME (function)) 10413 + SBYTES (SYMBOL_NAME (function)) + SBYTES (binding));
10407 + SBYTES (binding) 10414 SAFE_ALLOCA (newmessage, char *, newmessage_alloc);
10408 + 100); 10415 newmessage_len =
10409 sprintf (newmessage, "You can run the command `%s' with %s", 10416 esprintf (newmessage, "You can run the command `%s' with %s",
10410 SDATA (SYMBOL_NAME (function)), 10417 SDATA (SYMBOL_NAME (function)),
10411 SDATA (binding)); 10418 SDATA (binding));
10412 message2 (newmessage, 10419 message2 (newmessage,
10413 strlen (newmessage), 10420 newmessage_len,
10414 STRING_MULTIBYTE (binding)); 10421 STRING_MULTIBYTE (binding));
10415 if (NUMBERP (Vsuggest_key_bindings)) 10422 if (NUMBERP (Vsuggest_key_bindings))
10416 waited = sit_for (Vsuggest_key_bindings, 0, 2); 10423 waited = sit_for (Vsuggest_key_bindings, 0, 2);
@@ -10420,6 +10427,7 @@ give to the command you invoke, if it asks for an argument. */)
10420 if (!NILP (waited) && message_p) 10427 if (!NILP (waited) && message_p)
10421 restore_message (); 10428 restore_message ();
10422 10429
10430 SAFE_FREE ();
10423 unbind_to (count, Qnil); 10431 unbind_to (count, Qnil);
10424 } 10432 }
10425 } 10433 }
@@ -10649,7 +10657,9 @@ DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
10649 (void) 10657 (void)
10650{ 10658{
10651 Lisp_Object temp; 10659 Lisp_Object temp;
10652 XSETFASTINT (temp, command_loop_level + minibuf_level); 10660 /* Wrap around reliably on integer overflow. */
10661 EMACS_INT sum = (command_loop_level & INTMASK) + (minibuf_level & INTMASK);
10662 XSETINT (temp, sum);
10653 return temp; 10663 return temp;
10654} 10664}
10655 10665