From: Kenichi Handa Date: Tue, 13 Mar 2001 06:04:12 +0000 (+0000) Subject: (read_multibyte): Check the validity of multibyte sequence. If X-Git-Tag: emacs-pretest-21.0.100~44 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0d5e5843574a732cc3ba5ce66aa4a22f106cad5f;p=emacs.git (read_multibyte): Check the validity of multibyte sequence. If invalid, return the first byte. --- 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) 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 `\'. */