From: Richard M. Stallman Date: Mon, 5 Jan 1998 17:14:29 +0000 (+0000) Subject: (read_minibuf): Handle bytes vs chars X-Git-Tag: emacs-20.3~2489 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82d6226f4e92fb6635ca19a6f4667340dadcdb0f;p=emacs.git (read_minibuf): Handle bytes vs chars when checking for junk at end of expression. --- diff --git a/src/minibuf.c b/src/minibuf.c index 583fc2ac7da..8d35b73de6f 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -470,12 +470,22 @@ read_minibuf (map, initial, prompt, backup_n, expflag, { Lisp_Object expr_and_pos; unsigned char *p; + int pos; expr_and_pos = Fread_from_string (val, Qnil, Qnil); - /* Ignore trailing whitespace; any other trailing junk is an error. */ - for (p = XSTRING (val)->data + XINT (Fcdr (expr_and_pos)); *p; p++) - if (*p != ' ' && *p != '\t' && *p != '\n') - error ("Trailing garbage following expression"); + pos = XINT (Fcdr (expr_and_pos)); + if (pos != XSTRING (val)->size) + { + /* Ignore trailing whitespace; any other trailing junk is an error. */ + int i; + pos = string_char_to_byte (val, pos); + for (i = pos; i < XSTRING (val)->size_byte; i++) + { + int c = XSTRING (val)->data[i]; + if (c != ' ' && c != '\t' && c != '\n') + error ("Trailing garbage following expression"); + } + } val = Fcar (expr_and_pos); }