emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5252c45: Initialise unread buffer


From: Mattias Engdegård
Subject: master 5252c45: Initialise unread buffer
Date: Sun, 19 Sep 2021 10:22:52 -0400 (EDT)

branch: master
commit 5252c45850b3c4a3914f6c94dc163c2c23286bbf
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Initialise unread buffer
    
    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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lread.c b/src/lread.c
index a6c2db5..2abe2fd 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]