Mercurial > emacs
comparison src/lread.c @ 25251:1fb18e7e3f35
(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.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 13 Aug 1999 12:54:36 +0000 |
parents | f2c7d7fb6198 |
children | 301ce7f0b398 |
comparison
equal
deleted
inserted
replaced
25250:2228d0a678ef | 25251:1fb18e7e3f35 |
---|---|
1490 error ("Invalid escape character syntax"); | 1490 error ("Invalid escape character syntax"); |
1491 case '^': | 1491 case '^': |
1492 c = READCHAR; | 1492 c = READCHAR; |
1493 if (c == '\\') | 1493 if (c == '\\') |
1494 c = read_escape (readcharfun, 0); | 1494 c = read_escape (readcharfun, 0); |
1495 if ((c & 0177) == '?') | 1495 if ((c & ~CHAR_MODIFIER_MASK) == '?') |
1496 return 0177 | c; | 1496 return 0177 | (c & CHAR_MODIFIER_MASK); |
1497 else if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) | |
1498 return c | ctrl_modifier; | |
1497 /* ASCII control chars are made from letters (both cases), | 1499 /* ASCII control chars are made from letters (both cases), |
1498 as well as the non-letters within 0100...0137. */ | 1500 as well as the non-letters within 0100...0137. */ |
1499 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) | 1501 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) |
1500 return (c & (037 | ~0177)); | 1502 return (c & (037 | ~0177)); |
1501 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) | 1503 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) |
1947 continue; | 1949 continue; |
1948 } | 1950 } |
1949 | 1951 |
1950 /* If an escape specifies a non-ASCII single-byte character, | 1952 /* If an escape specifies a non-ASCII single-byte character, |
1951 this must be a unibyte string. */ | 1953 this must be a unibyte string. */ |
1952 if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_META)) | 1954 if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)) |
1953 && ! ASCII_BYTE_P (c)) | 1955 && ! ASCII_BYTE_P ((c & ~CHAR_MODIFIER_MASK))) |
1954 force_singlebyte = 1; | 1956 force_singlebyte = 1; |
1955 } | 1957 } |
1956 | 1958 |
1957 if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_META))) | 1959 if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) |
1958 { | 1960 { |
1959 unsigned char workbuf[4]; | 1961 unsigned char workbuf[4]; |
1960 unsigned char *str = workbuf; | 1962 unsigned char *str = workbuf; |
1961 int length; | 1963 int length; |
1962 | 1964 |
1965 /* Any modifiers for a multibyte character are invalid. */ | |
1966 if (c & CHAR_MODIFIER_MASK) | |
1967 error ("Invalid modifier in string"); | |
1963 length = non_ascii_char_to_string (c, workbuf, &str); | 1968 length = non_ascii_char_to_string (c, workbuf, &str); |
1964 if (length > 1) | 1969 if (length > 1) |
1965 force_multibyte = 1; | 1970 force_multibyte = 1; |
1966 | 1971 |
1967 bcopy (str, p, length); | 1972 bcopy (str, p, length); |
1972 /* Allow `\C- ' and `\C-?'. */ | 1977 /* Allow `\C- ' and `\C-?'. */ |
1973 if (c == (CHAR_CTL | ' ')) | 1978 if (c == (CHAR_CTL | ' ')) |
1974 c = 0; | 1979 c = 0; |
1975 else if (c == (CHAR_CTL | '?')) | 1980 else if (c == (CHAR_CTL | '?')) |
1976 c = 127; | 1981 c = 127; |
1982 | |
1983 if (c & CHAR_SHIFT) | |
1984 { | |
1985 /* Shift modifier is valid only with [A-Za-z]. */ | |
1986 if ((c & 0377) >= 'A' && (c & 0377) <= 'Z') | |
1987 c &= ~CHAR_SHIFT; | |
1988 else if ((c & 0377) >= 'a' && (c & 0377) <= 'z') | |
1989 c = (c & ~CHAR_SHIFT) - ('a' - 'A'); | |
1990 } | |
1977 | 1991 |
1978 if (c & CHAR_META) | 1992 if (c & CHAR_META) |
1979 /* Move the meta bit to the right place for a string. */ | 1993 /* Move the meta bit to the right place for a string. */ |
1980 c = (c & ~CHAR_META) | 0x80; | 1994 c = (c & ~CHAR_META) | 0x80; |
1981 if (c & ~0xff) | 1995 if (c & ~0xff) |