]> git.eshelyaron.com Git - emacs.git/commitdiff
Initialise unread buffer
authorMattias Engdegård <mattiase@acm.org>
Sun, 19 Sep 2021 14:16:34 +0000 (16:16 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sun, 19 Sep 2021 14:22:29 +0000 (16:22 +0200)
The reader has an extra 1-char unread buffer that was incorrectly
initialised to 0, which means that the first character read would
always be NUL.  As this is often the code that looks for the
lexical-binding cookie, the first loaded source module would be
treated as dynamically bound.  During bootstrapping this is loadup.el
and so its local variables got dumped into the global environment.

* src/lread.c (unread_char): Initialise to empty.
(Fload): Initialise here too just in case.

src/lread.c

index a6c2db5d99453ab7472c94ed765bba3bbac7ddf1..2abe2fd91ab4db232a216100556e9dde7987ab1e 100644 (file)
@@ -192,7 +192,7 @@ static int readbyte_from_string (int, Lisp_Object);
    Qlambda, or a cons, we use this to keep an unread character because
    a file stream can't handle multibyte-char unreading.  The value -1
    means that there's no unread character.  */
-static int unread_char;
+static int unread_char = -1;
 
 static int
 readchar (Lisp_Object readcharfun, bool *multibyte)
@@ -1507,6 +1507,7 @@ Return t if the file exists and loads successfully.  */)
       input.stream = stream;
       input.lookahead = 0;
       infile = &input;
+      unread_char = -1;
     }
 
   if (! NILP (Vpurify_flag))