aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2001-03-13 06:04:12 +0000
committerKenichi Handa2001-03-13 06:04:12 +0000
commit0d5e5843574a732cc3ba5ce66aa4a22f106cad5f (patch)
tree135ea2c2dec545a23f8757085c165845cf562b85 /src
parentc6f7429aa9e19172cfcde6cbebda559234e3db83 (diff)
downloademacs-0d5e5843574a732cc3ba5ce66aa4a22f106cad5f.tar.gz
emacs-0d5e5843574a732cc3ba5ce66aa4a22f106cad5f.zip
(read_multibyte): Check the validity of multibyte sequence. If
invalid, return the first byte.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lread.c b/src/lread.c
index b862bbf217b..3f2e747c998 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1506,13 +1506,20 @@ read_multibyte (c, readcharfun)
1506 characters. */ 1506 characters. */
1507 unsigned char str[MAX_MULTIBYTE_LENGTH]; 1507 unsigned char str[MAX_MULTIBYTE_LENGTH];
1508 int len = 0; 1508 int len = 0;
1509 int bytes;
1509 1510
1510 str[len++] = c; 1511 str[len++] = c;
1511 while ((c = READCHAR) >= 0xA0 1512 while ((c = READCHAR) >= 0xA0
1512 && len < MAX_MULTIBYTE_LENGTH) 1513 && len < MAX_MULTIBYTE_LENGTH)
1513 str[len++] = c; 1514 str[len++] = c;
1514 UNREAD (c); 1515 UNREAD (c);
1515 return STRING_CHAR (str, len); 1516 if (UNIBYTE_STR_AS_MULTIBYTE_P (str, len, bytes))
1517 return STRING_CHAR (str, len);
1518 /* The byte sequence is not valid as multibyte. Unread all bytes
1519 but the first one, and return the first byte. */
1520 while (--len > 0)
1521 UNREAD (str[len]);
1522 return str[0];
1516} 1523}
1517 1524
1518/* Read a \-escape sequence, assuming we already read the `\'. */ 1525/* Read a \-escape sequence, assuming we already read the `\'. */