Mercurial > hg > xemacs-beta
comparison src/eval.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children | 41dbb7a9d5f2 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
71 /* If subrs take more than 8 arguments, more cases need to be added | 71 /* If subrs take more than 8 arguments, more cases need to be added |
72 to this switch. (But wait - don't do it - if you really need | 72 to this switch. (But wait - don't do it - if you really need |
73 a SUBR with more than 8 arguments, use max_args == MANY. | 73 a SUBR with more than 8 arguments, use max_args == MANY. |
74 See the DEFUN macro in lisp.h) */ | 74 See the DEFUN macro in lisp.h) */ |
75 #define PRIMITIVE_FUNCALL(rv, fn, av, ac) do { \ | 75 #define PRIMITIVE_FUNCALL(rv, fn, av, ac) do { \ |
76 void (*PF_fn)(void) = (void (*)(void)) fn; \ | 76 void (*PF_fn)() = (void (*)()) (fn); \ |
77 Lisp_Object *PF_av = (av); \ | 77 Lisp_Object *PF_av = (av); \ |
78 switch (ac) \ | 78 switch (ac) \ |
79 { \ | 79 { \ |
80 default:rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 0); break; \ | 80 default: abort(); \ |
81 case 0: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 0); break; \ | |
81 case 1: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 1); break; \ | 82 case 1: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 1); break; \ |
82 case 2: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 2); break; \ | 83 case 2: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 2); break; \ |
83 case 3: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 3); break; \ | 84 case 3: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 3); break; \ |
84 case 4: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 4); break; \ | 85 case 4: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 4); break; \ |
85 case 5: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 5); break; \ | 86 case 5: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 5); break; \ |
141 Lisp_Object Vcurrent_warning_class; | 142 Lisp_Object Vcurrent_warning_class; |
142 | 143 |
143 /* Special catch tag used in call_with_suspended_errors(). */ | 144 /* Special catch tag used in call_with_suspended_errors(). */ |
144 Lisp_Object Qunbound_suspended_errors_tag; | 145 Lisp_Object Qunbound_suspended_errors_tag; |
145 | 146 |
147 /* Non-nil means we're going down, so we better not run any hooks | |
148 or do other non-essential stuff. */ | |
149 int preparing_for_armageddon; | |
150 | |
146 /* Non-nil means record all fset's and provide's, to be undone | 151 /* Non-nil means record all fset's and provide's, to be undone |
147 if the file being autoloaded is not fully loaded. | 152 if the file being autoloaded is not fully loaded. |
148 They are recorded by being consed onto the front of Vautoload_queue: | 153 They are recorded by being consed onto the front of Vautoload_queue: |
149 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */ | 154 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */ |
150 Lisp_Object Vautoload_queue; | 155 Lisp_Object Vautoload_queue; |
163 | 168 |
164 /* Maximum size allowed for specpdl allocation */ | 169 /* Maximum size allowed for specpdl allocation */ |
165 int max_specpdl_size; | 170 int max_specpdl_size; |
166 | 171 |
167 /* Depth in Lisp evaluations and function calls. */ | 172 /* Depth in Lisp evaluations and function calls. */ |
168 static int lisp_eval_depth; | 173 int lisp_eval_depth; |
169 | 174 |
170 /* Maximum allowed depth in Lisp evaluations and function calls. */ | 175 /* Maximum allowed depth in Lisp evaluations and function calls. */ |
171 int max_lisp_eval_depth; | 176 int max_lisp_eval_depth; |
172 | 177 |
173 /* Nonzero means enter debugger before next function call */ | 178 /* Nonzero means enter debugger before next function call */ |
261 in. | 266 in. |
262 */ | 267 */ |
263 static Lisp_Object Vcondition_handlers; | 268 static Lisp_Object Vcondition_handlers; |
264 | 269 |
265 | 270 |
266 #define DEFEND_AGAINST_THROW_RECURSION | 271 #if 0 /* no longer used */ |
267 | |
268 #ifdef DEFEND_AGAINST_THROW_RECURSION | |
269 /* Used for error catching purposes by throw_or_bomb_out */ | 272 /* Used for error catching purposes by throw_or_bomb_out */ |
270 static int throw_level; | 273 static int throw_level; |
271 #endif | 274 #endif /* unused */ |
272 | |
273 #ifdef ERROR_CHECK_TYPECHECK | |
274 void check_error_state_sanity (void); | |
275 #endif | |
276 | 275 |
277 | 276 |
278 /************************************************************************/ | 277 /************************************************************************/ |
279 /* The subr object type */ | 278 /* The subr object type */ |
280 /************************************************************************/ | 279 /************************************************************************/ |
281 | 280 |
282 static void | 281 static void |
283 print_subr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 282 print_subr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
284 { | 283 { |
285 Lisp_Subr *subr = XSUBR (obj); | 284 Lisp_Subr *subr = XSUBR (obj); |
286 const char *header = | 285 CONST char *header = |
287 (subr->max_args == UNEVALLED) ? "#<special-form " : "#<subr "; | 286 (subr->max_args == UNEVALLED) ? "#<special-form " : "#<subr "; |
288 const char *name = subr_name (subr); | 287 CONST char *name = subr_name (subr); |
289 const char *trailer = subr->prompt ? " (interactive)>" : ">"; | 288 CONST char *trailer = subr->prompt ? " (interactive)>" : ">"; |
290 | 289 |
291 if (print_readably) | 290 if (print_readably) |
292 error ("printing unreadable object %s%s%s", header, name, trailer); | 291 error ("printing unreadable object %s%s%s", header, name, trailer); |
293 | 292 |
294 write_c_string (header, printcharfun); | 293 write_c_string (header, printcharfun); |
295 write_c_string (name, printcharfun); | 294 write_c_string (name, printcharfun); |
296 write_c_string (trailer, printcharfun); | 295 write_c_string (trailer, printcharfun); |
297 } | 296 } |
298 | 297 |
299 static const struct lrecord_description subr_description[] = { | 298 DEFINE_LRECORD_IMPLEMENTATION ("subr", subr, |
300 { XD_DOC_STRING, offsetof (Lisp_Subr, doc) }, | 299 this_one_is_unmarkable, print_subr, 0, 0, 0, |
301 { XD_END } | 300 Lisp_Subr); |
302 }; | |
303 | |
304 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("subr", subr, | |
305 0, print_subr, 0, 0, 0, | |
306 subr_description, | |
307 Lisp_Subr); | |
308 | 301 |
309 /************************************************************************/ | 302 /************************************************************************/ |
310 /* Entering the debugger */ | 303 /* Entering the debugger */ |
311 /************************************************************************/ | 304 /************************************************************************/ |
312 | 305 |
1009 /* Defining functions/variables */ | 1002 /* Defining functions/variables */ |
1010 /************************************************************************/ | 1003 /************************************************************************/ |
1011 static Lisp_Object | 1004 static Lisp_Object |
1012 define_function (Lisp_Object name, Lisp_Object defn) | 1005 define_function (Lisp_Object name, Lisp_Object defn) |
1013 { | 1006 { |
1007 if (purify_flag) | |
1008 defn = Fpurecopy (defn); | |
1014 Ffset (name, defn); | 1009 Ffset (name, defn); |
1015 LOADHIST_ATTACH (name); | 1010 LOADHIST_ATTACH (name); |
1016 return name; | 1011 return name; |
1017 } | 1012 } |
1018 | 1013 |
1055 void.) | 1050 void.) |
1056 If SYMBOL is buffer-local, its default value is what is set; | 1051 If SYMBOL is buffer-local, its default value is what is set; |
1057 buffer-local values are not affected. | 1052 buffer-local values are not affected. |
1058 INITVALUE and DOCSTRING are optional. | 1053 INITVALUE and DOCSTRING are optional. |
1059 If DOCSTRING starts with *, this variable is identified as a user option. | 1054 If DOCSTRING starts with *, this variable is identified as a user option. |
1060 This means that M-x set-variable recognizes it. | 1055 This means that M-x set-variable and M-x edit-options recognize it. |
1061 If INITVALUE is missing, SYMBOL's value is not set. | 1056 If INITVALUE is missing, SYMBOL's value is not set. |
1062 | 1057 |
1063 In lisp-interaction-mode defvar is treated as defconst. | 1058 In lisp-interaction-mode defvar is treated as defconst. |
1064 */ | 1059 */ |
1065 (args)) | 1060 (args)) |
1081 } | 1076 } |
1082 | 1077 |
1083 if (!NILP (args = XCDR (args))) | 1078 if (!NILP (args = XCDR (args))) |
1084 { | 1079 { |
1085 Lisp_Object doc = XCAR (args); | 1080 Lisp_Object doc = XCAR (args); |
1081 #if 0 /* FSFmacs */ | |
1082 /* #### We should probably do this but it might be dangerous */ | |
1083 if (purify_flag) | |
1084 doc = Fpurecopy (doc); | |
1086 Fput (sym, Qvariable_documentation, doc); | 1085 Fput (sym, Qvariable_documentation, doc); |
1086 #else | |
1087 pure_put (sym, Qvariable_documentation, doc); | |
1088 #endif | |
1087 if (!NILP (args = XCDR (args))) | 1089 if (!NILP (args = XCDR (args))) |
1088 error ("too many arguments"); | 1090 error ("too many arguments"); |
1089 } | 1091 } |
1090 } | 1092 } |
1091 | 1093 |
1092 #ifdef I18N3 | 1094 #ifdef I18N3 |
1093 if (!NILP (Vfile_domain)) | 1095 if (!NILP (Vfile_domain)) |
1094 Fput (sym, Qvariable_domain, Vfile_domain); | 1096 pure_put (sym, Qvariable_domain, Vfile_domain); |
1095 #endif | 1097 #endif |
1096 | 1098 |
1097 LOADHIST_ATTACH (sym); | 1099 LOADHIST_ATTACH (sym); |
1098 return sym; | 1100 return sym; |
1099 } | 1101 } |
1105 Always sets the value of SYMBOL to the result of evalling INITVALUE. | 1107 Always sets the value of SYMBOL to the result of evalling INITVALUE. |
1106 If SYMBOL is buffer-local, its default value is what is set; | 1108 If SYMBOL is buffer-local, its default value is what is set; |
1107 buffer-local values are not affected. | 1109 buffer-local values are not affected. |
1108 DOCSTRING is optional. | 1110 DOCSTRING is optional. |
1109 If DOCSTRING starts with *, this variable is identified as a user option. | 1111 If DOCSTRING starts with *, this variable is identified as a user option. |
1110 This means that M-x set-variable recognizes it. | 1112 This means that M-x set-variable and M-x edit-options recognize it. |
1111 | 1113 |
1112 Note: do not use `defconst' for user options in libraries that are not | 1114 Note: do not use `defconst' for user options in libraries that are not |
1113 normally loaded, since it is useful for users to be able to specify | 1115 normally loaded, since it is useful for users to be able to specify |
1114 their own values for such variables before loading the library. | 1116 their own values for such variables before loading the library. |
1115 Since `defconst' unconditionally assigns the variable, | 1117 Since `defconst' unconditionally assigns the variable, |
1129 UNGCPRO; | 1131 UNGCPRO; |
1130 | 1132 |
1131 if (!NILP (args = XCDR (args))) | 1133 if (!NILP (args = XCDR (args))) |
1132 { | 1134 { |
1133 Lisp_Object doc = XCAR (args); | 1135 Lisp_Object doc = XCAR (args); |
1136 #if 0 /* FSFmacs */ | |
1137 /* #### We should probably do this but it might be dangerous */ | |
1138 if (purify_flag) | |
1139 doc = Fpurecopy (doc); | |
1134 Fput (sym, Qvariable_documentation, doc); | 1140 Fput (sym, Qvariable_documentation, doc); |
1141 #else | |
1142 pure_put (sym, Qvariable_documentation, doc); | |
1143 #endif | |
1135 if (!NILP (args = XCDR (args))) | 1144 if (!NILP (args = XCDR (args))) |
1136 error ("too many arguments"); | 1145 error ("too many arguments"); |
1137 } | 1146 } |
1138 | 1147 |
1139 #ifdef I18N3 | 1148 #ifdef I18N3 |
1140 if (!NILP (Vfile_domain)) | 1149 if (!NILP (Vfile_domain)) |
1141 Fput (sym, Qvariable_domain, Vfile_domain); | 1150 pure_put (sym, Qvariable_domain, Vfile_domain); |
1142 #endif | 1151 #endif |
1143 | 1152 |
1144 LOADHIST_ATTACH (sym); | 1153 LOADHIST_ATTACH (sym); |
1145 return sym; | 1154 return sym; |
1146 } | 1155 } |
1156 Lisp_Object documentation = Fget (variable, Qvariable_documentation, Qnil); | 1165 Lisp_Object documentation = Fget (variable, Qvariable_documentation, Qnil); |
1157 | 1166 |
1158 return | 1167 return |
1159 ((INTP (documentation) && XINT (documentation) < 0) || | 1168 ((INTP (documentation) && XINT (documentation) < 0) || |
1160 | 1169 |
1161 (STRINGP (documentation) && | 1170 ((STRINGP (documentation)) && |
1162 (string_byte (XSTRING (documentation), 0) == '*')) || | 1171 (string_byte (XSTRING (documentation), 0) == '*')) || |
1163 | 1172 |
1164 /* If (STRING . INTEGER), a negative integer means a user variable. */ | 1173 /* If (STRING . INTEGER), a negative integer means a user variable. */ |
1165 (CONSP (documentation) | 1174 (CONSP (documentation) |
1166 && STRINGP (XCAR (documentation)) | 1175 && STRINGP (XCAR (documentation)) |
1304 return c.val; | 1313 return c.val; |
1305 } | 1314 } |
1306 c.val = (*func) (arg); | 1315 c.val = (*func) (arg); |
1307 if (threw) *threw = 0; | 1316 if (threw) *threw = 0; |
1308 catchlist = c.next; | 1317 catchlist = c.next; |
1309 #ifdef ERROR_CHECK_TYPECHECK | |
1310 check_error_state_sanity (); | |
1311 #endif | |
1312 return c.val; | 1318 return c.val; |
1313 } | 1319 } |
1314 | 1320 |
1315 | 1321 |
1316 /* Unwind the specbind, catch, and handler stacks back to CATCH, and | 1322 /* Unwind the specbind, catch, and handler stacks back to CATCH, and |
1363 /* Unwind the specpdl stack, and then restore the proper set of | 1369 /* Unwind the specpdl stack, and then restore the proper set of |
1364 handlers. */ | 1370 handlers. */ |
1365 unbind_to (catchlist->pdlcount, Qnil); | 1371 unbind_to (catchlist->pdlcount, Qnil); |
1366 handlerlist = catchlist->handlerlist; | 1372 handlerlist = catchlist->handlerlist; |
1367 catchlist = catchlist->next; | 1373 catchlist = catchlist->next; |
1368 #ifdef ERROR_CHECK_TYPECHECK | |
1369 check_error_state_sanity (); | |
1370 #endif | |
1371 } | 1374 } |
1372 while (! last_time); | 1375 while (! last_time); |
1373 #else /* Actual XEmacs code */ | 1376 #else /* Actual XEmacs code */ |
1374 /* Unwind the specpdl stack */ | 1377 /* Unwind the specpdl stack */ |
1375 unbind_to (c->pdlcount, Qnil); | 1378 unbind_to (c->pdlcount, Qnil); |
1376 catchlist = c->next; | 1379 catchlist = c->next; |
1377 #ifdef ERROR_CHECK_TYPECHECK | |
1378 check_error_state_sanity (); | |
1379 #endif | |
1380 #endif | 1380 #endif |
1381 | 1381 |
1382 gcprolist = c->gcpro; | 1382 gcprolist = c->gcpro; |
1383 backtrace_list = c->backlist; | 1383 backtrace_list = c->backlist; |
1384 lisp_eval_depth = c->lisp_eval_depth; | 1384 lisp_eval_depth = c->lisp_eval_depth; |
1385 | 1385 |
1386 #ifdef DEFEND_AGAINST_THROW_RECURSION | 1386 #if 0 /* no longer used */ |
1387 throw_level = 0; | 1387 throw_level = 0; |
1388 #endif | 1388 #endif |
1389 LONGJMP (c->jmp, 1); | 1389 LONGJMP (c->jmp, 1); |
1390 } | 1390 } |
1391 | 1391 |
1392 static DOESNT_RETURN | 1392 static DOESNT_RETURN |
1393 throw_or_bomb_out (Lisp_Object tag, Lisp_Object val, int bomb_out_p, | 1393 throw_or_bomb_out (Lisp_Object tag, Lisp_Object val, int bomb_out_p, |
1394 Lisp_Object sig, Lisp_Object data) | 1394 Lisp_Object sig, Lisp_Object data) |
1395 { | 1395 { |
1396 #ifdef DEFEND_AGAINST_THROW_RECURSION | 1396 #if 0 |
1397 /* die if we recurse more than is reasonable */ | 1397 /* die if we recurse more than is reasonable */ |
1398 if (++throw_level > 20) | 1398 if (++throw_level > 20) |
1399 abort(); | 1399 abort(); |
1400 #endif | 1400 #endif |
1401 | 1401 |
1491 /************************************************************************/ | 1491 /************************************************************************/ |
1492 | 1492 |
1493 static Lisp_Object | 1493 static Lisp_Object |
1494 condition_bind_unwind (Lisp_Object loser) | 1494 condition_bind_unwind (Lisp_Object loser) |
1495 { | 1495 { |
1496 Lisp_Cons *victim; | 1496 struct Lisp_Cons *victim; |
1497 /* ((handler-fun . handler-args) ... other handlers) */ | 1497 /* ((handler-fun . handler-args) ... other handlers) */ |
1498 Lisp_Object tem = XCAR (loser); | 1498 Lisp_Object tem = XCAR (loser); |
1499 | 1499 |
1500 while (CONSP (tem)) | 1500 while (CONSP (tem)) |
1501 { | 1501 { |
1513 } | 1513 } |
1514 | 1514 |
1515 static Lisp_Object | 1515 static Lisp_Object |
1516 condition_case_unwind (Lisp_Object loser) | 1516 condition_case_unwind (Lisp_Object loser) |
1517 { | 1517 { |
1518 Lisp_Cons *victim; | 1518 struct Lisp_Cons *victim; |
1519 | 1519 |
1520 /* ((<unbound> . clauses) ... other handlers */ | 1520 /* ((<unbound> . clauses) ... other handlers */ |
1521 victim = XCONS (XCAR (loser)); | 1521 victim = XCONS (XCAR (loser)); |
1522 free_cons (victim); | 1522 free_cons (victim); |
1523 | 1523 |
1644 ungcpro, restoring catchlist and condition_handlers are actually | 1644 ungcpro, restoring catchlist and condition_handlers are actually |
1645 redundant since unbind_to now restores them. But it looks funny not to | 1645 redundant since unbind_to now restores them. But it looks funny not to |
1646 have this code here, and it doesn't cost anything, so I'm leaving it.*/ | 1646 have this code here, and it doesn't cost anything, so I'm leaving it.*/ |
1647 UNGCPRO; | 1647 UNGCPRO; |
1648 catchlist = c.next; | 1648 catchlist = c.next; |
1649 #ifdef ERROR_CHECK_TYPECHECK | |
1650 check_error_state_sanity (); | |
1651 #endif | |
1652 Vcondition_handlers = XCDR (c.tag); | 1649 Vcondition_handlers = XCDR (c.tag); |
1653 | 1650 |
1654 return unbind_to (speccount, c.val); | 1651 return unbind_to (speccount, c.val); |
1655 } | 1652 } |
1656 | 1653 |
1863 | 1860 |
1864 if (!initialized) | 1861 if (!initialized) |
1865 { | 1862 { |
1866 /* who knows how much has been initialized? Safest bet is | 1863 /* who knows how much has been initialized? Safest bet is |
1867 just to bomb out immediately. */ | 1864 just to bomb out immediately. */ |
1868 /* let's not use stderr_out() here, because that does a bunch of | |
1869 things that might not be safe yet. */ | |
1870 fprintf (stderr, "Error before initialization is complete!\n"); | 1865 fprintf (stderr, "Error before initialization is complete!\n"); |
1871 abort (); | 1866 abort (); |
1872 } | 1867 } |
1873 | 1868 |
1874 if (gc_in_progress || in_display) | 1869 if (gc_in_progress || in_display) |
2050 signal_error (Lisp_Object sig, Lisp_Object data) | 2045 signal_error (Lisp_Object sig, Lisp_Object data) |
2051 { | 2046 { |
2052 for (;;) | 2047 for (;;) |
2053 Fsignal (sig, data); | 2048 Fsignal (sig, data); |
2054 } | 2049 } |
2055 #ifdef ERROR_CHECK_TYPECHECK | 2050 |
2056 void | 2051 static Lisp_Object |
2057 check_error_state_sanity (void) | 2052 call_with_suspended_errors_1 (Lisp_Object opaque_arg) |
2058 { | 2053 { |
2059 struct catchtag *c; | 2054 Lisp_Object val; |
2060 int found_error_tag = 0; | 2055 Lisp_Object *kludgy_args = (Lisp_Object *) get_opaque_ptr (opaque_arg); |
2061 | 2056 PRIMITIVE_FUNCALL (val, get_opaque_ptr (kludgy_args[0]), |
2062 for (c = catchlist; c; c = c->next) | 2057 kludgy_args + 2, XINT (kludgy_args[1])); |
2063 { | 2058 return val; |
2064 if (EQ (c->tag, Qunbound_suspended_errors_tag)) | 2059 } |
2065 { | |
2066 found_error_tag = 1; | |
2067 break; | |
2068 } | |
2069 } | |
2070 | |
2071 assert (found_error_tag || NILP (Vcurrent_error_state)); | |
2072 } | |
2073 #endif | |
2074 | 2060 |
2075 static Lisp_Object | 2061 static Lisp_Object |
2076 restore_current_warning_class (Lisp_Object warning_class) | 2062 restore_current_warning_class (Lisp_Object warning_class) |
2077 { | 2063 { |
2078 Vcurrent_warning_class = warning_class; | 2064 Vcurrent_warning_class = warning_class; |
2082 static Lisp_Object | 2068 static Lisp_Object |
2083 restore_current_error_state (Lisp_Object error_state) | 2069 restore_current_error_state (Lisp_Object error_state) |
2084 { | 2070 { |
2085 Vcurrent_error_state = error_state; | 2071 Vcurrent_error_state = error_state; |
2086 return Qnil; | 2072 return Qnil; |
2087 } | |
2088 | |
2089 static Lisp_Object | |
2090 call_with_suspended_errors_1 (Lisp_Object opaque_arg) | |
2091 { | |
2092 Lisp_Object val; | |
2093 Lisp_Object *kludgy_args = (Lisp_Object *) get_opaque_ptr (opaque_arg); | |
2094 Lisp_Object no_error = kludgy_args[2]; | |
2095 int speccount = specpdl_depth (); | |
2096 | |
2097 if (!EQ (Vcurrent_error_state, no_error)) | |
2098 { | |
2099 record_unwind_protect (restore_current_error_state, | |
2100 Vcurrent_error_state); | |
2101 Vcurrent_error_state = no_error; | |
2102 } | |
2103 PRIMITIVE_FUNCALL (val, get_opaque_ptr (kludgy_args[0]), | |
2104 kludgy_args + 3, XINT (kludgy_args[1])); | |
2105 return unbind_to (speccount, val); | |
2106 } | 2073 } |
2107 | 2074 |
2108 /* Many functions would like to do one of three things if an error | 2075 /* Many functions would like to do one of three things if an error |
2109 occurs: | 2076 occurs: |
2110 | 2077 |
2125 Lisp_Object class, Error_behavior errb, | 2092 Lisp_Object class, Error_behavior errb, |
2126 int nargs, ...) | 2093 int nargs, ...) |
2127 { | 2094 { |
2128 va_list vargs; | 2095 va_list vargs; |
2129 int speccount; | 2096 int speccount; |
2130 Lisp_Object kludgy_args[23]; | 2097 Lisp_Object kludgy_args[22]; |
2131 Lisp_Object *args = kludgy_args + 3; | 2098 Lisp_Object *args = kludgy_args + 2; |
2132 int i; | 2099 int i; |
2133 Lisp_Object no_error; | 2100 Lisp_Object no_error; |
2134 | 2101 |
2135 assert (SYMBOLP (class)); /* sanity-check */ | 2102 assert (SYMBOLP (class)); /* sanity-check */ |
2136 assert (!NILP (class)); | 2103 assert (!NILP (class)); |
2168 Lisp_Object val; | 2135 Lisp_Object val; |
2169 PRIMITIVE_FUNCALL (val, fun, args, nargs); | 2136 PRIMITIVE_FUNCALL (val, fun, args, nargs); |
2170 return val; | 2137 return val; |
2171 } | 2138 } |
2172 | 2139 |
2173 speccount = specpdl_depth (); | 2140 speccount = specpdl_depth(); |
2174 if (NILP (class) || NILP (Vcurrent_warning_class)) | 2141 if (NILP (class) || NILP (Vcurrent_warning_class)) |
2175 { | 2142 { |
2176 /* If we're currently calling for no warnings, then make it so. | 2143 /* If we're currently calling for no warnings, then make it so. |
2177 If we're currently calling for warnings and we weren't | 2144 If we're currently calling for warnings and we weren't |
2178 previously, then set our warning class; otherwise, leave | 2145 previously, then set our warning class; otherwise, leave |
2179 the existing one alone. */ | 2146 the existing one alone. */ |
2180 record_unwind_protect (restore_current_warning_class, | 2147 record_unwind_protect (restore_current_warning_class, |
2181 Vcurrent_warning_class); | 2148 Vcurrent_warning_class); |
2182 Vcurrent_warning_class = class; | 2149 Vcurrent_warning_class = class; |
2183 } | 2150 } |
2151 if (!EQ (Vcurrent_error_state, no_error)) | |
2152 { | |
2153 record_unwind_protect (restore_current_error_state, | |
2154 Vcurrent_error_state); | |
2155 Vcurrent_error_state = no_error; | |
2156 } | |
2184 | 2157 |
2185 { | 2158 { |
2186 int threw; | 2159 int threw; |
2187 Lisp_Object the_retval; | 2160 Lisp_Object the_retval; |
2188 Lisp_Object opaque1 = make_opaque_ptr (kludgy_args); | 2161 Lisp_Object opaque1 = make_opaque_ptr (kludgy_args); |
2190 struct gcpro gcpro1, gcpro2; | 2163 struct gcpro gcpro1, gcpro2; |
2191 | 2164 |
2192 GCPRO2 (opaque1, opaque2); | 2165 GCPRO2 (opaque1, opaque2); |
2193 kludgy_args[0] = opaque2; | 2166 kludgy_args[0] = opaque2; |
2194 kludgy_args[1] = make_int (nargs); | 2167 kludgy_args[1] = make_int (nargs); |
2195 kludgy_args[2] = no_error; | |
2196 the_retval = internal_catch (Qunbound_suspended_errors_tag, | 2168 the_retval = internal_catch (Qunbound_suspended_errors_tag, |
2197 call_with_suspended_errors_1, | 2169 call_with_suspended_errors_1, |
2198 opaque1, &threw); | 2170 opaque1, &threw); |
2199 free_opaque_ptr (opaque1); | 2171 free_opaque_ptr (opaque1); |
2200 free_opaque_ptr (opaque2); | 2172 free_opaque_ptr (opaque2); |
2251 is a single string, created using the arguments. */ | 2223 is a single string, created using the arguments. */ |
2252 | 2224 |
2253 /* dump an error message; called like printf */ | 2225 /* dump an error message; called like printf */ |
2254 | 2226 |
2255 DOESNT_RETURN | 2227 DOESNT_RETURN |
2256 error (const char *fmt, ...) | 2228 error (CONST char *fmt, ...) |
2257 { | 2229 { |
2258 Lisp_Object obj; | 2230 Lisp_Object obj; |
2259 va_list args; | 2231 va_list args; |
2260 | 2232 |
2261 va_start (args, fmt); | 2233 va_start (args, fmt); |
2262 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2234 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2263 args); | 2235 args); |
2264 va_end (args); | 2236 va_end (args); |
2265 | 2237 |
2266 /* Fsignal GC-protects its args */ | 2238 /* Fsignal GC-protects its args */ |
2267 signal_error (Qerror, list1 (obj)); | 2239 signal_error (Qerror, list1 (obj)); |
2268 } | 2240 } |
2269 | 2241 |
2270 void | 2242 void |
2271 maybe_error (Lisp_Object class, Error_behavior errb, const char *fmt, ...) | 2243 maybe_error (Lisp_Object class, Error_behavior errb, CONST char *fmt, ...) |
2272 { | 2244 { |
2273 Lisp_Object obj; | 2245 Lisp_Object obj; |
2274 va_list args; | 2246 va_list args; |
2275 | 2247 |
2276 /* Optimization: */ | 2248 /* Optimization: */ |
2277 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2249 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2278 return; | 2250 return; |
2279 | 2251 |
2280 va_start (args, fmt); | 2252 va_start (args, fmt); |
2281 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2253 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2282 args); | 2254 args); |
2283 va_end (args); | 2255 va_end (args); |
2284 | 2256 |
2285 /* Fsignal GC-protects its args */ | 2257 /* Fsignal GC-protects its args */ |
2286 maybe_signal_error (Qerror, list1 (obj), class, errb); | 2258 maybe_signal_error (Qerror, list1 (obj), class, errb); |
2287 } | 2259 } |
2288 | 2260 |
2289 Lisp_Object | 2261 Lisp_Object |
2290 continuable_error (const char *fmt, ...) | 2262 continuable_error (CONST char *fmt, ...) |
2291 { | 2263 { |
2292 Lisp_Object obj; | 2264 Lisp_Object obj; |
2293 va_list args; | 2265 va_list args; |
2294 | 2266 |
2295 va_start (args, fmt); | 2267 va_start (args, fmt); |
2296 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2268 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2297 args); | 2269 args); |
2298 va_end (args); | 2270 va_end (args); |
2299 | 2271 |
2300 /* Fsignal GC-protects its args */ | 2272 /* Fsignal GC-protects its args */ |
2301 return Fsignal (Qerror, list1 (obj)); | 2273 return Fsignal (Qerror, list1 (obj)); |
2302 } | 2274 } |
2303 | 2275 |
2304 Lisp_Object | 2276 Lisp_Object |
2305 maybe_continuable_error (Lisp_Object class, Error_behavior errb, | 2277 maybe_continuable_error (Lisp_Object class, Error_behavior errb, |
2306 const char *fmt, ...) | 2278 CONST char *fmt, ...) |
2307 { | 2279 { |
2308 Lisp_Object obj; | 2280 Lisp_Object obj; |
2309 va_list args; | 2281 va_list args; |
2310 | 2282 |
2311 /* Optimization: */ | 2283 /* Optimization: */ |
2312 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2284 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2313 return Qnil; | 2285 return Qnil; |
2314 | 2286 |
2315 va_start (args, fmt); | 2287 va_start (args, fmt); |
2316 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2288 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2317 args); | 2289 args); |
2318 va_end (args); | 2290 va_end (args); |
2319 | 2291 |
2320 /* Fsignal GC-protects its args */ | 2292 /* Fsignal GC-protects its args */ |
2321 return maybe_signal_continuable_error (Qerror, list1 (obj), class, errb); | 2293 return maybe_signal_continuable_error (Qerror, list1 (obj), class, errb); |
2328 These functions signal an error of type Qerror, whose data | 2300 These functions signal an error of type Qerror, whose data |
2329 is two objects, a string and a related Lisp object (usually the object | 2301 is two objects, a string and a related Lisp object (usually the object |
2330 where the error is occurring). */ | 2302 where the error is occurring). */ |
2331 | 2303 |
2332 DOESNT_RETURN | 2304 DOESNT_RETURN |
2333 signal_simple_error (const char *reason, Lisp_Object frob) | 2305 signal_simple_error (CONST char *reason, Lisp_Object frob) |
2334 { | 2306 { |
2335 signal_error (Qerror, list2 (build_translated_string (reason), frob)); | 2307 signal_error (Qerror, list2 (build_translated_string (reason), frob)); |
2336 } | 2308 } |
2337 | 2309 |
2338 void | 2310 void |
2339 maybe_signal_simple_error (const char *reason, Lisp_Object frob, | 2311 maybe_signal_simple_error (CONST char *reason, Lisp_Object frob, |
2340 Lisp_Object class, Error_behavior errb) | 2312 Lisp_Object class, Error_behavior errb) |
2341 { | 2313 { |
2342 /* Optimization: */ | 2314 /* Optimization: */ |
2343 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2315 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2344 return; | 2316 return; |
2345 maybe_signal_error (Qerror, list2 (build_translated_string (reason), frob), | 2317 maybe_signal_error (Qerror, list2 (build_translated_string (reason), frob), |
2346 class, errb); | 2318 class, errb); |
2347 } | 2319 } |
2348 | 2320 |
2349 Lisp_Object | 2321 Lisp_Object |
2350 signal_simple_continuable_error (const char *reason, Lisp_Object frob) | 2322 signal_simple_continuable_error (CONST char *reason, Lisp_Object frob) |
2351 { | 2323 { |
2352 return Fsignal (Qerror, list2 (build_translated_string (reason), frob)); | 2324 return Fsignal (Qerror, list2 (build_translated_string (reason), frob)); |
2353 } | 2325 } |
2354 | 2326 |
2355 Lisp_Object | 2327 Lisp_Object |
2356 maybe_signal_simple_continuable_error (const char *reason, Lisp_Object frob, | 2328 maybe_signal_simple_continuable_error (CONST char *reason, Lisp_Object frob, |
2357 Lisp_Object class, Error_behavior errb) | 2329 Lisp_Object class, Error_behavior errb) |
2358 { | 2330 { |
2359 /* Optimization: */ | 2331 /* Optimization: */ |
2360 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2332 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2361 return Qnil; | 2333 return Qnil; |
2372 is a two objects, a string (created using the arguments) and a | 2344 is a two objects, a string (created using the arguments) and a |
2373 Lisp object. | 2345 Lisp object. |
2374 */ | 2346 */ |
2375 | 2347 |
2376 DOESNT_RETURN | 2348 DOESNT_RETURN |
2377 error_with_frob (Lisp_Object frob, const char *fmt, ...) | 2349 error_with_frob (Lisp_Object frob, CONST char *fmt, ...) |
2378 { | 2350 { |
2379 Lisp_Object obj; | 2351 Lisp_Object obj; |
2380 va_list args; | 2352 va_list args; |
2381 | 2353 |
2382 va_start (args, fmt); | 2354 va_start (args, fmt); |
2383 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2355 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2384 args); | 2356 args); |
2385 va_end (args); | 2357 va_end (args); |
2386 | 2358 |
2387 /* Fsignal GC-protects its args */ | 2359 /* Fsignal GC-protects its args */ |
2388 signal_error (Qerror, list2 (obj, frob)); | 2360 signal_error (Qerror, list2 (obj, frob)); |
2389 } | 2361 } |
2390 | 2362 |
2391 void | 2363 void |
2392 maybe_error_with_frob (Lisp_Object frob, Lisp_Object class, | 2364 maybe_error_with_frob (Lisp_Object frob, Lisp_Object class, |
2393 Error_behavior errb, const char *fmt, ...) | 2365 Error_behavior errb, CONST char *fmt, ...) |
2394 { | 2366 { |
2395 Lisp_Object obj; | 2367 Lisp_Object obj; |
2396 va_list args; | 2368 va_list args; |
2397 | 2369 |
2398 /* Optimization: */ | 2370 /* Optimization: */ |
2399 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2371 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2400 return; | 2372 return; |
2401 | 2373 |
2402 va_start (args, fmt); | 2374 va_start (args, fmt); |
2403 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2375 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2404 args); | 2376 args); |
2405 va_end (args); | 2377 va_end (args); |
2406 | 2378 |
2407 /* Fsignal GC-protects its args */ | 2379 /* Fsignal GC-protects its args */ |
2408 maybe_signal_error (Qerror, list2 (obj, frob), class, errb); | 2380 maybe_signal_error (Qerror, list2 (obj, frob), class, errb); |
2409 } | 2381 } |
2410 | 2382 |
2411 Lisp_Object | 2383 Lisp_Object |
2412 continuable_error_with_frob (Lisp_Object frob, const char *fmt, ...) | 2384 continuable_error_with_frob (Lisp_Object frob, CONST char *fmt, ...) |
2413 { | 2385 { |
2414 Lisp_Object obj; | 2386 Lisp_Object obj; |
2415 va_list args; | 2387 va_list args; |
2416 | 2388 |
2417 va_start (args, fmt); | 2389 va_start (args, fmt); |
2418 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2390 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2419 args); | 2391 args); |
2420 va_end (args); | 2392 va_end (args); |
2421 | 2393 |
2422 /* Fsignal GC-protects its args */ | 2394 /* Fsignal GC-protects its args */ |
2423 return Fsignal (Qerror, list2 (obj, frob)); | 2395 return Fsignal (Qerror, list2 (obj, frob)); |
2424 } | 2396 } |
2425 | 2397 |
2426 Lisp_Object | 2398 Lisp_Object |
2427 maybe_continuable_error_with_frob (Lisp_Object frob, Lisp_Object class, | 2399 maybe_continuable_error_with_frob (Lisp_Object frob, Lisp_Object class, |
2428 Error_behavior errb, const char *fmt, ...) | 2400 Error_behavior errb, CONST char *fmt, ...) |
2429 { | 2401 { |
2430 Lisp_Object obj; | 2402 Lisp_Object obj; |
2431 va_list args; | 2403 va_list args; |
2432 | 2404 |
2433 /* Optimization: */ | 2405 /* Optimization: */ |
2434 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2406 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2435 return Qnil; | 2407 return Qnil; |
2436 | 2408 |
2437 va_start (args, fmt); | 2409 va_start (args, fmt); |
2438 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1, | 2410 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, |
2439 args); | 2411 args); |
2440 va_end (args); | 2412 va_end (args); |
2441 | 2413 |
2442 /* Fsignal GC-protects its args */ | 2414 /* Fsignal GC-protects its args */ |
2443 return maybe_signal_continuable_error (Qerror, list2 (obj, frob), | 2415 return maybe_signal_continuable_error (Qerror, list2 (obj, frob), |
2450 /* Class 5: Signal an error with a string and two associated objects. | 2422 /* Class 5: Signal an error with a string and two associated objects. |
2451 These functions signal an error of type Qerror, whose data | 2423 These functions signal an error of type Qerror, whose data |
2452 is three objects, a string and two related Lisp objects. */ | 2424 is three objects, a string and two related Lisp objects. */ |
2453 | 2425 |
2454 DOESNT_RETURN | 2426 DOESNT_RETURN |
2455 signal_simple_error_2 (const char *reason, | 2427 signal_simple_error_2 (CONST char *reason, |
2456 Lisp_Object frob0, Lisp_Object frob1) | 2428 Lisp_Object frob0, Lisp_Object frob1) |
2457 { | 2429 { |
2458 signal_error (Qerror, list3 (build_translated_string (reason), frob0, | 2430 signal_error (Qerror, list3 (build_translated_string (reason), frob0, |
2459 frob1)); | 2431 frob1)); |
2460 } | 2432 } |
2461 | 2433 |
2462 void | 2434 void |
2463 maybe_signal_simple_error_2 (const char *reason, Lisp_Object frob0, | 2435 maybe_signal_simple_error_2 (CONST char *reason, Lisp_Object frob0, |
2464 Lisp_Object frob1, Lisp_Object class, | 2436 Lisp_Object frob1, Lisp_Object class, |
2465 Error_behavior errb) | 2437 Error_behavior errb) |
2466 { | 2438 { |
2467 /* Optimization: */ | 2439 /* Optimization: */ |
2468 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2440 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2471 frob1), class, errb); | 2443 frob1), class, errb); |
2472 } | 2444 } |
2473 | 2445 |
2474 | 2446 |
2475 Lisp_Object | 2447 Lisp_Object |
2476 signal_simple_continuable_error_2 (const char *reason, Lisp_Object frob0, | 2448 signal_simple_continuable_error_2 (CONST char *reason, Lisp_Object frob0, |
2477 Lisp_Object frob1) | 2449 Lisp_Object frob1) |
2478 { | 2450 { |
2479 return Fsignal (Qerror, list3 (build_translated_string (reason), frob0, | 2451 return Fsignal (Qerror, list3 (build_translated_string (reason), frob0, |
2480 frob1)); | 2452 frob1)); |
2481 } | 2453 } |
2482 | 2454 |
2483 Lisp_Object | 2455 Lisp_Object |
2484 maybe_signal_simple_continuable_error_2 (const char *reason, Lisp_Object frob0, | 2456 maybe_signal_simple_continuable_error_2 (CONST char *reason, Lisp_Object frob0, |
2485 Lisp_Object frob1, Lisp_Object class, | 2457 Lisp_Object frob1, Lisp_Object class, |
2486 Error_behavior errb) | 2458 Error_behavior errb) |
2487 { | 2459 { |
2488 /* Optimization: */ | 2460 /* Optimization: */ |
2489 if (ERRB_EQ (errb, ERROR_ME_NOT)) | 2461 if (ERRB_EQ (errb, ERROR_ME_NOT)) |
2507 Fsignal (Qquit, Qnil); | 2479 Fsignal (Qquit, Qnil); |
2508 } | 2480 } |
2509 | 2481 |
2510 | 2482 |
2511 /* Used in core lisp functions for efficiency */ | 2483 /* Used in core lisp functions for efficiency */ |
2512 Lisp_Object | 2484 void |
2513 signal_void_function_error (Lisp_Object function) | 2485 signal_void_function_error (Lisp_Object function) |
2514 { | 2486 { |
2515 return Fsignal (Qvoid_function, list1 (function)); | 2487 Fsignal (Qvoid_function, list1 (function)); |
2516 } | 2488 } |
2517 | 2489 |
2518 Lisp_Object | 2490 static void |
2519 signal_invalid_function_error (Lisp_Object function) | 2491 signal_invalid_function_error (Lisp_Object function) |
2520 { | 2492 { |
2521 return Fsignal (Qinvalid_function, list1 (function)); | 2493 Fsignal (Qinvalid_function, list1 (function)); |
2522 } | 2494 } |
2523 | 2495 |
2524 Lisp_Object | 2496 static void |
2525 signal_wrong_number_of_arguments_error (Lisp_Object function, int nargs) | 2497 signal_wrong_number_of_arguments_error (Lisp_Object function, int nargs) |
2526 { | 2498 { |
2527 return Fsignal (Qwrong_number_of_arguments, | 2499 Fsignal (Qwrong_number_of_arguments, list2 (function, make_int (nargs))); |
2528 list2 (function, make_int (nargs))); | |
2529 } | 2500 } |
2530 | 2501 |
2531 /* Used in list traversal macros for efficiency. */ | 2502 /* Used in list traversal macros for efficiency. */ |
2532 DOESNT_RETURN | 2503 void |
2533 signal_malformed_list_error (Lisp_Object list) | 2504 signal_malformed_list_error (Lisp_Object list) |
2534 { | 2505 { |
2535 signal_error (Qmalformed_list, list1 (list)); | 2506 Fsignal (Qmalformed_list, list1 (list)); |
2536 } | 2507 } |
2537 | 2508 |
2538 DOESNT_RETURN | 2509 void |
2539 signal_malformed_property_list_error (Lisp_Object list) | 2510 signal_malformed_property_list_error (Lisp_Object list) |
2540 { | 2511 { |
2541 signal_error (Qmalformed_property_list, list1 (list)); | 2512 Fsignal (Qmalformed_property_list, list1 (list)); |
2542 } | 2513 } |
2543 | 2514 |
2544 DOESNT_RETURN | 2515 void |
2545 signal_circular_list_error (Lisp_Object list) | 2516 signal_circular_list_error (Lisp_Object list) |
2546 { | 2517 { |
2547 signal_error (Qcircular_list, list1 (list)); | 2518 Fsignal (Qcircular_list, list1 (list)); |
2548 } | 2519 } |
2549 | 2520 |
2550 DOESNT_RETURN | 2521 void |
2551 signal_circular_property_list_error (Lisp_Object list) | 2522 signal_circular_property_list_error (Lisp_Object list) |
2552 { | 2523 { |
2553 signal_error (Qcircular_property_list, list1 (list)); | 2524 Fsignal (Qcircular_property_list, list1 (list)); |
2554 } | 2525 } |
2555 | 2526 |
2556 /************************************************************************/ | 2527 /************************************************************************/ |
2557 /* User commands */ | 2528 /* User commands */ |
2558 /************************************************************************/ | 2529 /************************************************************************/ |
2660 } | 2631 } |
2661 else | 2632 else |
2662 { | 2633 { |
2663 Fsignal (Qwrong_type_argument, | 2634 Fsignal (Qwrong_type_argument, |
2664 Fcons (Qcommandp, | 2635 Fcons (Qcommandp, |
2665 (EQ (cmd, final) | 2636 ((EQ (cmd, final)) |
2666 ? list1 (cmd) | 2637 ? list1 (cmd) |
2667 : list2 (cmd, final)))); | 2638 : list2 (cmd, final)))); |
2668 return Qnil; | 2639 return Qnil; |
2669 } | 2640 } |
2670 } | 2641 } |
2778 { | 2749 { |
2779 /* Attempt to avoid consing identical (string=) pure strings. */ | 2750 /* Attempt to avoid consing identical (string=) pure strings. */ |
2780 file = Fsymbol_name (Fintern (file, Qnil)); | 2751 file = Fsymbol_name (Fintern (file, Qnil)); |
2781 } | 2752 } |
2782 | 2753 |
2783 return Ffset (function, Fcons (Qautoload, list4 (file, | 2754 return Ffset (function, |
2784 docstring, | 2755 Fpurecopy (Fcons (Qautoload, list4 (file, |
2785 interactive, | 2756 docstring, |
2786 type))); | 2757 interactive, |
2758 type)))); | |
2787 } | 2759 } |
2788 | 2760 |
2789 Lisp_Object | 2761 Lisp_Object |
2790 un_autoload (Lisp_Object oldqueue) | 2762 un_autoload (Lisp_Object oldqueue) |
2791 { | 2763 { |
2868 /************************************************************************/ | 2840 /************************************************************************/ |
2869 /* eval, funcall, apply */ | 2841 /* eval, funcall, apply */ |
2870 /************************************************************************/ | 2842 /************************************************************************/ |
2871 | 2843 |
2872 static Lisp_Object funcall_lambda (Lisp_Object fun, | 2844 static Lisp_Object funcall_lambda (Lisp_Object fun, |
2873 int nargs, Lisp_Object args[]); | 2845 int nargs, Lisp_Object args[]); |
2874 static int in_warnings; | 2846 static int in_warnings; |
2875 | 2847 |
2876 static Lisp_Object | 2848 static Lisp_Object |
2877 in_warnings_restore (Lisp_Object minimus) | 2849 in_warnings_restore (Lisp_Object minimus) |
2878 { | 2850 { |
2981 goto wrong_number_of_arguments; | 2953 goto wrong_number_of_arguments; |
2982 | 2954 |
2983 if (max_args == UNEVALLED) /* Optimize for the common case */ | 2955 if (max_args == UNEVALLED) /* Optimize for the common case */ |
2984 { | 2956 { |
2985 backtrace.evalargs = 0; | 2957 backtrace.evalargs = 0; |
2986 val = (((Lisp_Object (*) (Lisp_Object)) subr_function (subr)) | 2958 val = (((Lisp_Object (*) (Lisp_Object)) (subr_function (subr))) |
2987 (original_args)); | 2959 (original_args)); |
2988 } | 2960 } |
2989 else if (nargs <= max_args) | 2961 else if (nargs <= max_args) |
2990 { | 2962 { |
2991 struct gcpro gcpro1; | 2963 struct gcpro gcpro1; |
3035 } | 3007 } |
3036 | 3008 |
3037 backtrace.args = args; | 3009 backtrace.args = args; |
3038 backtrace.nargs = nargs; | 3010 backtrace.nargs = nargs; |
3039 | 3011 |
3040 val = (((Lisp_Object (*) (int, Lisp_Object *)) subr_function (subr)) | 3012 val = (((Lisp_Object (*) (int, Lisp_Object *)) (subr_function (subr))) |
3041 (nargs, args)); | 3013 (nargs, args)); |
3042 | 3014 |
3043 UNGCPRO; | 3015 UNGCPRO; |
3044 } | 3016 } |
3045 else | 3017 else |
3046 { | 3018 { |
3047 wrong_number_of_arguments: | 3019 wrong_number_of_arguments: |
3048 val = signal_wrong_number_of_arguments_error (original_fun, nargs); | 3020 signal_wrong_number_of_arguments_error (fun, nargs); |
3049 } | 3021 } |
3050 } | 3022 } |
3051 else if (COMPILED_FUNCTIONP (fun)) | 3023 else if (COMPILED_FUNCTIONP (fun)) |
3052 { | 3024 { |
3053 struct gcpro gcpro1; | 3025 struct gcpro gcpro1; |
3131 } | 3103 } |
3132 } | 3104 } |
3133 else /* ! (SUBRP (fun) || COMPILED_FUNCTIONP (fun) || CONSP (fun)) */ | 3105 else /* ! (SUBRP (fun) || COMPILED_FUNCTIONP (fun) || CONSP (fun)) */ |
3134 { | 3106 { |
3135 invalid_function: | 3107 invalid_function: |
3136 val = signal_invalid_function_error (fun); | 3108 signal_invalid_function_error (fun); |
3137 } | 3109 } |
3138 | 3110 |
3139 lisp_eval_depth--; | 3111 lisp_eval_depth--; |
3140 if (backtrace.debug_on_exit) | 3112 if (backtrace.debug_on_exit) |
3141 val = do_debug_on_exit (val); | 3113 val = do_debug_on_exit (val); |
3206 { | 3178 { |
3207 Lisp_Subr *subr = XSUBR (fun); | 3179 Lisp_Subr *subr = XSUBR (fun); |
3208 int max_args = subr->max_args; | 3180 int max_args = subr->max_args; |
3209 Lisp_Object spacious_args[SUBR_MAX_ARGS]; | 3181 Lisp_Object spacious_args[SUBR_MAX_ARGS]; |
3210 | 3182 |
3183 if (fun_nargs < subr->min_args) | |
3184 goto wrong_number_of_arguments; | |
3185 | |
3211 if (fun_nargs == max_args) /* Optimize for the common case */ | 3186 if (fun_nargs == max_args) /* Optimize for the common case */ |
3212 { | 3187 { |
3213 funcall_subr: | 3188 funcall_subr: |
3214 FUNCALL_SUBR (val, subr, fun_args, max_args); | 3189 FUNCALL_SUBR (val, subr, fun_args, max_args); |
3215 } | 3190 } |
3216 else if (fun_nargs < subr->min_args) | |
3217 { | |
3218 goto wrong_number_of_arguments; | |
3219 } | |
3220 else if (fun_nargs < max_args) | 3191 else if (fun_nargs < max_args) |
3221 { | 3192 { |
3222 Lisp_Object *p = spacious_args; | 3193 Lisp_Object *p = spacious_args; |
3223 | 3194 |
3224 /* Default optionals to nil */ | 3195 /* Default optionals to nil */ |
3230 fun_args = spacious_args; | 3201 fun_args = spacious_args; |
3231 goto funcall_subr; | 3202 goto funcall_subr; |
3232 } | 3203 } |
3233 else if (max_args == MANY) | 3204 else if (max_args == MANY) |
3234 { | 3205 { |
3235 val = SUBR_FUNCTION (subr, MANY) (fun_nargs, fun_args); | 3206 val = ((Lisp_Object (*) (int, Lisp_Object *)) (subr_function (subr))) |
3207 (fun_nargs, fun_args); | |
3236 } | 3208 } |
3237 else if (max_args == UNEVALLED) /* Can't funcall a special form */ | 3209 else if (max_args == UNEVALLED) /* Can't funcall a special form */ |
3238 { | 3210 { |
3239 goto invalid_function; | 3211 goto invalid_function; |
3240 } | 3212 } |
3241 else | 3213 else |
3242 { | 3214 { |
3243 wrong_number_of_arguments: | 3215 wrong_number_of_arguments: |
3244 val = signal_wrong_number_of_arguments_error (fun, fun_nargs); | 3216 signal_wrong_number_of_arguments_error (fun, fun_nargs); |
3245 } | 3217 } |
3246 } | 3218 } |
3247 else if (COMPILED_FUNCTIONP (fun)) | 3219 else if (COMPILED_FUNCTIONP (fun)) |
3248 { | 3220 { |
3249 val = funcall_compiled_function (fun, fun_nargs, fun_args); | 3221 val = funcall_compiled_function (fun, fun_nargs, fun_args); |
3266 goto invalid_function; | 3238 goto invalid_function; |
3267 } | 3239 } |
3268 } | 3240 } |
3269 else if (UNBOUNDP (fun)) | 3241 else if (UNBOUNDP (fun)) |
3270 { | 3242 { |
3271 val = signal_void_function_error (args[0]); | 3243 signal_void_function_error (args[0]); |
3272 } | 3244 } |
3273 else | 3245 else |
3274 { | 3246 { |
3275 invalid_function: | 3247 invalid_function: |
3276 val = signal_invalid_function_error (fun); | 3248 signal_invalid_function_error (fun); |
3277 } | 3249 } |
3278 | 3250 |
3279 lisp_eval_depth--; | 3251 lisp_eval_depth--; |
3280 if (backtrace.debug_on_exit) | 3252 if (backtrace.debug_on_exit) |
3281 val = do_debug_on_exit (val); | 3253 val = do_debug_on_exit (val); |
3313 if (SYMBOLP (function)) | 3285 if (SYMBOLP (function)) |
3314 function = indirect_function (function, 1); | 3286 function = indirect_function (function, 1); |
3315 | 3287 |
3316 if (SUBRP (function)) | 3288 if (SUBRP (function)) |
3317 { | 3289 { |
3318 /* Using return with the ?: operator tickles a DEC CC compiler bug. */ | 3290 return function_min_args_p ? |
3319 if (function_min_args_p) | 3291 Fsubr_min_args (function): |
3320 return Fsubr_min_args (function); | 3292 Fsubr_max_args (function); |
3321 else | |
3322 return Fsubr_max_args (function); | |
3323 } | 3293 } |
3324 else if (COMPILED_FUNCTIONP (function)) | 3294 else if (COMPILED_FUNCTIONP (function)) |
3325 { | 3295 { |
3326 arglist = compiled_function_arglist (XCOMPILED_FUNCTION (function)); | 3296 arglist = compiled_function_arglist (XCOMPILED_FUNCTION (function)); |
3327 } | 3297 } |
3349 } | 3319 } |
3350 } | 3320 } |
3351 else | 3321 else |
3352 { | 3322 { |
3353 invalid_function: | 3323 invalid_function: |
3354 return signal_invalid_function_error (function); | 3324 return Fsignal (Qinvalid_function, list1 (function)); |
3355 } | 3325 } |
3356 | 3326 |
3357 { | 3327 { |
3358 int argcount = 0; | 3328 int argcount = 0; |
3359 Lisp_Object arg; | 3329 Lisp_Object arg; |
3536 goto wrong_number_of_arguments; | 3506 goto wrong_number_of_arguments; |
3537 | 3507 |
3538 return unbind_to (speccount, Fprogn (body)); | 3508 return unbind_to (speccount, Fprogn (body)); |
3539 | 3509 |
3540 wrong_number_of_arguments: | 3510 wrong_number_of_arguments: |
3541 return signal_wrong_number_of_arguments_error (fun, nargs); | 3511 return Fsignal (Qwrong_number_of_arguments, list2 (fun, make_int (nargs))); |
3542 | 3512 |
3543 invalid_function: | 3513 invalid_function: |
3544 return signal_invalid_function_error (fun); | 3514 return Fsignal (Qinvalid_function, list1 (fun)); |
3545 } | 3515 } |
3546 | 3516 |
3547 | 3517 |
3548 /************************************************************************/ | 3518 /************************************************************************/ |
3549 /* Run hook variables in various ways. */ | 3519 /* Run hook variables in various ways. */ |
3655 args[0] = val; | 3625 args[0] = val; |
3656 return Ffuncall (nargs, args); | 3626 return Ffuncall (nargs, args); |
3657 } | 3627 } |
3658 else | 3628 else |
3659 { | 3629 { |
3660 struct gcpro gcpro1, gcpro2, gcpro3; | 3630 struct gcpro gcpro1, gcpro2; |
3661 Lisp_Object globals = Qnil; | 3631 GCPRO2 (sym, val); |
3662 GCPRO3 (sym, val, globals); | |
3663 | 3632 |
3664 for (; | 3633 for (; |
3665 CONSP (val) && ((cond == RUN_HOOKS_TO_COMPLETION) | 3634 CONSP (val) && ((cond == RUN_HOOKS_TO_COMPLETION) |
3666 || (cond == RUN_HOOKS_UNTIL_SUCCESS ? NILP (ret) | 3635 || (cond == RUN_HOOKS_UNTIL_SUCCESS ? NILP (ret) |
3667 : !NILP (ret))); | 3636 : !NILP (ret))); |
3669 { | 3638 { |
3670 if (EQ (XCAR (val), Qt)) | 3639 if (EQ (XCAR (val), Qt)) |
3671 { | 3640 { |
3672 /* t indicates this hook has a local binding; | 3641 /* t indicates this hook has a local binding; |
3673 it means to run the global binding too. */ | 3642 it means to run the global binding too. */ |
3674 globals = Fdefault_value (sym); | 3643 Lisp_Object globals = Fdefault_value (sym); |
3675 | 3644 |
3676 if ((! CONSP (globals) || EQ (XCAR (globals), Qlambda)) && | 3645 if ((! CONSP (globals) || EQ (XCAR (globals), Qlambda)) && |
3677 ! NILP (globals)) | 3646 ! NILP (globals)) |
3678 { | 3647 { |
3679 args[0] = globals; | 3648 args[0] = globals; |
4177 (with-output-to-string (display-error errordata)) | 4146 (with-output-to-string (display-error errordata)) |
4178 but that stuff is all in Lisp currently. */ | 4147 but that stuff is all in Lisp currently. */ |
4179 args[1] = errordata; | 4148 args[1] = errordata; |
4180 warn_when_safe_lispobj | 4149 warn_when_safe_lispobj |
4181 (Qerror, Qwarning, | 4150 (Qerror, Qwarning, |
4182 emacs_doprnt_string_lisp ((const Bufbyte *) "%s: %s", | 4151 emacs_doprnt_string_lisp ((CONST Bufbyte *) "%s: %s", |
4183 Qnil, -1, 2, args)); | 4152 Qnil, -1, 2, args)); |
4184 } | 4153 } |
4185 return Qunbound; | 4154 return Qunbound; |
4186 } | 4155 } |
4187 | 4156 |
4220 { | 4189 { |
4221 return eval_in_buffer (XBUFFER (XCAR (cons)), XCDR (cons)); | 4190 return eval_in_buffer (XBUFFER (XCAR (cons)), XCDR (cons)); |
4222 } | 4191 } |
4223 | 4192 |
4224 Lisp_Object | 4193 Lisp_Object |
4225 eval_in_buffer_trapping_errors (const char *warning_string, | 4194 eval_in_buffer_trapping_errors (CONST char *warning_string, |
4226 struct buffer *buf, Lisp_Object form) | 4195 struct buffer *buf, Lisp_Object form) |
4227 { | 4196 { |
4228 int speccount = specpdl_depth(); | 4197 int speccount = specpdl_depth(); |
4229 Lisp_Object tem; | 4198 Lisp_Object tem; |
4230 Lisp_Object buffer; | 4199 Lisp_Object buffer; |
4236 | 4205 |
4237 specbind (Qinhibit_quit, Qt); | 4206 specbind (Qinhibit_quit, Qt); |
4238 /* gc_currently_forbidden = 1; Currently no reason to do this; */ | 4207 /* gc_currently_forbidden = 1; Currently no reason to do this; */ |
4239 | 4208 |
4240 cons = noseeum_cons (buffer, form); | 4209 cons = noseeum_cons (buffer, form); |
4241 opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil); | 4210 opaque = (warning_string ? make_opaque_ptr (warning_string) : Qnil); |
4242 GCPRO2 (cons, opaque); | 4211 GCPRO2 (cons, opaque); |
4243 /* Qerror not Qt, so you can get a backtrace */ | 4212 /* Qerror not Qt, so you can get a backtrace */ |
4244 tem = condition_case_1 (Qerror, | 4213 tem = condition_case_1 (Qerror, |
4245 catch_them_squirmers_eval_in_buffer, cons, | 4214 catch_them_squirmers_eval_in_buffer, cons, |
4246 caught_a_squirmer, opaque); | 4215 caught_a_squirmer, opaque); |
4247 free_cons (XCONS (cons)); | 4216 free_cons (XCONS (cons)); |
4248 if (OPAQUE_PTRP (opaque)) | 4217 if (OPAQUEP (opaque)) |
4249 free_opaque_ptr (opaque); | 4218 free_opaque_ptr (opaque); |
4250 UNGCPRO; | 4219 UNGCPRO; |
4251 | 4220 |
4252 /* gc_currently_forbidden = 0; */ | 4221 /* gc_currently_forbidden = 0; */ |
4253 return unbind_to (speccount, tem); | 4222 return unbind_to (speccount, tem); |
4260 run_hook (hook_symbol); | 4229 run_hook (hook_symbol); |
4261 return Qnil; | 4230 return Qnil; |
4262 } | 4231 } |
4263 | 4232 |
4264 Lisp_Object | 4233 Lisp_Object |
4265 run_hook_trapping_errors (const char *warning_string, Lisp_Object hook_symbol) | 4234 run_hook_trapping_errors (CONST char *warning_string, Lisp_Object hook_symbol) |
4266 { | 4235 { |
4267 int speccount; | 4236 int speccount; |
4268 Lisp_Object tem; | 4237 Lisp_Object tem; |
4269 Lisp_Object opaque; | 4238 Lisp_Object opaque; |
4270 struct gcpro gcpro1; | 4239 struct gcpro gcpro1; |
4276 return Qnil; | 4245 return Qnil; |
4277 | 4246 |
4278 speccount = specpdl_depth(); | 4247 speccount = specpdl_depth(); |
4279 specbind (Qinhibit_quit, Qt); | 4248 specbind (Qinhibit_quit, Qt); |
4280 | 4249 |
4281 opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil); | 4250 opaque = (warning_string ? make_opaque_ptr (warning_string) : Qnil); |
4282 GCPRO1 (opaque); | 4251 GCPRO1 (opaque); |
4283 /* Qerror not Qt, so you can get a backtrace */ | 4252 /* Qerror not Qt, so you can get a backtrace */ |
4284 tem = condition_case_1 (Qerror, | 4253 tem = condition_case_1 (Qerror, |
4285 catch_them_squirmers_run_hook, hook_symbol, | 4254 catch_them_squirmers_run_hook, hook_symbol, |
4286 caught_a_squirmer, opaque); | 4255 caught_a_squirmer, opaque); |
4287 if (OPAQUE_PTRP (opaque)) | 4256 if (OPAQUEP (opaque)) |
4288 free_opaque_ptr (opaque); | 4257 free_opaque_ptr (opaque); |
4289 UNGCPRO; | 4258 UNGCPRO; |
4290 | 4259 |
4291 return unbind_to (speccount, tem); | 4260 return unbind_to (speccount, tem); |
4292 } | 4261 } |
4293 | 4262 |
4294 /* Same as run_hook_trapping_errors() but also set the hook to nil | 4263 /* Same as run_hook_trapping_errors() but also set the hook to nil |
4295 if an error occurs. */ | 4264 if an error occurs. */ |
4296 | 4265 |
4297 Lisp_Object | 4266 Lisp_Object |
4298 safe_run_hook_trapping_errors (const char *warning_string, | 4267 safe_run_hook_trapping_errors (CONST char *warning_string, |
4299 Lisp_Object hook_symbol, | 4268 Lisp_Object hook_symbol, |
4300 int allow_quit) | 4269 int allow_quit) |
4301 { | 4270 { |
4302 int speccount = specpdl_depth(); | 4271 int speccount = specpdl_depth(); |
4303 Lisp_Object tem; | 4272 Lisp_Object tem; |
4312 | 4281 |
4313 if (!allow_quit) | 4282 if (!allow_quit) |
4314 specbind (Qinhibit_quit, Qt); | 4283 specbind (Qinhibit_quit, Qt); |
4315 | 4284 |
4316 cons = noseeum_cons (hook_symbol, | 4285 cons = noseeum_cons (hook_symbol, |
4317 warning_string ? make_opaque_ptr ((void *)warning_string) | 4286 warning_string ? make_opaque_ptr (warning_string) |
4318 : Qnil); | 4287 : Qnil); |
4319 GCPRO1 (cons); | 4288 GCPRO1 (cons); |
4320 /* Qerror not Qt, so you can get a backtrace */ | 4289 /* Qerror not Qt, so you can get a backtrace */ |
4321 tem = condition_case_1 (Qerror, | 4290 tem = condition_case_1 (Qerror, |
4322 catch_them_squirmers_run_hook, | 4291 catch_them_squirmers_run_hook, |
4323 hook_symbol, | 4292 hook_symbol, |
4324 allow_quit ? | 4293 allow_quit ? |
4325 allow_quit_safe_run_hook_caught_a_squirmer : | 4294 allow_quit_safe_run_hook_caught_a_squirmer : |
4326 safe_run_hook_caught_a_squirmer, | 4295 safe_run_hook_caught_a_squirmer, |
4327 cons); | 4296 cons); |
4328 if (OPAQUE_PTRP (XCDR (cons))) | 4297 if (OPAQUEP (XCDR (cons))) |
4329 free_opaque_ptr (XCDR (cons)); | 4298 free_opaque_ptr (XCDR (cons)); |
4330 free_cons (XCONS (cons)); | 4299 free_cons (XCONS (cons)); |
4331 UNGCPRO; | 4300 UNGCPRO; |
4332 | 4301 |
4333 return unbind_to (speccount, tem); | 4302 return unbind_to (speccount, tem); |
4339 /* This function can GC */ | 4308 /* This function can GC */ |
4340 return call0 (function); | 4309 return call0 (function); |
4341 } | 4310 } |
4342 | 4311 |
4343 Lisp_Object | 4312 Lisp_Object |
4344 call0_trapping_errors (const char *warning_string, Lisp_Object function) | 4313 call0_trapping_errors (CONST char *warning_string, Lisp_Object function) |
4345 { | 4314 { |
4346 int speccount; | 4315 int speccount; |
4347 Lisp_Object tem; | 4316 Lisp_Object tem; |
4348 Lisp_Object opaque = Qnil; | 4317 Lisp_Object opaque = Qnil; |
4349 struct gcpro gcpro1, gcpro2; | 4318 struct gcpro gcpro1, gcpro2; |
4358 GCPRO2 (opaque, function); | 4327 GCPRO2 (opaque, function); |
4359 speccount = specpdl_depth(); | 4328 speccount = specpdl_depth(); |
4360 specbind (Qinhibit_quit, Qt); | 4329 specbind (Qinhibit_quit, Qt); |
4361 /* gc_currently_forbidden = 1; Currently no reason to do this; */ | 4330 /* gc_currently_forbidden = 1; Currently no reason to do this; */ |
4362 | 4331 |
4363 opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil); | 4332 opaque = (warning_string ? make_opaque_ptr (warning_string) : Qnil); |
4364 /* Qerror not Qt, so you can get a backtrace */ | 4333 /* Qerror not Qt, so you can get a backtrace */ |
4365 tem = condition_case_1 (Qerror, | 4334 tem = condition_case_1 (Qerror, |
4366 catch_them_squirmers_call0, function, | 4335 catch_them_squirmers_call0, function, |
4367 caught_a_squirmer, opaque); | 4336 caught_a_squirmer, opaque); |
4368 if (OPAQUE_PTRP (opaque)) | 4337 if (OPAQUEP (opaque)) |
4369 free_opaque_ptr (opaque); | 4338 free_opaque_ptr (opaque); |
4370 UNGCPRO; | 4339 UNGCPRO; |
4371 | 4340 |
4372 /* gc_currently_forbidden = 0; */ | 4341 /* gc_currently_forbidden = 0; */ |
4373 return unbind_to (speccount, tem); | 4342 return unbind_to (speccount, tem); |
4386 /* This function can GC */ | 4355 /* This function can GC */ |
4387 return call2 (XCAR (cons), XCAR (XCDR (cons)), XCAR (XCDR (XCDR (cons)))); | 4356 return call2 (XCAR (cons), XCAR (XCDR (cons)), XCAR (XCDR (XCDR (cons)))); |
4388 } | 4357 } |
4389 | 4358 |
4390 Lisp_Object | 4359 Lisp_Object |
4391 call1_trapping_errors (const char *warning_string, Lisp_Object function, | 4360 call1_trapping_errors (CONST char *warning_string, Lisp_Object function, |
4392 Lisp_Object object) | 4361 Lisp_Object object) |
4393 { | 4362 { |
4394 int speccount = specpdl_depth(); | 4363 int speccount = specpdl_depth(); |
4395 Lisp_Object tem; | 4364 Lisp_Object tem; |
4396 Lisp_Object cons = Qnil; | 4365 Lisp_Object cons = Qnil; |
4408 | 4377 |
4409 specbind (Qinhibit_quit, Qt); | 4378 specbind (Qinhibit_quit, Qt); |
4410 /* gc_currently_forbidden = 1; Currently no reason to do this; */ | 4379 /* gc_currently_forbidden = 1; Currently no reason to do this; */ |
4411 | 4380 |
4412 cons = noseeum_cons (function, object); | 4381 cons = noseeum_cons (function, object); |
4413 opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil); | 4382 opaque = (warning_string ? make_opaque_ptr (warning_string) : Qnil); |
4414 /* Qerror not Qt, so you can get a backtrace */ | 4383 /* Qerror not Qt, so you can get a backtrace */ |
4415 tem = condition_case_1 (Qerror, | 4384 tem = condition_case_1 (Qerror, |
4416 catch_them_squirmers_call1, cons, | 4385 catch_them_squirmers_call1, cons, |
4417 caught_a_squirmer, opaque); | 4386 caught_a_squirmer, opaque); |
4418 if (OPAQUE_PTRP (opaque)) | 4387 if (OPAQUEP (opaque)) |
4419 free_opaque_ptr (opaque); | 4388 free_opaque_ptr (opaque); |
4420 free_cons (XCONS (cons)); | 4389 free_cons (XCONS (cons)); |
4421 UNGCPRO; | 4390 UNGCPRO; |
4422 | 4391 |
4423 /* gc_currently_forbidden = 0; */ | 4392 /* gc_currently_forbidden = 0; */ |
4424 return unbind_to (speccount, tem); | 4393 return unbind_to (speccount, tem); |
4425 } | 4394 } |
4426 | 4395 |
4427 Lisp_Object | 4396 Lisp_Object |
4428 call2_trapping_errors (const char *warning_string, Lisp_Object function, | 4397 call2_trapping_errors (CONST char *warning_string, Lisp_Object function, |
4429 Lisp_Object object1, Lisp_Object object2) | 4398 Lisp_Object object1, Lisp_Object object2) |
4430 { | 4399 { |
4431 int speccount = specpdl_depth(); | 4400 int speccount = specpdl_depth(); |
4432 Lisp_Object tem; | 4401 Lisp_Object tem; |
4433 Lisp_Object cons = Qnil; | 4402 Lisp_Object cons = Qnil; |
4444 GCPRO5 (cons, opaque, function, object1, object2); | 4413 GCPRO5 (cons, opaque, function, object1, object2); |
4445 specbind (Qinhibit_quit, Qt); | 4414 specbind (Qinhibit_quit, Qt); |
4446 /* gc_currently_forbidden = 1; Currently no reason to do this; */ | 4415 /* gc_currently_forbidden = 1; Currently no reason to do this; */ |
4447 | 4416 |
4448 cons = list3 (function, object1, object2); | 4417 cons = list3 (function, object1, object2); |
4449 opaque = (warning_string ? make_opaque_ptr ((void *)warning_string) : Qnil); | 4418 opaque = (warning_string ? make_opaque_ptr (warning_string) : Qnil); |
4450 /* Qerror not Qt, so you can get a backtrace */ | 4419 /* Qerror not Qt, so you can get a backtrace */ |
4451 tem = condition_case_1 (Qerror, | 4420 tem = condition_case_1 (Qerror, |
4452 catch_them_squirmers_call2, cons, | 4421 catch_them_squirmers_call2, cons, |
4453 caught_a_squirmer, opaque); | 4422 caught_a_squirmer, opaque); |
4454 if (OPAQUE_PTRP (opaque)) | 4423 if (OPAQUEP (opaque)) |
4455 free_opaque_ptr (opaque); | 4424 free_opaque_ptr (opaque); |
4456 free_list (cons); | 4425 free_list (cons); |
4457 UNGCPRO; | 4426 UNGCPRO; |
4458 | 4427 |
4459 /* gc_currently_forbidden = 0; */ | 4428 /* gc_currently_forbidden = 0; */ |
4502 static Lisp_Object | 4471 static Lisp_Object |
4503 specbind_unwind_local (Lisp_Object ovalue) | 4472 specbind_unwind_local (Lisp_Object ovalue) |
4504 { | 4473 { |
4505 Lisp_Object current = Fcurrent_buffer (); | 4474 Lisp_Object current = Fcurrent_buffer (); |
4506 Lisp_Object symbol = specpdl_ptr->symbol; | 4475 Lisp_Object symbol = specpdl_ptr->symbol; |
4507 Lisp_Cons *victim = XCONS (ovalue); | 4476 struct Lisp_Cons *victim = XCONS (ovalue); |
4508 Lisp_Object buf = get_buffer (victim->car, 0); | 4477 Lisp_Object buf = get_buffer (victim->car, 0); |
4509 ovalue = victim->cdr; | 4478 ovalue = victim->cdr; |
4510 | 4479 |
4511 free_cons (victim); | 4480 free_cons (victim); |
4512 | 4481 |
4637 void | 4606 void |
4638 unbind_to_hairy (int count) | 4607 unbind_to_hairy (int count) |
4639 { | 4608 { |
4640 int quitf; | 4609 int quitf; |
4641 | 4610 |
4642 ++specpdl_ptr; | |
4643 ++specpdl_depth_counter; | |
4644 | |
4645 check_quit (); /* make Vquit_flag accurate */ | 4611 check_quit (); /* make Vquit_flag accurate */ |
4646 quitf = !NILP (Vquit_flag); | 4612 quitf = !NILP (Vquit_flag); |
4647 Vquit_flag = Qnil; | 4613 Vquit_flag = Qnil; |
4614 | |
4615 ++specpdl_ptr; | |
4616 ++specpdl_depth_counter; | |
4648 | 4617 |
4649 while (specpdl_depth_counter != count) | 4618 while (specpdl_depth_counter != count) |
4650 { | 4619 { |
4651 --specpdl_ptr; | 4620 --specpdl_ptr; |
4652 --specpdl_depth_counter; | 4621 --specpdl_depth_counter; |
4656 (*specpdl_ptr->func) (specpdl_ptr->old_value); | 4625 (*specpdl_ptr->func) (specpdl_ptr->old_value); |
4657 else | 4626 else |
4658 { | 4627 { |
4659 /* We checked symbol for validity when we specbound it, | 4628 /* We checked symbol for validity when we specbound it, |
4660 so only need to call Fset if symbol has magic value. */ | 4629 so only need to call Fset if symbol has magic value. */ |
4661 Lisp_Symbol *sym = XSYMBOL (specpdl_ptr->symbol); | 4630 struct Lisp_Symbol *sym = XSYMBOL (specpdl_ptr->symbol); |
4662 if (!SYMBOL_VALUE_MAGIC_P (sym->value)) | 4631 if (!SYMBOL_VALUE_MAGIC_P (sym->value)) |
4663 sym->value = specpdl_ptr->old_value; | 4632 sym->value = specpdl_ptr->old_value; |
4664 else | 4633 else |
4665 Fset (specpdl_ptr->symbol, specpdl_ptr->old_value); | 4634 Fset (specpdl_ptr->symbol, specpdl_ptr->old_value); |
4666 } | 4635 } |
4782 if (printing_bindings) write_c_string (")\n", stream); | 4751 if (printing_bindings) write_c_string (")\n", stream); |
4783 } | 4752 } |
4784 | 4753 |
4785 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /* | 4754 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /* |
4786 Print a trace of Lisp function calls currently active. | 4755 Print a trace of Lisp function calls currently active. |
4787 Optional arg STREAM specifies the output stream to send the backtrace to, | 4756 Option arg STREAM specifies the output stream to send the backtrace to, |
4788 and defaults to the value of `standard-output'. Optional second arg | 4757 and defaults to the value of `standard-output'. Optional second arg |
4789 DETAILED means show places where currently active variable bindings, | 4758 DETAILED means show places where currently active variable bindings, |
4790 catches, condition-cases, and unwind-protects were made as well as | 4759 catches, condition-cases, and unwind-protects were made as well as |
4791 function calls. | 4760 function calls. |
4792 */ | 4761 */ |
4825 for (;;) | 4794 for (;;) |
4826 { | 4795 { |
4827 if (!NILP (detailed) && catches && catches->backlist == backlist) | 4796 if (!NILP (detailed) && catches && catches->backlist == backlist) |
4828 { | 4797 { |
4829 int catchpdl = catches->pdlcount; | 4798 int catchpdl = catches->pdlcount; |
4830 if (speccount > catchpdl | 4799 if (specpdl[catchpdl].func == condition_case_unwind |
4831 && specpdl[catchpdl].func == condition_case_unwind) | 4800 && speccount > catchpdl) |
4832 /* This is a condition-case catchpoint */ | 4801 /* This is a condition-case catchpoint */ |
4833 catchpdl = catchpdl + 1; | 4802 catchpdl = catchpdl + 1; |
4834 | 4803 |
4835 backtrace_specials (speccount, catchpdl, stream); | 4804 backtrace_specials (speccount, catchpdl, stream); |
4836 | 4805 |
4897 } | 4866 } |
4898 if (i != 0) write_c_string (" ", stream); | 4867 if (i != 0) write_c_string (" ", stream); |
4899 Fprin1 (backlist->args[i], stream); | 4868 Fprin1 (backlist->args[i], stream); |
4900 } | 4869 } |
4901 } | 4870 } |
4902 write_c_string (")\n", stream); | |
4903 } | 4871 } |
4872 write_c_string (")\n", stream); | |
4904 backlist = backlist->next; | 4873 backlist = backlist->next; |
4905 } | 4874 } |
4906 } | 4875 } |
4907 Vprint_level = old_level; | 4876 Vprint_level = old_level; |
4908 print_readably = old_pr; | 4877 print_readably = old_pr; |
4976 An alternative approach is to just pass some non-string type of | 4945 An alternative approach is to just pass some non-string type of |
4977 Lisp_Object to warn_when_safe_lispobj(); `prin1-to-string' will | 4946 Lisp_Object to warn_when_safe_lispobj(); `prin1-to-string' will |
4978 automatically be called when it is safe to do so. */ | 4947 automatically be called when it is safe to do so. */ |
4979 | 4948 |
4980 void | 4949 void |
4981 warn_when_safe (Lisp_Object class, Lisp_Object level, const char *fmt, ...) | 4950 warn_when_safe (Lisp_Object class, Lisp_Object level, CONST char *fmt, ...) |
4982 { | 4951 { |
4983 Lisp_Object obj; | 4952 Lisp_Object obj; |
4984 va_list args; | 4953 va_list args; |
4985 | 4954 |
4986 va_start (args, fmt); | 4955 va_start (args, fmt); |
4987 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), | 4956 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), |
4988 Qnil, -1, args); | 4957 Qnil, -1, args); |
4989 va_end (args); | 4958 va_end (args); |
4990 | 4959 |
4991 warn_when_safe_lispobj (class, level, obj); | 4960 warn_when_safe_lispobj (class, level, obj); |
4992 } | 4961 } |
4999 /************************************************************************/ | 4968 /************************************************************************/ |
5000 | 4969 |
5001 void | 4970 void |
5002 syms_of_eval (void) | 4971 syms_of_eval (void) |
5003 { | 4972 { |
5004 INIT_LRECORD_IMPLEMENTATION (subr); | |
5005 | |
5006 defsymbol (&Qinhibit_quit, "inhibit-quit"); | 4973 defsymbol (&Qinhibit_quit, "inhibit-quit"); |
5007 defsymbol (&Qautoload, "autoload"); | 4974 defsymbol (&Qautoload, "autoload"); |
5008 defsymbol (&Qdebug_on_error, "debug-on-error"); | 4975 defsymbol (&Qdebug_on_error, "debug-on-error"); |
5009 defsymbol (&Qstack_trace_on_error, "stack-trace-on-error"); | 4976 defsymbol (&Qstack_trace_on_error, "stack-trace-on-error"); |
5010 defsymbol (&Qdebug_on_signal, "debug-on-signal"); | 4977 defsymbol (&Qdebug_on_signal, "debug-on-signal"); |
5084 lisp_eval_depth = 0; | 5051 lisp_eval_depth = 0; |
5085 entering_debugger = 0; | 5052 entering_debugger = 0; |
5086 } | 5053 } |
5087 | 5054 |
5088 void | 5055 void |
5089 reinit_vars_of_eval (void) | |
5090 { | |
5091 preparing_for_armageddon = 0; | |
5092 in_warnings = 0; | |
5093 Qunbound_suspended_errors_tag = make_opaque_ptr (&Qunbound_suspended_errors_tag); | |
5094 staticpro_nodump (&Qunbound_suspended_errors_tag); | |
5095 | |
5096 specpdl_size = 50; | |
5097 specpdl = xnew_array (struct specbinding, specpdl_size); | |
5098 /* XEmacs change: increase these values. */ | |
5099 max_specpdl_size = 3000; | |
5100 max_lisp_eval_depth = 500; | |
5101 #ifdef DEFEND_AGAINST_THROW_RECURSION | |
5102 throw_level = 0; | |
5103 #endif | |
5104 } | |
5105 | |
5106 void | |
5107 vars_of_eval (void) | 5056 vars_of_eval (void) |
5108 { | 5057 { |
5109 reinit_vars_of_eval (); | |
5110 | |
5111 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size /* | 5058 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size /* |
5112 Limit on number of Lisp variable bindings & unwind-protects before error. | 5059 Limit on number of Lisp variable bindings & unwind-protects before error. |
5113 */ ); | 5060 */ ); |
5114 | 5061 |
5115 DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth /* | 5062 DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth /* |
5207 If due to `apply' or `funcall' entry, one arg, `lambda'. | 5154 If due to `apply' or `funcall' entry, one arg, `lambda'. |
5208 If due to `eval' entry, one arg, t. | 5155 If due to `eval' entry, one arg, t. |
5209 */ ); | 5156 */ ); |
5210 Vdebugger = Qnil; | 5157 Vdebugger = Qnil; |
5211 | 5158 |
5159 preparing_for_armageddon = 0; | |
5160 | |
5212 staticpro (&Vpending_warnings); | 5161 staticpro (&Vpending_warnings); |
5213 Vpending_warnings = Qnil; | 5162 Vpending_warnings = Qnil; |
5214 pdump_wire (&Vpending_warnings_tail); | 5163 Vpending_warnings_tail = Qnil; /* no need to protect this */ |
5215 Vpending_warnings_tail = Qnil; | 5164 |
5165 in_warnings = 0; | |
5216 | 5166 |
5217 staticpro (&Vautoload_queue); | 5167 staticpro (&Vautoload_queue); |
5218 Vautoload_queue = Qnil; | 5168 Vautoload_queue = Qnil; |
5219 | 5169 |
5220 staticpro (&Vcondition_handlers); | 5170 staticpro (&Vcondition_handlers); |
5223 Vcurrent_warning_class = Qnil; | 5173 Vcurrent_warning_class = Qnil; |
5224 | 5174 |
5225 staticpro (&Vcurrent_error_state); | 5175 staticpro (&Vcurrent_error_state); |
5226 Vcurrent_error_state = Qnil; /* errors as normal */ | 5176 Vcurrent_error_state = Qnil; /* errors as normal */ |
5227 | 5177 |
5178 Qunbound_suspended_errors_tag = make_opaque_long (0); | |
5179 staticpro (&Qunbound_suspended_errors_tag); | |
5180 | |
5181 specpdl_size = 50; | |
5182 specpdl_depth_counter = 0; | |
5183 specpdl = xnew_array (struct specbinding, specpdl_size); | |
5184 /* XEmacs change: increase these values. */ | |
5185 max_specpdl_size = 3000; | |
5186 max_lisp_eval_depth = 500; | |
5187 #if 0 /* no longer used */ | |
5188 throw_level = 0; | |
5189 #endif | |
5190 | |
5228 reinit_eval (); | 5191 reinit_eval (); |
5229 } | 5192 } |