diff src/lread.c @ 4453:29efd169efe7

Automated merge with file:/Sources/xemacs-21.5-checked-out
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 11 May 2008 11:24:01 +0200
parents ac6231e0c1df
children 7869173584fc
line wrap: on
line diff
--- a/src/lread.c	Sun May 11 11:20:24 2008 +0200
+++ b/src/lread.c	Sun May 11 11:24:01 2008 +0200
@@ -744,6 +744,25 @@
     internal_bind_lisp_object (&Vfile_domain, Qnil);
 #endif
 
+    /* Is there a #!? If so, read it, and unread ;!.
+
+       GNU implement this by treating any #! anywhere in the source text as
+       commenting out the whole line. */
+    {
+      char shebangp[2];
+      int num_read;
+
+      num_read = Lstream_read (XLSTREAM (lispstream), shebangp,
+                               sizeof(shebangp));
+      if (sizeof(shebangp) == num_read
+	  && 0 == strncmp("#!", shebangp, sizeof(shebangp)))
+	{
+          shebangp[0] = ';';
+	}
+
+      Lstream_unread (XLSTREAM (lispstream), shebangp, num_read);
+    }
+
     /* Now determine what sort of ELC file we're reading in. */
     internal_bind_int (&load_byte_code_version, load_byte_code_version);
     if (reading_elc)
@@ -2763,6 +2782,8 @@
 
 	if (c == '\\')
 	  c = read_escape (readcharfun);
+	if (c < 0)
+	  return Fsignal (Qinvalid_read_syntax, list1 (READCHARFUN_MAYBE (readcharfun)));
 	return make_char (c);
       }