changeset 70535:8003a30510ee

(push_key_description): Handle invalid character key.
author Kenichi Handa <handa@m17n.org>
date Tue, 09 May 2006 13:17:24 +0000
parents afe3317800c2
children aa139a4a13b2
files src/keymap.c
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Tue May 09 12:47:12 2006 +0000
+++ b/src/keymap.c	Tue May 09 13:17:24 2006 +0000
@@ -2090,12 +2090,21 @@
      int force_multibyte;
 {
   unsigned c2;
+  int valid_p;
 
   /* Clear all the meaningless bits above the meta bit.  */
   c &= meta_modifier | ~ - meta_modifier;
   c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier
 	     | meta_modifier | shift_modifier | super_modifier);
 
+  valid_p = SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, 0);
+  if (! valid_p)
+    {
+      /* KEY_DESCRIPTION_SIZE is large enough for this.  */
+      p += sprintf (p, "[%d]", c);
+      return p;
+    }
+
   if (c & alt_modifier)
     {
       *p++ = 'A';
@@ -2183,16 +2192,13 @@
     }
   else
     {
-      int valid_p = SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, 0);
-
-      if (force_multibyte && valid_p)
+      if (force_multibyte)
 	{
 	  if (SINGLE_BYTE_CHAR_P (c))
 	    c = unibyte_char_to_multibyte (c);
 	  p += CHAR_STRING (c, p);
 	}
-      else if (NILP (current_buffer->enable_multibyte_characters)
-	       || valid_p)
+      else if (NILP (current_buffer->enable_multibyte_characters))
 	{
 	  int bit_offset;
 	  *p++ = '\\';