diff src/lread.c @ 90533:8a8e69664178

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 343-356) - Update from CVS - Update for ERC 5.1.3. - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 113-115) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-90
author Miles Bader <miles@gnu.org>
date Wed, 19 Jul 2006 00:42:56 +0000
parents 138ce2701550 da0099bc0ba4
children 858cb33ae39d
line wrap: on
line diff
--- a/src/lread.c	Fri Jul 14 02:25:53 2006 +0000
+++ b/src/lread.c	Wed Jul 19 00:42:56 2006 +0000
@@ -226,6 +226,9 @@
 static Lisp_Object load_unwind P_ ((Lisp_Object));
 static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object));
 
+static void invalid_syntax P_ ((const char *, int)) NO_RETURN;
+static void end_of_file_error P_ (()) NO_RETURN;
+
 
 /* Functions that read one byte from the current source READCHARFUN
    or unreads one byte.  If the integer argument C is -1, it returns
@@ -634,7 +637,7 @@
 		     input_method)
      int no_switch_frame, ascii_required, error_nonascii, input_method;
 {
-  register Lisp_Object val, delayed_switch_frame;
+  Lisp_Object val, delayed_switch_frame;
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (display_hourglass_p)
@@ -978,10 +981,8 @@
   if (fd == -1)
     {
       if (NILP (noerror))
-	Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
-				     Fcons (file, Qnil)));
-      else
-	return Qnil;
+	xsignal2 (Qfile_error, build_string ("Cannot open load file"), file);
+      return Qnil;
     }
 
   /* Tell startup.el whether or not we found the user's init file.  */
@@ -1022,8 +1023,7 @@
       {
 	if (fd >= 0)
 	  emacs_close (fd);
-	Fsignal (Qerror, Fcons (build_string ("Recursive load"),
-				Fcons (found, Vloads_in_progress)));
+	signal_error ("Recursive load", Fcons (found, Vloads_in_progress));
       }
     record_unwind_protect (record_load_unwind, Vloads_in_progress);
     Vloads_in_progress = Fcons (found, Vloads_in_progress);
@@ -1532,11 +1532,9 @@
   Lisp_Object data;
 
   if (STRINGP (Vload_file_name))
-    data = Fcons (Vload_file_name, Qnil);
-  else
-    data = Qnil;
-
-  Fsignal (Qend_of_file, data);
+    xsignal1 (Qend_of_file, Vload_file_name);
+
+  xsignal0 (Qend_of_file);
 }
 
 /* UNIBYTE specifies how to set load_convert_to_unibyte
@@ -1562,7 +1560,6 @@
   int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   struct buffer *b = 0;
-  int bpos;
   int continue_reading_p;
   /* Nonzero if reading an entire buffer.  */
   int whole_buffer = 0;
@@ -1572,7 +1569,7 @@
   if (MARKERP (readcharfun))
     {
       if (NILP (start))
-	start = readcharfun;	
+	start = readcharfun;
     }
 
   if (BUFFERP (readcharfun))
@@ -1593,8 +1590,8 @@
 
   /* Try to ensure sourcename is a truename, except whilst preloading. */
   if (NILP (Vpurify_flag)
-      && !NILP (sourcename) && Ffile_name_absolute_p (sourcename)
-      && (!NILP (Ffboundp (Qfile_truename))))
+      && !NILP (sourcename) && !NILP (Ffile_name_absolute_p (sourcename))
+      && !NILP (Ffboundp (Qfile_truename)))
     sourcename = call1 (Qfile_truename, sourcename) ;
 
   LOADHIST_ATTACH (sourcename);
@@ -1703,7 +1700,7 @@
       first_sexp = 0;
     }
 
-  build_load_history (sourcename, 
+  build_load_history (sourcename,
 		      stream || whole_buffer);
 
   UNGCPRO;
@@ -1893,6 +1890,21 @@
   return retval;
 }
 
+
+/* Signal Qinvalid_read_syntax error.
+   S is error string of length N (if > 0)  */
+
+static void
+invalid_syntax (s, n)
+     const char *s;
+     int n;
+{
+  if (!n)
+    n = strlen (s);
+  xsignal1 (Qinvalid_read_syntax, make_string (s, n));
+}
+
+
 /* Use this for recursive reads, in contexts where internal tokens
    are not allowed. */
 
@@ -1904,12 +1916,11 @@
   int c;
 
   val = read1 (readcharfun, &c, 0);
