comparison src/eval.c @ 578:190b164ddcac

[xemacs-hg @ 2001-05-25 11:26:50 by ben] device-msw.c, eldap.c, emodules.c, hpplay.c, process-unix.c, sound.h, tooltalk.c, win32.c: Revert Martin's attempted compile-warnings fix. It does fix the warnings, but not the right way. We are trying to eliminate the raw use of `char' and `unsigned char' absolutely everywhere. There is never an occasion to reintroduce these. buffer.h: Instead, we fix these macros so they don't care about the type of their lvalues. We already do this for the non-C-string equivalents of these, and it's correct because it should be OK to pass in an SBufbyte *, for example. In any case, we do not need any type-correctness checking here -- errors will be caught for sure as soon as we remove the -Wno-sign-compare switch. mule-charset.c: Use invalid_argument, not generic signal_error (Qerror, ). alloc.c, chartab.c, console-gtk.c, console-msw.c, console-stream.c, console-stream.h, console-tty.c, console-tty.h, console-x.c, console.c, console.h, device-x.c, device.c, elhash.c, eval.c, faces.c, faces.h, fns.c, glyphs.c, glyphs.h, gui.c, gui.h, lisp.h, lread.c, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, process-unix.c, rangetab.c, search.c, specifier.c, toolbar.c, window.c, window.h: Rename Error_behavior to Error_Behavior, to be consistent with general naming practices (Lisp_Object, Char_Binary, etc.).
author ben
date Fri, 25 May 2001 11:27:01 +0000
parents 183866b06e0b
children 13e3d7ae7155
comparison
equal deleted inserted replaced
577:910449c92002 578:190b164ddcac
2120 2120
2121 (1) signal the error, as usual. 2121 (1) signal the error, as usual.
2122 (2) silently fail and return some error value. 2122 (2) silently fail and return some error value.
2123 (3) do as (2) but issue a warning in the process. 2123 (3) do as (2) but issue a warning in the process.
2124 2124
2125 Currently there's lots of stuff that passes an Error_behavior 2125 Currently there's lots of stuff that passes an Error_Behavior
2126 value and calls maybe_signal_error() and other such functions. 2126 value and calls maybe_signal_error() and other such functions.
2127 This approach is inherently error-prone and broken. A much 2127 This approach is inherently error-prone and broken. A much
2128 more robust and easier approach is to use call_with_suspended_errors(). 2128 more robust and easier approach is to use call_with_suspended_errors().
2129 Wrap this around any function in which you might want errors 2129 Wrap this around any function in which you might want errors
2130 to not be errors. 2130 to not be errors.
2131 */ 2131 */
2132 2132
2133 Lisp_Object 2133 Lisp_Object
2134 call_with_suspended_errors (lisp_fn_t fun, volatile Lisp_Object retval, 2134 call_with_suspended_errors (lisp_fn_t fun, volatile Lisp_Object retval,
2135 Lisp_Object class, Error_behavior errb, 2135 Lisp_Object class, Error_Behavior errb,
2136 int nargs, ...) 2136 int nargs, ...)
2137 { 2137 {
2138 va_list vargs; 2138 va_list vargs;
2139 int speccount; 2139 int speccount;
2140 Lisp_Object kludgy_args[23]; 2140 Lisp_Object kludgy_args[23];
2222 refer to what sort of operation is being done (e.g. Qtoolbar, 2222 refer to what sort of operation is being done (e.g. Qtoolbar,
2223 Qresource, etc.). */ 2223 Qresource, etc.). */
2224 2224
2225 void 2225 void
2226 maybe_signal_error_1 (Lisp_Object sig, Lisp_Object data, Lisp_Object class, 2226 maybe_signal_error_1 (Lisp_Object sig, Lisp_Object data, Lisp_Object class,
2227 Error_behavior errb) 2227 Error_Behavior errb)
2228 { 2228 {
2229 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2229 if (ERRB_EQ (errb, ERROR_ME_NOT))
2230 return; 2230 return;
2231 else if (ERRB_EQ (errb, ERROR_ME_WARN)) 2231 else if (ERRB_EQ (errb, ERROR_ME_WARN))
2232 warn_when_safe_lispobj (class, Qwarning, Fcons (sig, data)); 2232 warn_when_safe_lispobj (class, Qwarning, Fcons (sig, data));
2238 /* Signal a continuable error or display a warning or do nothing, 2238 /* Signal a continuable error or display a warning or do nothing,
2239 according to ERRB. */ 2239 according to ERRB. */
2240 2240
2241 Lisp_Object 2241 Lisp_Object
2242 maybe_signal_continuable_error_1 (Lisp_Object sig, Lisp_Object data, 2242 maybe_signal_continuable_error_1 (Lisp_Object sig, Lisp_Object data,
2243 Lisp_Object class, Error_behavior errb) 2243 Lisp_Object class, Error_Behavior errb)
2244 { 2244 {
2245 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2245 if (ERRB_EQ (errb, ERROR_ME_NOT))
2246 return Qnil; 2246 return Qnil;
2247 else if (ERRB_EQ (errb, ERROR_ME_WARN)) 2247 else if (ERRB_EQ (errb, ERROR_ME_WARN))
2248 { 2248 {
2291 } 2291 }
2292 2292
2293 void 2293 void
2294 maybe_signal_error (Lisp_Object type, const char *reason, 2294 maybe_signal_error (Lisp_Object type, const char *reason,
2295 Lisp_Object frob, Lisp_Object class, 2295 Lisp_Object frob, Lisp_Object class,
2296 Error_behavior errb) 2296 Error_Behavior errb)
2297 { 2297 {
2298 /* Optimization: */ 2298 /* Optimization: */
2299 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2299 if (ERRB_EQ (errb, ERROR_ME_NOT))
2300 return; 2300 return;
2301 maybe_signal_error_1 (type, build_error_data (reason, frob), class, errb); 2301 maybe_signal_error_1 (type, build_error_data (reason, frob), class, errb);
2309 } 2309 }
2310 2310
2311 Lisp_Object 2311 Lisp_Object
2312 maybe_signal_continuable_error (Lisp_Object type, const char *reason, 2312 maybe_signal_continuable_error (Lisp_Object type, const char *reason,
2313 Lisp_Object frob, Lisp_Object class, 2313 Lisp_Object frob, Lisp_Object class,
2314 Error_behavior errb) 2314 Error_Behavior errb)
2315 { 2315 {
2316 /* Optimization: */ 2316 /* Optimization: */
2317 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2317 if (ERRB_EQ (errb, ERROR_ME_NOT))
2318 return Qnil; 2318 return Qnil;
2319 return maybe_signal_continuable_error_1 (type, 2319 return maybe_signal_continuable_error_1 (type,
2339 } 2339 }
2340 2340
2341 void 2341 void
2342 maybe_signal_error_2 (Lisp_Object type, const char *reason, 2342 maybe_signal_error_2 (Lisp_Object type, const char *reason,
2343 Lisp_Object frob0, Lisp_Object frob1, 2343 Lisp_Object frob0, Lisp_Object frob1,
2344 Lisp_Object class, Error_behavior errb) 2344 Lisp_Object class, Error_Behavior errb)
2345 { 2345 {
2346 /* Optimization: */ 2346 /* Optimization: */
2347 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2347 if (ERRB_EQ (errb, ERROR_ME_NOT))
2348 return; 2348 return;
2349 maybe_signal_error_1 (type, list3 (build_translated_string (reason), frob0, 2349 maybe_signal_error_1 (type, list3 (build_translated_string (reason), frob0,
2359 } 2359 }
2360 2360
2361 Lisp_Object 2361 Lisp_Object
2362 maybe_signal_continuable_error_2 (Lisp_Object type, const char *reason, 2362 maybe_signal_continuable_error_2 (Lisp_Object type, const char *reason,
2363 Lisp_Object frob0, Lisp_Object frob1, 2363 Lisp_Object frob0, Lisp_Object frob1,
2364 Lisp_Object class, Error_behavior errb) 2364 Lisp_Object class, Error_Behavior errb)
2365 { 2365 {
2366 /* Optimization: */ 2366 /* Optimization: */
2367 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2367 if (ERRB_EQ (errb, ERROR_ME_NOT))
2368 return Qnil; 2368 return Qnil;
2369 return maybe_signal_continuable_error_1 2369 return maybe_signal_continuable_error_1
2392 /* Fsignal GC-protects its args */ 2392 /* Fsignal GC-protects its args */
2393 signal_error (type, 0, obj); 2393 signal_error (type, 0, obj);
2394 } 2394 }
2395 2395
2396 void 2396 void
2397 maybe_signal_ferror (Lisp_Object type, Lisp_Object class, Error_behavior errb, 2397 maybe_signal_ferror (Lisp_Object type, Lisp_Object class, Error_Behavior errb,
2398 const char *fmt, ...) 2398 const char *fmt, ...)
2399 { 2399 {
2400 Lisp_Object obj; 2400 Lisp_Object obj;
2401 va_list args; 2401 va_list args;
2402 2402
2428 return Fsignal (type, list1 (obj)); 2428 return Fsignal (type, list1 (obj));
2429 } 2429 }
2430 2430
2431 Lisp_Object 2431 Lisp_Object
2432 maybe_signal_continuable_ferror (Lisp_Object type, Lisp_Object class, 2432 maybe_signal_continuable_ferror (Lisp_Object type, Lisp_Object class,
2433 Error_behavior errb, const char *fmt, ...) 2433 Error_Behavior errb, const char *fmt, ...)
2434 { 2434 {
2435 Lisp_Object obj; 2435 Lisp_Object obj;
2436 va_list args; 2436 va_list args;
2437 2437
2438 /* Optimization: */ 2438 /* Optimization: */
2479 signal_error_1 (type, Fcons (obj, build_error_data (0, frob))); 2479 signal_error_1 (type, Fcons (obj, build_error_data (0, frob)));
2480 } 2480 }
2481 2481
2482 void 2482 void
2483 maybe_signal_ferror_with_frob (Lisp_Object type, Lisp_Object frob, 2483 maybe_signal_ferror_with_frob (Lisp_Object type, Lisp_Object frob,
2484 Lisp_Object class, Error_behavior errb, 2484 Lisp_Object class, Error_Behavior errb,
2485 const char *fmt, ...) 2485 const char *fmt, ...)
2486 { 2486 {
2487 Lisp_Object obj; 2487 Lisp_Object obj;
2488 va_list args; 2488 va_list args;
2489 2489
2518 } 2518 }
2519 2519
2520 Lisp_Object 2520 Lisp_Object
2521 maybe_signal_continuable_ferror_with_frob (Lisp_Object type, Lisp_Object frob, 2521 maybe_signal_continuable_ferror_with_frob (Lisp_Object type, Lisp_Object frob,
2522 Lisp_Object class, 2522 Lisp_Object class,
2523 Error_behavior errb, 2523 Error_Behavior errb,
2524 const char *fmt, ...) 2524 const char *fmt, ...)
2525 { 2525 {
2526 Lisp_Object obj; 2526 Lisp_Object obj;
2527 va_list args; 2527 va_list args;
2528 2528
2614 signal_error_2 (Qsyntax_error, reason, frob1, frob2); 2614 signal_error_2 (Qsyntax_error, reason, frob1, frob2);
2615 } 2615 }
2616 2616
2617 void 2617 void
2618 maybe_syntax_error (const char *reason, Lisp_Object frob, 2618 maybe_syntax_error (const char *reason, Lisp_Object frob,
2619 Lisp_Object class, Error_behavior errb) 2619 Lisp_Object class, Error_Behavior errb)
2620 { 2620 {
2621 maybe_signal_error (Qsyntax_error, reason, frob, class, errb); 2621 maybe_signal_error (Qsyntax_error, reason, frob, class, errb);
2622 } 2622 }
2623 2623
2624 DOESNT_RETURN 2624 DOESNT_RETURN
2633 signal_error_2 (Qstructure_formation_error, reason, frob1, frob2); 2633 signal_error_2 (Qstructure_formation_error, reason, frob1, frob2);
2634 } 2634 }
2635 2635
2636 void 2636 void
2637 maybe_sferror (const char *reason, Lisp_Object frob, 2637 maybe_sferror (const char *reason, Lisp_Object frob,
2638 Lisp_Object class, Error_behavior errb) 2638 Lisp_Object class, Error_Behavior errb)
2639 { 2639 {
2640 maybe_signal_error (Qstructure_formation_error, reason, frob, class, errb); 2640 maybe_signal_error (Qstructure_formation_error, reason, frob, class, errb);
2641 } 2641 }
2642 2642
2643 DOESNT_RETURN 2643 DOESNT_RETURN
2652 signal_error_2 (Qinvalid_argument, reason, frob1, frob2); 2652 signal_error_2 (Qinvalid_argument, reason, frob1, frob2);
2653 } 2653 }
2654 2654
2655 void 2655 void
2656 maybe_invalid_argument (const char *reason, Lisp_Object frob, 2656 maybe_invalid_argument (const char *reason, Lisp_Object frob,
2657 Lisp_Object class, Error_behavior errb) 2657 Lisp_Object class, Error_Behavior errb)
2658 { 2658 {
2659 maybe_signal_error (Qinvalid_argument, reason, frob, class, errb); 2659 maybe_signal_error (Qinvalid_argument, reason, frob, class, errb);
2660 } 2660 }
2661 2661
2662 DOESNT_RETURN 2662 DOESNT_RETURN
2671 signal_error_2 (Qinvalid_constant, reason, frob1, frob2); 2671 signal_error_2 (Qinvalid_constant, reason, frob1, frob2);
2672 } 2672 }
2673 2673
2674 void 2674 void
2675 maybe_invalid_constant (const char *reason, Lisp_Object frob, 2675 maybe_invalid_constant (const char *reason, Lisp_Object frob,
2676 Lisp_Object class, Error_behavior errb) 2676 Lisp_Object class, Error_Behavior errb)
2677 { 2677 {
2678 maybe_signal_error (Qinvalid_constant, reason, frob, class, errb); 2678 maybe_signal_error (Qinvalid_constant, reason, frob, class, errb);
2679 } 2679 }
2680 2680
2681 DOESNT_RETURN 2681 DOESNT_RETURN
2690 signal_error_2 (Qinvalid_operation, reason, frob1, frob2); 2690 signal_error_2 (Qinvalid_operation, reason, frob1, frob2);
2691 } 2691 }
2692 2692
2693 void 2693 void
2694 maybe_invalid_operation (const char *reason, Lisp_Object frob, 2694 maybe_invalid_operation (const char *reason, Lisp_Object frob,
2695 Lisp_Object class, Error_behavior errb) 2695 Lisp_Object class, Error_Behavior errb)
2696 { 2696 {
2697 maybe_signal_error (Qinvalid_operation, reason, frob, class, errb); 2697 maybe_signal_error (Qinvalid_operation, reason, frob, class, errb);
2698 } 2698 }
2699 2699
2700 DOESNT_RETURN 2700 DOESNT_RETURN
2709 signal_error_2 (Qinvalid_change, reason, frob1, frob2); 2709 signal_error_2 (Qinvalid_change, reason, frob1, frob2);
2710 } 2710 }
2711 2711
2712 void 2712 void
2713 maybe_invalid_change (const char *reason, Lisp_Object frob, 2713 maybe_invalid_change (const char *reason, Lisp_Object frob,
2714 Lisp_Object class, Error_behavior errb) 2714 Lisp_Object class, Error_Behavior errb)
2715 { 2715 {
2716 maybe_signal_error (Qinvalid_change, reason, frob, class, errb); 2716 maybe_signal_error (Qinvalid_change, reason, frob, class, errb);
2717 } 2717 }
2718 2718
2719 DOESNT_RETURN 2719 DOESNT_RETURN
2728 signal_error_2 (Qinvalid_state, reason, frob1, frob2); 2728 signal_error_2 (Qinvalid_state, reason, frob1, frob2);
2729 } 2729 }
2730 2730
2731 void 2731 void
2732 maybe_invalid_state (const char *reason, Lisp_Object frob, 2732 maybe_invalid_state (const char *reason, Lisp_Object frob,
2733 Lisp_Object class, Error_behavior errb) 2733 Lisp_Object class, Error_Behavior errb)
2734 { 2734 {
2735 maybe_signal_error (Qinvalid_state, reason, frob, class, errb); 2735 maybe_signal_error (Qinvalid_state, reason, frob, class, errb);
2736 } 2736 }
2737 2737
2738 DOESNT_RETURN 2738 DOESNT_RETURN