aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-03-05 04:18:00 +0000
committerKenichi Handa2008-03-05 04:18:00 +0000
commitd0363d443c7cf37b1666fe48d3496814bd3e41ca (patch)
treeae9b38105dff869bc2ba0bed86e330cb5ba446e7 /src
parent388059876ac4a5aa55149e0544f58118742c5020 (diff)
downloademacs-d0363d443c7cf37b1666fe48d3496814bd3e41ca.tar.gz
emacs-d0363d443c7cf37b1666fe48d3496814bd3e41ca.zip
(char_resolve_modifier_mask): Fix previous change
(Fchar_resolve_modifiers): New function. (syms_of_character): Declare Fchar_resolve_modifiers as Lisp function.
Diffstat (limited to 'src')
-rw-r--r--src/character.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/character.c b/src/character.c
index a296fa94b24..f34e30912dc 100644
--- a/src/character.c
+++ b/src/character.c
@@ -103,16 +103,11 @@ int
103char_resolve_modifier_mask (c) 103char_resolve_modifier_mask (c)
104 int c; 104 int c;
105{ 105{
106 /* An non-ASCII character can't reflect modifier bits to the code. */ 106 /* A non-ASCII character can't reflect modifier bits to the code. */
107 if (! ASCII_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) 107 if (! ASCII_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
108 return c; 108 return c;
109 109
110 /* For Meta, Shift, and Control modifiers, we need special care. */ 110 /* For Meta, Shift, and Control modifiers, we need special care. */
111 if (c & CHAR_META)
112 {
113 /* Move the meta bit to the right place for a string. */
114 c = (c & ~CHAR_META) | 0x80;
115 }
116 if (c & CHAR_SHIFT) 111 if (c & CHAR_SHIFT)
117 { 112 {
118 /* Shift modifier is valid only with [A-Za-z]. */ 113 /* Shift modifier is valid only with [A-Za-z]. */
@@ -120,6 +115,15 @@ char_resolve_modifier_mask (c)
120 c &= ~CHAR_SHIFT; 115 c &= ~CHAR_SHIFT;
121 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z') 116 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z')
122 c = (c & ~CHAR_SHIFT) - ('a' - 'A'); 117 c = (c & ~CHAR_SHIFT) - ('a' - 'A');
118 /* Shift modifier with ASCII control characters should be
119 ignored. */
120 else if ((c & ~CHAR_MODIFIER_MASK) < 0x20)
121 c &= ~CHAR_SHIFT;
122 }
123 if (c & CHAR_META)
124 {
125 /* Move the meta bit to the right place for a string. */
126 c = (c & ~CHAR_META) | 0x80;
123 } 127 }
124 if (c & CHAR_CTL) 128 if (c & CHAR_CTL)
125 { 129 {
@@ -967,6 +971,22 @@ usage: (unibyte-string &rest BYTES) */)
967 return make_string_from_bytes ((char *) buf, n, p - buf); 971 return make_string_from_bytes ((char *) buf, n, p - buf);
968} 972}
969 973
974DEFUN ("char-resolve-modifers", Fchar_resolve_modifiers,
975 Schar_resolve_modifiers, 1, 1, 0,
976 doc: /* Resolve modifiers in the character CHAR.
977The value is a character with modifiers resolved into the character
978code. Unresolved modifiers are kept in the value.
979usage: (char-resolve-modifers CHAR) */)
980 (character)
981 Lisp_Object character;
982{
983 int c;
984
985 CHECK_NUMBER (character);
986 c = XINT (character);
987 return make_number (char_resolve_modifier_mask (c));
988}
989
970void 990void
971init_character_once () 991init_character_once ()
972{ 992{
@@ -993,6 +1013,7 @@ syms_of_character ()
993 defsubr (&Schar_direction); 1013 defsubr (&Schar_direction);
994 defsubr (&Sstring); 1014 defsubr (&Sstring);
995 defsubr (&Sunibyte_string); 1015 defsubr (&Sunibyte_string);
1016 defsubr (&Schar_resolve_modifiers);
996 1017
997 DEFVAR_LISP ("translation-table-vector", &Vtranslation_table_vector, 1018 DEFVAR_LISP ("translation-table-vector", &Vtranslation_table_vector,
998 doc: /* 1019 doc: /*