summaryrefslogtreecommitdiff
path: root/src/character.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2008-03-05 04:18:00 +0000
committerKenichi Handa <handa@m17n.org>2008-03-05 04:18:00 +0000
commitd0363d443c7cf37b1666fe48d3496814bd3e41ca (patch)
treeae9b38105dff869bc2ba0bed86e330cb5ba446e7 /src/character.c
parent388059876ac4a5aa55149e0544f58118742c5020 (diff)
downloademacs-d0363d443c7cf37b1666fe48d3496814bd3e41ca.tar.gz
(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/character.c')
-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
char_resolve_modifier_mask (c)
int c;
{
- /* An non-ASCII character can't reflect modifier bits to the code. */
+ /* A non-ASCII character can't reflect modifier bits to the code. */
if (! ASCII_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
return c;
/* For Meta, Shift, and Control modifiers, we need special care. */
- if (c & CHAR_META)
- {
- /* Move the meta bit to the right place for a string. */
- c = (c & ~CHAR_META) | 0x80;
- }
if (c & CHAR_SHIFT)
{
/* Shift modifier is valid only with [A-Za-z]. */
@@ -120,6 +115,15 @@ char_resolve_modifier_mask (c)
c &= ~CHAR_SHIFT;
else if ((c & 0377) >= 'a' && (c & 0377) <= 'z')
c = (c & ~CHAR_SHIFT) - ('a' - 'A');
+ /* Shift modifier with ASCII control characters should be
+ ignored. */
+ else if ((c & ~CHAR_MODIFIER_MASK) < 0x20)
+ c &= ~CHAR_SHIFT;
+ }
+ if (c & CHAR_META)
+ {
+ /* Move the meta bit to the right place for a string. */
+ c = (c & ~CHAR_META) | 0x80;
}
if (c & CHAR_CTL)
{
@@ -967,6 +971,22 @@ usage: (unibyte-string &rest BYTES) */)
return make_string_from_bytes ((char *) buf, n, p - buf);
}
+DEFUN ("char-resolve-modifers", Fchar_resolve_modifiers,
+ Schar_resolve_modifiers, 1, 1, 0,
+ doc: /* Resolve modifiers in the character CHAR.
+The value is a character with modifiers resolved into the character
+code. Unresolved modifiers are kept in the value.
+usage: (char-resolve-modifers CHAR) */)
+ (character)
+ Lisp_Object character;
+{
+ int c;
+
+ CHECK_NUMBER (character);
+ c = XINT (character);
+ return make_number (char_resolve_modifier_mask (c));
+}
+
void
init_character_once ()
{
@@ -993,6 +1013,7 @@ syms_of_character ()
defsubr (&Schar_direction);
defsubr (&Sstring);
defsubr (&Sunibyte_string);
+ defsubr (&Schar_resolve_modifiers);
DEFVAR_LISP ("translation-table-vector", &Vtranslation_table_vector,
doc: /*