comparison src/eval.c @ 18636:b3f3cd32fa70

(Fsignal, find_handler_clause): If ERROR_SYMBOL is nil, assume it's in the car of DATA.
author Richard M. Stallman <rms@gnu.org>
date Sat, 05 Jul 1997 19:58:21 +0000
parents 2a11f1e4bd6b
children 9c03cae980ed
comparison
equal deleted inserted replaced
18635:d55ebf568fe7 18636:b3f3cd32fa70
1209 Lisp_Object conditions; 1209 Lisp_Object conditions;
1210 extern int gc_in_progress; 1210 extern int gc_in_progress;
1211 extern int waiting_for_input; 1211 extern int waiting_for_input;
1212 Lisp_Object debugger_value; 1212 Lisp_Object debugger_value;
1213 Lisp_Object string; 1213 Lisp_Object string;
1214 Lisp_Object real_error_symbol;
1215 Lisp_Object combined_data;
1214 1216
1215 quit_error_check (); 1217 quit_error_check ();
1216 immediate_quit = 0; 1218 immediate_quit = 0;
1217 if (gc_in_progress || waiting_for_input) 1219 if (gc_in_progress || waiting_for_input)
1218 abort (); 1220 abort ();
1219 1221
1220 #ifdef HAVE_WINDOW_SYSTEM 1222 #ifdef HAVE_WINDOW_SYSTEM
1221 TOTALLY_UNBLOCK_INPUT; 1223 TOTALLY_UNBLOCK_INPUT;
1222 #endif 1224 #endif
1223 1225
1226 if (NILP (error_symbol))
1227 real_error_symbol = Fcar (data);
1228 else
1229 real_error_symbol = error_symbol;
1230
1224 /* This hook is used by edebug. */ 1231 /* This hook is used by edebug. */
1225 if (! NILP (Vsignal_hook_function)) 1232 if (! NILP (Vsignal_hook_function))
1226 call2 (Vsignal_hook_function, error_symbol, data); 1233 call2 (Vsignal_hook_function, error_symbol, data);
1227 1234
1228 conditions = Fget (error_symbol, Qerror_conditions); 1235 conditions = Fget (real_error_symbol, Qerror_conditions);
1229 1236
1230 for (; handlerlist; handlerlist = handlerlist->next) 1237 for (; handlerlist; handlerlist = handlerlist->next)
1231 { 1238 {
1232 register Lisp_Object clause; 1239 register Lisp_Object clause;
1233 clause = find_handler_clause (handlerlist->handler, conditions, 1240 clause = find_handler_clause (handlerlist->handler, conditions,
1242 #else 1249 #else
1243 if (EQ (clause, Qlambda)) 1250 if (EQ (clause, Qlambda))
1244 { 1251 {
1245 /* We can't return values to code which signaled an error, but we 1252 /* We can't return values to code which signaled an error, but we
1246 can continue code which has signaled a quit. */ 1253 can continue code which has signaled a quit. */
1247 if (EQ (error_symbol, Qquit)) 1254 if (EQ (real_error_symbol, Qquit))
1248 return Qnil; 1255 return Qnil;
1249 else 1256 else
1250 error ("Cannot return from the debugger in an error"); 1257 error ("Cannot return from the debugger in an error");
1251 } 1258 }
1252 #endif 1259 #endif
1255 { 1262 {
1256 Lisp_Object unwind_data; 1263 Lisp_Object unwind_data;
1257 struct handler *h = handlerlist; 1264 struct handler *h = handlerlist;
1258 1265
1259 handlerlist = allhandlers; 1266 handlerlist = allhandlers;
1260 if (EQ (data, memory_signal_data)) 1267
1261 unwind_data = memory_signal_data; 1268 if (NILP (error_symbol))
1269 unwind_data = data;
1262 else 1270 else
1263 unwind_data = Fcons (error_symbol, data); 1271 unwind_data = Fcons (error_symbol, data);
1264 h->chosen_clause = clause; 1272 h->chosen_clause = clause;
1265 unwind_to_catch (h->tag, unwind_data); 1273 unwind_to_catch (h->tag, unwind_data);
1266 } 1274 }
1271 and if that fails, throw to top level. */ 1279 and if that fails, throw to top level. */
1272 find_handler_clause (Qerror, conditions, error_symbol, data, &debugger_value); 1280 find_handler_clause (Qerror, conditions, error_symbol, data, &debugger_value);
1273 if (catchlist != 0) 1281 if (catchlist != 0)
1274 Fthrow (Qtop_level, Qt); 1282 Fthrow (Qtop_level, Qt);
1275 1283
1276 if (! EQ (data, memory_signal_data)) 1284 if (! NILP (error_symbol))
1277 data = Fcons (error_symbol, data); 1285 data = Fcons (error_symbol, data);
1278 1286
1279 string = Ferror_message_string (data); 1287 string = Ferror_message_string (data);
1280 fatal (XSTRING (string)->data, 0, 0); 1288 fatal (XSTRING (string)->data, 0, 0);
1281 } 1289 }
1342 1350
1343 return 0; 1351 return 0;
1344 } 1352 }
1345 1353
1346 /* Value of Qlambda means we have called debugger and user has continued. 1354 /* Value of Qlambda means we have called debugger and user has continued.
1355 There are two ways to pass SIG and DATA:
1356 - SIG is the error symbol, and DATA is the rest of the data.
1357 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1358
1347 Store value returned from debugger into *DEBUGGER_VALUE_PTR. */ 1359 Store value returned from debugger into *DEBUGGER_VALUE_PTR. */
1348 1360
1349 static Lisp_Object 1361 static Lisp_Object
1350 find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr) 1362 find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr)
1351 Lisp_Object handlers, conditions, sig, data; 1363 Lisp_Object handlers, conditions, sig, data;
1362 || !NILP (Vdebug_on_signal)) /* This says call debugger even if 1374 || !NILP (Vdebug_on_signal)) /* This says call debugger even if
1363 there is a handler. */ 1375 there is a handler. */
1364 { 1376 {
1365 int count = specpdl_ptr - specpdl; 1377 int count = specpdl_ptr - specpdl;
1366 int debugger_called = 0; 1378 int debugger_called = 0;
1379 Lisp_Object sig_symbol, combined_data;
1380
1381 if (NILP (sig))
1382 {
1383 combined_data = data;
1384 sig_symbol = Fcar (data);
1385 }
1386 else
1387 {
1388 combined_data = Fcons (sig, data);
1389 sig_symbol = sig;
1390 }
1367 1391
1368 if (wants_debugger (Vstack_trace_on_error, conditions)) 1392 if (wants_debugger (Vstack_trace_on_error, conditions))
1369 internal_with_output_to_temp_buffer ("*Backtrace*", Fbacktrace, Qnil); 1393 internal_with_output_to_temp_buffer ("*Backtrace*", Fbacktrace, Qnil);
1370 if ((EQ (sig, Qquit) 1394 if ((EQ (sig_symbol, Qquit)
1371 ? debug_on_quit 1395 ? debug_on_quit
1372 : wants_debugger (Vdebug_on_error, conditions)) 1396 : wants_debugger (Vdebug_on_error, conditions))
1373 && ! skip_debugger (conditions, Fcons (sig, data)) 1397 && ! skip_debugger (conditions, combined_data)
1374 && when_entered_debugger < num_nonmacro_input_events) 1398 && when_entered_debugger < num_nonmacro_input_events)
1375 { 1399 {
1376 specbind (Qdebug_on_error, Qnil); 1400 specbind (Qdebug_on_error, Qnil);
1377 *debugger_value_ptr 1401 *debugger_value_ptr
1378 = call_debugger (Fcons (Qerror, 1402 = call_debugger (Fcons (Qerror,
1379 Fcons (Fcons (sig, data), 1403 Fcons (combined_data, Qnil)));
1380 Qnil)));
1381 debugger_called = 1; 1404 debugger_called = 1;
1382 } 1405 }
1383 /* If there is no handler, return saying whether we ran the debugger. */ 1406 /* If there is no handler, return saying whether we ran the debugger. */
1384 if (EQ (handlers, Qerror)) 1407 if (EQ (handlers, Qerror))
1385 { 1408 {