summaryrefslogtreecommitdiff
path: root/src/keymap.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2021-10-31 16:20:27 +0200
committerEli Zaretskii <eliz@gnu.org>2021-10-31 16:20:27 +0200
commite170a31c57b61eb40878bf28a850b2b492947ee8 (patch)
treef25c9cbf41740cdbc5b8d55219c1bbfcc29f7709 /src/keymap.c
parent5e05be566b0e13ce0b4e75da663fb051039f0751 (diff)
downloademacs-e170a31c57b61eb40878bf28a850b2b492947ee8.tar.gz
Avoid signaling errors in lookup-key
* src/keymap.c (Flookup_key): Handle KEY vectors where not all components are symbols. (Bug#51527) Do not merge to master.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 50f896d17cf..28ff71c01da 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1259,22 +1259,28 @@ recognize the default bindings, just as `read-key-sequence' does. */)
Lisp_Object new_key = make_vector (key_len, Qnil);
for (int i = 0; i < key_len; ++i)
{
- Lisp_Object sym = Fsymbol_name (AREF (key, i));
- USE_SAFE_ALLOCA;
- unsigned char *dst = SAFE_ALLOCA (SBYTES (sym) + 1);
- memcpy (dst, SSDATA (sym), SBYTES (sym));
- /* We can walk the string data byte by byte, because UTF-8
- encoding ensures that no other byte of any multibyte
- sequence will ever include a 7-bit byte equal to an ASCII
- single-byte character. */
- for (int j = 0; j < SBYTES (sym); ++j)
- if (dst[j] >= 'A' && dst[j] <= 'Z')
- dst[j] += 'a' - 'A'; /* Convert to lower case. */
- ASET (new_key, i, Fintern (make_multibyte_string ((char *) dst,
- SCHARS (sym),
- SBYTES (sym)),
- Qnil));
- SAFE_FREE ();
+ Lisp_Object item = AREF (key, i);
+ if (!SYMBOLP (item))
+ ASET (new_key, i, item);
+ else
+ {
+ Lisp_Object sym = Fsymbol_name (item);
+ USE_SAFE_ALLOCA;
+ unsigned char *dst = SAFE_ALLOCA (SBYTES (sym) + 1);
+ memcpy (dst, SSDATA (sym), SBYTES (sym));
+ /* We can walk the string data byte by byte, because
+ UTF-8 encoding ensures that no other byte of any
+ multibyte sequence will ever include a 7-bit byte
+ equal to an ASCII single-byte character. */
+ for (int j = 0; j < SBYTES (sym); ++j)
+ if (dst[j] >= 'A' && dst[j] <= 'Z')
+ dst[j] += 'a' - 'A'; /* Convert to lower case. */
+ ASET (new_key, i, Fintern (make_multibyte_string ((char *) dst,
+ SCHARS (sym),
+ SBYTES (sym)),
+ Qnil));
+ SAFE_FREE ();
+ }
}
found = lookup_key_1 (keymap, new_key, accept_default);
}