]> git.eshelyaron.com Git - emacs.git/commitdiff
* src/lread.c (lisp_file_lexically_bound_p): Handle #! lines.
authorGlenn Morris <rgm@gnu.org>
Fri, 28 Sep 2012 07:40:42 +0000 (00:40 -0700)
committerGlenn Morris <rgm@gnu.org>
Fri, 28 Sep 2012 07:40:42 +0000 (00:40 -0700)
Fixes: debbugs:12528
src/ChangeLog
src/lread.c

index b0899d67ca8c5b1b5ec00c56e29f7bb3fe2bf2a6..601c72a9fd34d473271c45bbe09151e3311f99c0 100644 (file)
@@ -1,3 +1,7 @@
+2012-09-28  Glenn Morris  <rgm@gnu.org>
+
+       * lread.c (lisp_file_lexically_bound_p): Handle #! lines.  (Bug#12528)
+
 2012-09-27  Paul Eggert  <eggert@cs.ucla.edu>
 
        Check more robustly for timer_settime.
index cb808b376772d4087536e393eb0fb8360ac87238..0b7fd9067dc72f191a619fbe44b8df6c1ca4254a 100644 (file)
@@ -764,13 +764,28 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
 
 /* Return true if the lisp code read using READCHARFUN defines a non-nil
    `lexical-binding' file variable.  After returning, the stream is
-   positioned following the first line, if it is a comment, otherwise
-   nothing is read.  */
+   positioned following the first line, if it is a comment or #! line,
+   otherwise nothing is read.  */
 
 static int
 lisp_file_lexically_bound_p (Lisp_Object readcharfun)
 {
   int ch = READCHAR;
+
+  if (ch == '#')
+    {
+      ch = READCHAR;
+      if (ch != '!')
+        {
+          UNREAD (ch);
+          UNREAD ('#');
+          return 0;
+        }
+      while (ch != '\n' && ch != EOF)
+        ch = READCHAR;
+      if (ch == '\n') ch = READCHAR;
+    }
+
   if (ch != ';')
     /* The first line isn't a comment, just give up.  */
     {