diff options
| author | Kenichi Handa | 1999-12-15 00:17:03 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1999-12-15 00:17:03 +0000 |
| commit | 449fea39770775819ba99eafc124ceeb97a280e2 (patch) | |
| tree | 07639bbde3b8e61bdf193091b35b7deb5f8fc268 /src/lread.c | |
| parent | 19481752625b2bfbc6442c701eb58750c03d1f4e (diff) | |
| download | emacs-449fea39770775819ba99eafc124ceeb97a280e2.tar.gz emacs-449fea39770775819ba99eafc124ceeb97a280e2.zip | |
(readchar): Adjusted for the change of CHAR_STRING.
Delete a code that handles an invalid too-long multibyte sequence
because we are now sure that we never encounter with such a
sequence.
(read_multibyte): Use macro MAX_MULTIBYTE_LENGTH, not
MAX_LENGTH_OF_MULTI_BYTE_FORM.
(init_obarray): Likewise.
(read1): Likewise. Adjusted for the change of CHAR_STRING.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 75 |
1 files changed, 8 insertions, 67 deletions
diff --git a/src/lread.c b/src/lread.c index 616e3bd6824..5e3ae083c46 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -219,31 +219,10 @@ readchar (readcharfun) | |||
| 219 | 219 | ||
| 220 | if (! NILP (inbuffer->enable_multibyte_characters)) | 220 | if (! NILP (inbuffer->enable_multibyte_characters)) |
| 221 | { | 221 | { |
| 222 | unsigned char workbuf[4]; | ||
| 223 | unsigned char *str = workbuf; | ||
| 224 | int length; | ||
| 225 | |||
| 226 | /* Fetch the character code from the buffer. */ | 222 | /* Fetch the character code from the buffer. */ |
| 227 | unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte); | 223 | unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, pt_byte); |
| 228 | BUF_INC_POS (inbuffer, pt_byte); | 224 | BUF_INC_POS (inbuffer, pt_byte); |
| 229 | c = STRING_CHAR (p, pt_byte - orig_pt_byte); | 225 | c = STRING_CHAR (p, pt_byte - orig_pt_byte); |
| 230 | |||
| 231 | /* Find the byte-sequence representation of that character. */ | ||
| 232 | if (SINGLE_BYTE_CHAR_P (c)) | ||
| 233 | length = 1, workbuf[0] = c; | ||
| 234 | else | ||
| 235 | length = non_ascii_char_to_string (c, workbuf, &str); | ||
| 236 | |||
| 237 | /* If the bytes for this character in the buffer | ||
| 238 | are not identical with what the character code implies, | ||
| 239 | read the bytes one by one from the buffer. */ | ||
| 240 | if (length != pt_byte - orig_pt_byte | ||
| 241 | || (length == 1 ? *str != *p : bcmp (str, p, length))) | ||
| 242 | { | ||
| 243 | readchar_backlog = pt_byte - orig_pt_byte; | ||
| 244 | c = BUF_FETCH_BYTE (inbuffer, orig_pt_byte); | ||
| 245 | readchar_backlog--; | ||
| 246 | } | ||
| 247 | } | 226 | } |
| 248 | else | 227 | else |
| 249 | { | 228 | { |
| @@ -276,31 +255,10 @@ readchar (readcharfun) | |||
| 276 | 255 | ||
| 277 | if (! NILP (inbuffer->enable_multibyte_characters)) | 256 | if (! NILP (inbuffer->enable_multibyte_characters)) |
| 278 | { | 257 | { |
| 279 | unsigned char workbuf[4]; | ||
| 280 | unsigned char *str = workbuf; | ||
| 281 | int length; | ||
| 282 | |||
| 283 | /* Fetch the character code from the buffer. */ | 258 | /* Fetch the character code from the buffer. */ |
| 284 | unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos); | 259 | unsigned char *p = BUF_BYTE_ADDRESS (inbuffer, bytepos); |
| 285 | BUF_INC_POS (inbuffer, bytepos); | 260 | BUF_INC_POS (inbuffer, bytepos); |
| 286 | c = STRING_CHAR (p, bytepos - orig_bytepos); | 261 | c = STRING_CHAR (p, bytepos - orig_bytepos); |
| 287 | |||
| 288 | /* Find the byte-sequence representation of that character. */ | ||
| 289 | if (SINGLE_BYTE_CHAR_P (c)) | ||
| 290 | length = 1, workbuf[0] = c; | ||
| 291 | else | ||
| 292 | length = non_ascii_char_to_string (c, workbuf, &str); | ||
| 293 | |||
| 294 | /* If the bytes for this character in the buffer | ||
| 295 | are not identical with what the character code implies, | ||
| 296 | read the bytes one by one from the buffer. */ | ||
| 297 | if (length != bytepos - orig_bytepos | ||
| 298 | || (length == 1 ? *str != *p : bcmp (str, p, length))) | ||
| 299 | { | ||
| 300 | readchar_backlog = bytepos - orig_bytepos; | ||
| 301 | c = BUF_FETCH_BYTE (inbuffer, orig_bytepos); | ||
| 302 | readchar_backlog--; | ||
| 303 | } | ||
| 304 | } | 262 | } |
| 305 | else | 263 | else |
| 306 | { | 264 | { |
| @@ -1399,12 +1357,12 @@ read_multibyte (c, readcharfun) | |||
| 1399 | { | 1357 | { |
| 1400 | /* We need the actual character code of this multibyte | 1358 | /* We need the actual character code of this multibyte |
| 1401 | characters. */ | 1359 | characters. */ |
| 1402 | unsigned char str[MAX_LENGTH_OF_MULTI_BYTE_FORM]; | 1360 | unsigned char str[MAX_MULTIBYTE_LENGTH]; |
| 1403 | int len = 0; | 1361 | int len = 0; |
| 1404 | 1362 | ||
| 1405 | str[len++] = c; | 1363 | str[len++] = c; |
| 1406 | while ((c = READCHAR) >= 0xA0 | 1364 | while ((c = READCHAR) >= 0xA0 |
| 1407 | && len < MAX_LENGTH_OF_MULTI_BYTE_FORM) | 1365 | && len < MAX_MULTIBYTE_LENGTH) |
| 1408 | str[len++] = c; | 1366 | str[len++] = c; |
| 1409 | UNREAD (c); | 1367 | UNREAD (c); |
| 1410 | return STRING_CHAR (str, len); | 1368 | return STRING_CHAR (str, len); |
| @@ -1935,7 +1893,7 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1935 | while ((c = READCHAR) >= 0 | 1893 | while ((c = READCHAR) >= 0 |
| 1936 | && c != '\"') | 1894 | && c != '\"') |
| 1937 | { | 1895 | { |
| 1938 | if (end - p < MAX_LENGTH_OF_MULTI_BYTE_FORM) | 1896 | if (end - p < MAX_MULTIBYTE_LENGTH) |
| 1939 | { | 1897 | { |
| 1940 | char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | 1898 | char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); |
| 1941 | p += new - read_buffer; | 1899 | p += new - read_buffer; |
| @@ -1964,19 +1922,11 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1964 | 1922 | ||
| 1965 | if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) | 1923 | if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) |
| 1966 | { | 1924 | { |
| 1967 | unsigned char workbuf[4]; | ||
| 1968 | unsigned char *str = workbuf; | ||
| 1969 | int length; | ||
| 1970 | |||
| 1971 | /* Any modifiers for a multibyte character are invalid. */ | 1925 | /* Any modifiers for a multibyte character are invalid. */ |
| 1972 | if (c & CHAR_MODIFIER_MASK) | 1926 | if (c & CHAR_MODIFIER_MASK) |
| 1973 | error ("Invalid modifier in string"); | 1927 | error ("Invalid modifier in string"); |
| 1974 | length = non_ascii_char_to_string (c, workbuf, &str); | 1928 | p += CHAR_STRING (c, p); |
| 1975 | if (length > 1) | 1929 | force_multibyte = 1; |
| 1976 | force_multibyte = 1; | ||
| 1977 | |||
| 1978 | bcopy (str, p, length); | ||
| 1979 | p += length; | ||
| 1980 | } | 1930 | } |
| 1981 | else | 1931 | else |
| 1982 | { | 1932 | { |
| @@ -2090,7 +2040,7 @@ read1 (readcharfun, pch, first_in_list) | |||
| 2090 | || c == '[' || c == ']' || c == '#' | 2040 | || c == '[' || c == ']' || c == '#' |
| 2091 | )) | 2041 | )) |
| 2092 | { | 2042 | { |
| 2093 | if (end - p < MAX_LENGTH_OF_MULTI_BYTE_FORM) | 2043 | if (end - p < MAX_MULTIBYTE_LENGTH) |
| 2094 | { | 2044 | { |
| 2095 | register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | 2045 | register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); |
| 2096 | p += new - read_buffer; | 2046 | p += new - read_buffer; |
| @@ -2104,16 +2054,7 @@ read1 (readcharfun, pch, first_in_list) | |||
| 2104 | } | 2054 | } |
| 2105 | 2055 | ||
| 2106 | if (! SINGLE_BYTE_CHAR_P (c)) | 2056 | if (! SINGLE_BYTE_CHAR_P (c)) |
| 2107 | { | 2057 | p += CHAR_STRING (c, p); |
| 2108 | unsigned char workbuf[4]; | ||
| 2109 | unsigned char *str = workbuf; | ||
| 2110 | int length; | ||
| 2111 | |||
| 2112 | length = non_ascii_char_to_string (c, workbuf, &str); | ||
| 2113 | |||
| 2114 | bcopy (str, p, length); | ||
| 2115 | p += length; | ||
| 2116 | } | ||
| 2117 | else | 2058 | else |
| 2118 | *p++ = c; | 2059 | *p++ = c; |
| 2119 | 2060 | ||
| @@ -2994,7 +2935,7 @@ init_obarray () | |||
| 2994 | Qvariable_documentation = intern ("variable-documentation"); | 2935 | Qvariable_documentation = intern ("variable-documentation"); |
| 2995 | staticpro (&Qvariable_documentation); | 2936 | staticpro (&Qvariable_documentation); |
| 2996 | 2937 | ||
| 2997 | read_buffer_size = 100 + MAX_LENGTH_OF_MULTI_BYTE_FORM; | 2938 | read_buffer_size = 100 + MAX_MULTIBYTE_LENGTH; |
| 2998 | read_buffer = (char *) malloc (read_buffer_size); | 2939 | read_buffer = (char *) malloc (read_buffer_size); |
| 2999 | } | 2940 | } |
| 3000 | 2941 | ||