-  if (c)
-    Fsignal (Qinvalid_read_syntax, Fcons (Fmake_string (make_number (1),
-							make_number (c)),
-					  Qnil));
-
-  return val;
+  if (!c)
+    return val;
+
+  xsignal1 (Qinvalid_read_syntax,
+	    Fmake_string (make_number (1), make_number (c)));
 }
 
 static int read_buffer_size;
@@ -2127,7 +2138,6 @@
     }
 }
 
-
 /* Read an integer in radix RADIX using READCHARFUN to read
    characters.  RADIX must be in the interval [2..36]; if it isn't, a
    read error is signaled .  Value is the integer read.  Signals an
@@ -2187,7 +2197,7 @@
     {
       char buf[50];
       sprintf (buf, "integer, radix %d", radix);
-      Fsignal (Qinvalid_read_syntax, Fcons (build_string (buf), Qnil));
+      invalid_syntax (buf, 0);
     }
 
   return make_number (sign * number);
@@ -2267,10 +2277,9 @@
 		  XSETSUB_CHAR_TABLE (tmp, XSUB_CHAR_TABLE (tmp));
 		  return tmp;
 		}
-	      Fsignal (Qinvalid_read_syntax,
-		       Fcons (make_string ("#^^", 3), Qnil));
+	      invalid_syntax ("#^^", 3);
 	    }
-	  Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#^", 2), Qnil));
+	  invalid_syntax ("#^", 2);
 	}
       if (c == '&')
 	{
@@ -2294,8 +2303,7 @@
 			 version.  */
 		      && ! (XFASTINT (length)
 			    == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR)))
-		Fsignal (Qinvalid_read_syntax,
-			 Fcons (make_string ("#&...", 5), Qnil));
+		invalid_syntax ("#&...", 5);
 
 	      val = Fmake_bool_vector (length, Qnil);
 	      bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data,
@@ -2306,8 +2314,7 @@
 		  &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
 	      return val;
 	    }
-	  Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5),
-						Qnil));
+	  invalid_syntax ("#&...", 5);
 	}
       if (c == '[')
 	{
@@ -2327,7 +2334,7 @@
 	  /* Read the string itself.  */
 	  tmp = read1 (readcharfun, &ch, 0);
 	  if (ch != 0 || !STRINGP (tmp))
-	    Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
+	    invalid_syntax ("#", 1);
 	  GCPRO1 (tmp);
 	  /* Read the intervals and their properties.  */
 	  while (1)
@@ -2343,9 +2350,7 @@
 	      if (ch == 0)
 		plist = read1 (readcharfun, &ch, 0);
 	      if (ch)
-		Fsignal (Qinvalid_read_syntax,
-			 Fcons (build_string ("invalid string property list"),
-				Qnil));
+		invalid_syntax ("Invalid string property list", 0);
 	      Fset_text_properties (beg, end, plist, tmp);
 	    }
 	  UNGCPRO;
@@ -2502,7 +2507,7 @@
 	return read_integer (readcharfun, 2);
 
       UNREAD (c);
-      Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
+      invalid_syntax ("#", 1);
 
     case ';':
       while ((c = READCHAR) >= 0 && c != '\n');
@@ -2599,10 +2604,10 @@
 			  || (new_backquote_flag && next_char == ','))));
 	  }
 	UNREAD (next_char);
-	if (!ok)
-	  Fsignal (Qinvalid_read_syntax, Fcons (make_string ("?", 1), Qnil));
-
-	return make_number (c);
+	if (ok)
+	  return make_number (c);
+
+	invalid_syntax ("?", 1);
       }
 
     case '"':
@@ -3238,8 +3243,7 @@
 	    {
 	      if (ch == ']')
 		return val;
-	      Fsignal (Qinvalid_read_syntax,
-		       Fcons (make_string (") or . in a vector", 18), Qnil));
+	      invalid_syntax (") or . in a vector", 18);
 	    }
 	  if (ch == ')')
 	    return val;
@@ -3341,9 +3345,9 @@
 
 		  return val;
 		}
-	      return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil));
+	      invalid_syntax (". in wrong context", 18);
 	    }
-	  return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil));
+	  invalid_syntax ("] in a list", 11);
 	}
       tem = (read_pure && flag <= 0
 	     ? pure_cons (elt, Qnil)
@@ -3376,12 +3380,11 @@
 check_obarray (obarray)
      Lisp_Object obarray;
 {
-  while (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+  if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
     {
       /* If Vobarray is now invalid, force it to be valid.  */
       if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
-
-      obarray = wrong_type_argument (Qvectorp, obarray);
+      wrong_type_argument (Qvectorp, obarray);
     }
   return obarray;
 }