aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2006-07-18 13:28:34 +0000
committerKim F. Storm2006-07-18 13:28:34 +0000
commit336d4a9c4fa1b6b2136178b25276e8acc9e17986 (patch)
tree9853626bf33f16d13cba8f7269dd15c3bc119848 /src
parent7e85c1aa4daec9267204ac5757a3f149a7914c6a (diff)
downloademacs-336d4a9c4fa1b6b2136178b25276e8acc9e17986.tar.gz
emacs-336d4a9c4fa1b6b2136178b25276e8acc9e17986.zip
(Fload): Use xsignal2, signal_error.
(end_of_file_error): Use xsignal0, xsignal1. (read0): Use xsignal1. (invalid_syntax): New error function marked no-return. (read_integer, read1, read_list): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/lread.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/lread.c b/src/lread.c
index 3ee50e946a7..c407b5947d9 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -214,6 +214,8 @@ static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object,
214static Lisp_Object load_unwind P_ ((Lisp_Object)); 214static Lisp_Object load_unwind P_ ((Lisp_Object));
215static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object)); 215static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object));
216 216
217static void invalid_syntax P_ ((const char *, int)) NO_RETURN;
218
217 219
218/* Handle unreading and rereading of characters. 220/* Handle unreading and rereading of characters.
219 Write READCHAR to read a character, 221 Write READCHAR to read a character,
@@ -797,10 +799,8 @@ Return t if the file exists and loads successfully. */)
797 if (fd == -1) 799 if (fd == -1)
798 { 800 {
799 if (NILP (noerror)) 801 if (NILP (noerror))
800 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), 802 xsignal2 (Qfile_error, build_string ("Cannot open load file"), file);
801 Fcons (file, Qnil))); 803 return Qnil;
802 else
803 return Qnil;
804 } 804 }
805 805
806 /* Tell startup.el whether or not we found the user's init file. */ 806 /* Tell startup.el whether or not we found the user's init file. */
@@ -841,8 +841,7 @@ Return t if the file exists and loads successfully. */)
841 { 841 {
842 if (fd >= 0) 842 if (fd >= 0)
843 emacs_close (fd); 843 emacs_close (fd);
844 Fsignal (Qerror, Fcons (build_string ("Recursive load"), 844 signal_error ("Recursive load", Fcons (found, Vloads_in_progress));
845 Fcons (found, Vloads_in_progress)));
846 } 845 }
847 record_unwind_protect (record_load_unwind, Vloads_in_progress); 846 record_unwind_protect (record_load_unwind, Vloads_in_progress);
848 Vloads_in_progress = Fcons (found, Vloads_in_progress); 847 Vloads_in_progress = Fcons (found, Vloads_in_progress);
@@ -1339,11 +1338,9 @@ end_of_file_error ()
1339 Lisp_Object data; 1338 Lisp_Object data;
1340 1339
1341 if (STRINGP (Vload_file_name)) 1340 if (STRINGP (Vload_file_name))
1342 data = Fcons (Vload_file_name, Qnil); 1341 xsignal1 (Qend_of_file, Vload_file_name);
1343 else
1344 data = Qnil;
1345 1342
1346 Fsignal (Qend_of_file, data); 1343 xsignal0 (Qend_of_file);
1347} 1344}
1348 1345
1349/* UNIBYTE specifies how to set load_convert_to_unibyte 1346/* UNIBYTE specifies how to set load_convert_to_unibyte
@@ -1694,6 +1691,21 @@ read_internal_start (stream, start, end)
1694 return retval; 1691 return retval;
1695} 1692}
1696 1693
1694
1695/* Signal Qinvalid_read_syntax error.
1696 S is error string of length N (if > 0) */
1697
1698static void
1699invalid_syntax (s, n)
1700 const char *s;
1701 int n;
1702{
1703 if (!n)
1704 n = strlen (s);
1705 xsignal1 (Qinvalid_read_syntax, make_string (s, n));
1706}
1707
1708
1697/* Use this for recursive reads, in contexts where internal tokens 1709/* Use this for recursive reads, in contexts where internal tokens
1698 are not allowed. */ 1710 are not allowed. */
1699 1711
@@ -1705,12 +1717,11 @@ read0 (readcharfun)
1705 int c; 1717 int c;
1706 1718
1707 val = read1 (readcharfun, &c, 0); 1719 val = read1 (readcharfun, &c, 0);
1708 if (c) 1720 if (!c)
1709 Fsignal (Qinvalid_read_syntax, Fcons (Fmake_string (make_number (1), 1721 return val;
1710 make_number (c)),
1711 Qnil));
1712 1722
1713 return val; 1723 xsignal1 (Qinvalid_read_syntax,
1724 Fmake_string (make_number (1), make_number (c)));
1714} 1725}
1715 1726
1716static int read_buffer_size; 1727static int read_buffer_size;
@@ -1978,7 +1989,6 @@ read_escape (readcharfun, stringp, byterep)
1978 } 1989 }
1979} 1990}
1980 1991
1981
1982/* Read an integer in radix RADIX using READCHARFUN to read 1992/* Read an integer in radix RADIX using READCHARFUN to read
1983 characters. RADIX must be in the interval [2..36]; if it isn't, a 1993 characters. RADIX must be in the interval [2..36]; if it isn't, a
1984 read error is signaled . Value is the integer read. Signals an 1994 read error is signaled . Value is the integer read. Signals an
@@ -2038,7 +2048,7 @@ read_integer (readcharfun, radix)
2038 { 2048 {
2039 char buf[50]; 2049 char buf[50];
2040 sprintf (buf, "integer, radix %d", radix); 2050 sprintf (buf, "integer, radix %d", radix);
2041 Fsignal (Qinvalid_read_syntax, Fcons (build_string (buf), Qnil)); 2051 invalid_syntax (buf, 0);
2042 } 2052 }
2043 2053
2044 return make_number (sign * number); 2054 return make_number (sign * number);
@@ -2149,10 +2159,9 @@ read1 (readcharfun, pch, first_in_list)
2149 XCHAR_TABLE (tmp)->top = Qnil; 2159 XCHAR_TABLE (tmp)->top = Qnil;
2150 return tmp; 2160 return tmp;
2151 } 2161 }
2152 Fsignal (Qinvalid_read_syntax, 2162 invalid_syntax ("#^^", 3);
2153 Fcons (make_string ("#^^", 3), Qnil));
2154 } 2163 }
2155 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#^", 2), Qnil)); 2164 invalid_syntax ("#^", 2);
2156 } 2165 }
2157 if (c == '&') 2166 if (c == '&')
2158 { 2167 {
@@ -2174,8 +2183,7 @@ read1 (readcharfun, pch, first_in_list)
2174 Accept such input in case it came from an old version. */ 2183 Accept such input in case it came from an old version. */
2175 && ! (XFASTINT (length) 2184 && ! (XFASTINT (length)
2176 == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR)) 2185 == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR))
2177 Fsignal (Qinvalid_read_syntax, 2186 invalid_syntax ("#&...", 5);
2178 Fcons (make_string ("#&...", 5), Qnil));
2179 2187
2180 val = Fmake_bool_vector (length, Qnil); 2188 val = Fmake_bool_vector (length, Qnil);
2181 bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data, 2189 bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data,
@@ -2186,8 +2194,7 @@ read1 (readcharfun, pch, first_in_list)
2186 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; 2194 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
2187 return val; 2195 return val;
2188 } 2196 }
2189 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5), 2197 invalid_syntax ("#&...", 5);
2190 Qnil));
2191 } 2198 }
2192 if (c == '[') 2199 if (c == '[')
2193 { 2200 {
@@ -2207,7 +2214,7 @@ read1 (readcharfun, pch, first_in_list)
2207 /* Read the string itself. */ 2214 /* Read the string itself. */
2208 tmp = read1 (readcharfun, &ch, 0); 2215 tmp = read1 (readcharfun, &ch, 0);
2209 if (ch != 0 || !STRINGP (tmp)) 2216 if (ch != 0 || !STRINGP (tmp))
2210 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); 2217 invalid_syntax ("#", 1);
2211 GCPRO1 (tmp); 2218 GCPRO1 (tmp);
2212 /* Read the intervals and their properties. */ 2219 /* Read the intervals and their properties. */
2213 while (1) 2220 while (1)
@@ -2223,9 +2230,7 @@ read1 (readcharfun, pch, first_in_list)
2223 if (ch == 0) 2230 if (ch == 0)
2224 plist = read1 (readcharfun, &ch, 0); 2231 plist = read1 (readcharfun, &ch, 0);
2225 if (ch) 2232 if (ch)
2226 Fsignal (Qinvalid_read_syntax, 2233 invalid_syntax ("Invalid string property list", 0);
2227 Fcons (build_string ("invalid string property list"),
2228 Qnil));
2229 Fset_text_properties (beg, end, plist, tmp); 2234 Fset_text_properties (beg, end, plist, tmp);
2230 } 2235 }
2231 UNGCPRO; 2236 UNGCPRO;
@@ -2378,7 +2383,7 @@ read1 (readcharfun, pch, first_in_list)
2378 return read_integer (readcharfun, 2); 2383 return read_integer (readcharfun, 2);
2379 2384
2380 UNREAD (c); 2385 UNREAD (c);
2381 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); 2386 invalid_syntax ("#", 1);
2382 2387
2383 case ';': 2388 case ';':
2384 while ((c = READCHAR) >= 0 && c != '\n'); 2389 while ((c = READCHAR) >= 0 && c != '\n');
@@ -2472,10 +2477,10 @@ read1 (readcharfun, pch, first_in_list)
2472 || (new_backquote_flag && next_char == ',')))); 2477 || (new_backquote_flag && next_char == ','))));
2473 } 2478 }
2474 UNREAD (next_char); 2479 UNREAD (next_char);
2475 if (!ok) 2480 if (ok)
2476 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("?", 1), Qnil)); 2481 return make_number (c);
2477 2482
2478 return make_number (c); 2483 invalid_syntax ("?", 1);
2479 } 2484 }
2480 2485
2481 case '"': 2486 case '"':
@@ -3120,8 +3125,7 @@ read_list (flag, readcharfun)
3120 { 3125 {
3121 if (ch == ']') 3126 if (ch == ']')
3122 return val; 3127 return val;
3123 Fsignal (Qinvalid_read_syntax, 3128 invalid_syntax (") or . in a vector", 18);
3124 Fcons (make_string (") or . in a vector", 18), Qnil));
3125 } 3129 }
3126 if (ch == ')') 3130 if (ch == ')')
3127 return val; 3131 return val;
@@ -3214,9 +3218,9 @@ read_list (flag, readcharfun)
3214 3218
3215 return val; 3219 return val;
3216 } 3220 }
3217 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); 3221 invalid_syntax (". in wrong context", 18);
3218 } 3222 }
3219 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); 3223 invalid_syntax ("] in a list", 11);
3220 } 3224 }
3221 tem = (read_pure && flag <= 0 3225 tem = (read_pure && flag <= 0
3222 ? pure_cons (elt, Qnil) 3226 ? pure_cons (elt, Qnil)