# HG changeset patch # User Kenichi Handa # Date 934548876 0 # Node ID 1fb18e7e3f3513fb94ced6a6a4a4539e02e4c1fe # Parent 2228d0a678ef05d81e48ea8fb0413cdded00c89c (read_escape): For Control modifier, pay attention to multibyte character. (read1): Likewise. Singal error or a multibyte character which has a modifer bit. Check validity of Shift modifer. diff -r 2228d0a678ef -r 1fb18e7e3f35 src/lread.c --- a/src/lread.c Fri Aug 13 12:54:08 1999 +0000 +++ b/src/lread.c Fri Aug 13 12:54:36 1999 +0000 @@ -1492,8 +1492,10 @@ c = READCHAR; if (c == '\\') c = read_escape (readcharfun, 0); - if ((c & 0177) == '?') - return 0177 | c; + if ((c & ~CHAR_MODIFIER_MASK) == '?') + return 0177 | (c & CHAR_MODIFIER_MASK); + else if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) + return c | ctrl_modifier; /* ASCII control chars are made from letters (both cases), as well as the non-letters within 0100...0137. */ else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) @@ -1949,17 +1951,20 @@ /* If an escape specifies a non-ASCII single-byte character, this must be a unibyte string. */ - if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_META)) - && ! ASCII_BYTE_P (c)) + if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)) + && ! ASCII_BYTE_P ((c & ~CHAR_MODIFIER_MASK))) force_singlebyte = 1; } - if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_META))) + if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) { unsigned char workbuf[4]; unsigned char *str = workbuf; int length; + /* Any modifiers for a multibyte character are invalid. */ + if (c & CHAR_MODIFIER_MASK) + error ("Invalid modifier in string"); length = non_ascii_char_to_string (c, workbuf, &str); if (length > 1) force_multibyte = 1; @@ -1975,6 +1980,15 @@ else if (c == (CHAR_CTL | '?')) c = 127; + if (c & CHAR_SHIFT) + { + /* Shift modifier is valid only with [A-Za-z]. */ + if ((c & 0377) >= 'A' && (c & 0377) <= 'Z') + c &= ~CHAR_SHIFT; + else if ((c & 0377) >= 'a' && (c & 0377) <= 'z') + c = (c & ~CHAR_SHIFT) - ('a' - 'A'); + } + if (c & CHAR_META) /* Move the meta bit to the right place for a string. */ c = (c & ~CHAR_META) | 0x80;