aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorVibhav Pant2023-06-06 19:30:27 +0530
committerVibhav Pant2023-06-06 19:30:27 +0530
commit49ffcbf86a32a8a217538d4df3736fe069ccf35d (patch)
treea5f16157cc20fb19a844473a6fbd2b434f4c8260 /src/keymap.c
parentaf569fa3d90a717983b743eb97adbf869c6d1736 (diff)
parent7ca1d782f5910d0c3978c6798a45c6854ec668c7 (diff)
downloademacs-49ffcbf86a32a8a217538d4df3736fe069ccf35d.tar.gz
emacs-49ffcbf86a32a8a217538d4df3736fe069ccf35d.zip
Merge branch 'master' into scratch/comp-static-data
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 23453eaa9a6..da2af98c2d6 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -887,22 +887,23 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx,
887 keymap_end: 887 keymap_end:
888 /* We have scanned the entire keymap, and not found a binding for 888 /* We have scanned the entire keymap, and not found a binding for
889 IDX. Let's add one. */ 889 IDX. Let's add one. */
890 { 890 if (!remove)
891 Lisp_Object elt; 891 {
892 Lisp_Object elt;
892 893
893 if (CONSP (idx) && CHARACTERP (XCAR (idx))) 894 if (CONSP (idx) && CHARACTERP (XCAR (idx)))
894 { 895 {
895 /* IDX specifies a range of characters, and not all of them 896 /* IDX specifies a range of characters, and not all of them
896 were handled yet, which means this keymap doesn't have a 897 were handled yet, which means this keymap doesn't have a
897 char-table. So, we insert a char-table now. */ 898 char-table. So, we insert a char-table now. */
898 elt = Fmake_char_table (Qkeymap, Qnil); 899 elt = Fmake_char_table (Qkeymap, Qnil);
899 Fset_char_table_range (elt, idx, NILP (def) ? Qt : def); 900 Fset_char_table_range (elt, idx, NILP (def) ? Qt : def);
900 } 901 }
901 else 902 else
902 elt = Fcons (idx, def); 903 elt = Fcons (idx, def);
903 CHECK_IMPURE (insertion_point, XCONS (insertion_point)); 904 CHECK_IMPURE (insertion_point, XCONS (insertion_point));
904 XSETCDR (insertion_point, Fcons (elt, XCDR (insertion_point))); 905 XSETCDR (insertion_point, Fcons (elt, XCDR (insertion_point)));
905 } 906 }
906 } 907 }
907 908
908 return def; 909 return def;
@@ -1362,7 +1363,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1362 { 1363 {
1363 USE_SAFE_ALLOCA; 1364 USE_SAFE_ALLOCA;
1364 ptrdiff_t size = SCHARS (key_item), n; 1365 ptrdiff_t size = SCHARS (key_item), n;
1365 if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n)) 1366 if (ckd_mul (&n, size, MAX_MULTIBYTE_LENGTH))
1366 n = PTRDIFF_MAX; 1367 n = PTRDIFF_MAX;
1367 unsigned char *dst = SAFE_ALLOCA (n); 1368 unsigned char *dst = SAFE_ALLOCA (n);
1368 unsigned char *p = dst; 1369 unsigned char *p = dst;
@@ -1410,7 +1411,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1410 1411
1411 USE_SAFE_ALLOCA; 1412 USE_SAFE_ALLOCA;
1412 ptrdiff_t size = SCHARS (lc_key), n; 1413 ptrdiff_t size = SCHARS (lc_key), n;
1413 if (INT_MULTIPLY_WRAPV (size, MAX_MULTIBYTE_LENGTH, &n)) 1414 if (ckd_mul (&n, size, MAX_MULTIBYTE_LENGTH))
1414 n = PTRDIFF_MAX; 1415 n = PTRDIFF_MAX;
1415 unsigned char *dst = SAFE_ALLOCA (n); 1416 unsigned char *dst = SAFE_ALLOCA (n);
1416 1417
@@ -2096,7 +2097,7 @@ For an approximate inverse of this, see `kbd'. */)
2096 2097
2097 /* This has one extra element at the end that we don't pass to Fconcat. */ 2098 /* This has one extra element at the end that we don't pass to Fconcat. */
2098 ptrdiff_t size4; 2099 ptrdiff_t size4;
2099 if (INT_MULTIPLY_WRAPV (nkeys + nprefix, 4, &size4)) 2100 if (ckd_mul (&size4, nkeys + nprefix, 4))
2100 memory_full (SIZE_MAX); 2101 memory_full (SIZE_MAX);
2101 SAFE_ALLOCA_LISP (args, size4); 2102 SAFE_ALLOCA_LISP (args, size4);
2102 2103
@@ -3307,13 +3308,18 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3307 if (this_shadowed) 3308 if (this_shadowed)
3308 { 3309 {
3309 SET_PT (PT - 1); 3310 SET_PT (PT - 1);
3310 static char const fmt[] = " (currently shadowed by `%s')"; 3311 if (SYMBOLP (shadowed_by))
3311 USE_SAFE_ALLOCA; 3312 {
3312 char *buffer = SAFE_ALLOCA (sizeof fmt + 3313 static char const fmt[] = " (currently shadowed by `%s')";
3313 SBYTES (SYMBOL_NAME (shadowed_by))); 3314 USE_SAFE_ALLOCA;
3314 esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by))); 3315 char *buffer =
3315 insert_string (buffer); 3316 SAFE_ALLOCA (sizeof fmt + SBYTES (SYMBOL_NAME (shadowed_by)));
3316 SAFE_FREE(); 3317 esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by)));
3318 insert_string (buffer);
3319 SAFE_FREE();
3320 }
3321 else /* Could be a keymap, a lambda, or a keyboard macro. */
3322 insert_string (" (currently shadowed)");
3317 SET_PT (PT + 1); 3323 SET_PT (PT + 1);
3318 } 3324 }
3319 } 3325 }