# HG changeset patch # User Kenichi Handa # Date 984463452 0 # Node ID 23382dbfb9d025afca9ac98f843086b0bd36105a # Parent bd3b761b45bae101d4ec04c8b24a92cf114e3ffd (read_multibyte): Check the validity of multibyte sequence. If invalid, return the first byte. diff -r bd3b761b45ba -r 23382dbfb9d0 src/lread.c --- a/src/lread.c Tue Mar 13 06:03:52 2001 +0000 +++ b/src/lread.c Tue Mar 13 06:04:12 2001 +0000 @@ -1506,13 +1506,20 @@ characters. */ unsigned char str[MAX_MULTIBYTE_LENGTH]; int len = 0; + int bytes; str[len++] = c; while ((c = READCHAR) >= 0xA0 && len < MAX_MULTIBYTE_LENGTH) str[len++] = c; UNREAD (c); - return STRING_CHAR (str, len); + if (UNIBYTE_STR_AS_MULTIBYTE_P (str, len, bytes)) + return STRING_CHAR (str, len); + /* The byte sequence is not valid as multibyte. Unread all bytes + but the first one, and return the first byte. */ + while (--len > 0) + UNREAD (str[len]); + return str[0]; } /* Read a \-escape sequence, assuming we already read the `\'. */