comparison src/eval.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 576fb035e263
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
1 /* Evaluator for XEmacs Lisp interpreter. 1 /* Evaluator for XEmacs Lisp interpreter.
2 Copyright (C) 1985-1987, 1992-1994 Free Software Foundation, Inc. 2 Copyright (C) 1985-1987, 1992-1994 Free Software Foundation, Inc.
3 Copyright (C) 1995 Sun Microsystems, Inc. 3 Copyright (C) 1995 Sun Microsystems, Inc.
4 Copyright (C) 2000 Ben Wing.
4 5
5 This file is part of XEmacs. 6 This file is part of XEmacs.
6 7
7 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
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
146 /* Non-nil means we're going down, so we better not run any hooks
147 or do other non-essential stuff. */
148 int preparing_for_armageddon;
149
150 /* Non-nil means record all fset's and provide's, to be undone 147 /* Non-nil means record all fset's and provide's, to be undone
151 if the file being autoloaded is not fully loaded. 148 if the file being autoloaded is not fully loaded.
152 They are recorded by being consed onto the front of Vautoload_queue: 149 They are recorded by being consed onto the front of Vautoload_queue:
153 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */ 150 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */
154 Lisp_Object Vautoload_queue; 151 Lisp_Object Vautoload_queue;
265 in. 262 in.
266 */ 263 */
267 static Lisp_Object Vcondition_handlers; 264 static Lisp_Object Vcondition_handlers;
268 265
269 266
270 #if 0 /* no longer used */ 267 #define DEFEND_AGAINST_THROW_RECURSION
268
269 #ifdef DEFEND_AGAINST_THROW_RECURSION
271 /* Used for error catching purposes by throw_or_bomb_out */ 270 /* Used for error catching purposes by throw_or_bomb_out */
272 static int throw_level; 271 static int throw_level;
273 #endif /* unused */ 272 #endif
273
274 #ifdef ERROR_CHECK_TYPECHECK
275 void check_error_state_sanity (void);
276 #endif
274 277
275 278
276 /************************************************************************/ 279 /************************************************************************/
277 /* The subr object type */ 280 /* The subr object type */
278 /************************************************************************/ 281 /************************************************************************/
279 282
280 static void 283 static void
281 print_subr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 284 print_subr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
282 { 285 {
283 Lisp_Subr *subr = XSUBR (obj); 286 Lisp_Subr *subr = XSUBR (obj);
284 CONST char *header = 287 const char *header =
285 (subr->max_args == UNEVALLED) ? "#<special-form " : "#<subr "; 288 (subr->max_args == UNEVALLED) ? "#<special-form " : "#<subr ";
286 CONST char *name = subr_name (subr); 289 const char *name = subr_name (subr);
287 CONST char *trailer = subr->prompt ? " (interactive)>" : ">"; 290 const char *trailer = subr->prompt ? " (interactive)>" : ">";
288 291
289 if (print_readably) 292 if (print_readably)
290 error ("printing unreadable object %s%s%s", header, name, trailer); 293 error ("printing unreadable object %s%s%s", header, name, trailer);
291 294
292 write_c_string (header, printcharfun); 295 write_c_string (header, printcharfun);
298 { XD_DOC_STRING, offsetof (Lisp_Subr, doc) }, 301 { XD_DOC_STRING, offsetof (Lisp_Subr, doc) },
299 { XD_END } 302 { XD_END }
300 }; 303 };
301 304
302 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("subr", subr, 305 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("subr", subr,
303 this_one_is_unmarkable, print_subr, 0, 0, 0, 306 0, print_subr, 0, 0, 0,
304 subr_description, 307 subr_description,
305 Lisp_Subr); 308 Lisp_Subr);
306 309
307 /************************************************************************/ 310 /************************************************************************/
308 /* Entering the debugger */ 311 /* Entering the debugger */
557 specbind (Qdebug_on_error, Qnil); 560 specbind (Qdebug_on_error, Qnil);
558 specbind (Qstack_trace_on_error, Qnil); 561 specbind (Qstack_trace_on_error, Qnil);
559 specbind (Qdebug_on_signal, Qnil); 562 specbind (Qdebug_on_signal, Qnil);
560 specbind (Qstack_trace_on_signal, Qnil); 563 specbind (Qstack_trace_on_signal, Qnil);
561 564
562 internal_with_output_to_temp_buffer (build_string ("*Backtrace*"), 565 if (!noninteractive)
563 backtrace_259, 566 internal_with_output_to_temp_buffer (build_string ("*Backtrace*"),
564 Qnil, 567 backtrace_259,
565 Qnil); 568 Qnil,
569 Qnil);
570 else /* in batch mode, we want this going to stderr. */
571 backtrace_259 (Qnil);
566 unbind_to (speccount, Qnil); 572 unbind_to (speccount, Qnil);
567 *stack_trace_displayed = 1; 573 *stack_trace_displayed = 1;
568 } 574 }
569 575
570 if (!entering_debugger && !*debugger_entered && !signal_vars_only 576 if (!entering_debugger && !*debugger_entered && !signal_vars_only
589 specbind (Qdebug_on_error, Qnil); 595 specbind (Qdebug_on_error, Qnil);
590 specbind (Qstack_trace_on_error, Qnil); 596 specbind (Qstack_trace_on_error, Qnil);
591 specbind (Qdebug_on_signal, Qnil); 597 specbind (Qdebug_on_signal, Qnil);
592 specbind (Qstack_trace_on_signal, Qnil); 598 specbind (Qstack_trace_on_signal, Qnil);
593 599
594 internal_with_output_to_temp_buffer (build_string ("*Backtrace*"), 600 if (!noninteractive)
595 backtrace_259, 601 internal_with_output_to_temp_buffer (build_string ("*Backtrace*"),
596 Qnil, 602 backtrace_259,
597 Qnil); 603 Qnil,
604 Qnil);
605 else /* in batch mode, we want this going to stderr. */
606 backtrace_259 (Qnil);
598 unbind_to (speccount, Qnil); 607 unbind_to (speccount, Qnil);
599 *stack_trace_displayed = 1; 608 *stack_trace_displayed = 1;
600 } 609 }
601 610
602 if (!entering_debugger && !*debugger_entered 611 if (!entering_debugger && !*debugger_entered
633 If all args return nil, return nil. 642 If all args return nil, return nil.
634 */ 643 */
635 (args)) 644 (args))
636 { 645 {
637 /* This function can GC */ 646 /* This function can GC */
638 REGISTER Lisp_Object arg, val; 647 REGISTER Lisp_Object val;
639 648
640 LIST_LOOP_2 (arg, args) 649 LIST_LOOP_2 (arg, args)
641 { 650 {
642 if (!NILP (val = Feval (arg))) 651 if (!NILP (val = Feval (arg)))
643 return val; 652 return val;
652 If no arg yields nil, return the last arg's value. 661 If no arg yields nil, return the last arg's value.
653 */ 662 */
654 (args)) 663 (args))
655 { 664 {
656 /* This function can GC */ 665 /* This function can GC */
657 REGISTER Lisp_Object arg, val = Qt; 666 REGISTER Lisp_Object val = Qt;
658 667
659 LIST_LOOP_2 (arg, args) 668 LIST_LOOP_2 (arg, args)
660 { 669 {
661 if (NILP (val = Feval (arg))) 670 if (NILP (val = Feval (arg)))
662 return val; 671 return val;
728 CONDITION's value if non-nil is returned from the cond-form. 737 CONDITION's value if non-nil is returned from the cond-form.
729 */ 738 */
730 (args)) 739 (args))
731 { 740 {
732 /* This function can GC */ 741 /* This function can GC */
733 REGISTER Lisp_Object val, clause; 742 REGISTER Lisp_Object val;
734 743
735 LIST_LOOP_2 (clause, args) 744 LIST_LOOP_2 (clause, args)
736 { 745 {
737 CHECK_CONS (clause); 746 CHECK_CONS (clause);
738 if (!NILP (val = Feval (XCAR (clause)))) 747 if (!NILP (val = Feval (XCAR (clause))))
754 */ 763 */
755 (args)) 764 (args))
756 { 765 {
757 /* This function can GC */ 766 /* This function can GC */
758 /* Caller must provide a true list in ARGS */ 767 /* Caller must provide a true list in ARGS */
759 REGISTER Lisp_Object form, val = Qnil; 768 REGISTER Lisp_Object val = Qnil;
760 struct gcpro gcpro1; 769 struct gcpro gcpro1;
761 770
762 GCPRO1 (args); 771 GCPRO1 (args);
763 772
764 { 773 {
780 whose values are discarded. 789 whose values are discarded.
781 */ 790 */
782 (args)) 791 (args))
783 { 792 {
784 /* This function can GC */ 793 /* This function can GC */
785 REGISTER Lisp_Object val, form; 794 REGISTER Lisp_Object val;
786 struct gcpro gcpro1; 795 struct gcpro gcpro1;
787 796
788 val = Feval (XCAR (args)); 797 val = Feval (XCAR (args));
789 798
790 GCPRO1 (val); 799 GCPRO1 (val);
805 whose values are discarded. 814 whose values are discarded.
806 */ 815 */
807 (args)) 816 (args))
808 { 817 {
809 /* This function can GC */ 818 /* This function can GC */
810 REGISTER Lisp_Object val, form, tail; 819 REGISTER Lisp_Object val;
811 struct gcpro gcpro1; 820 struct gcpro gcpro1;
812 821
813 Feval (XCAR (args)); 822 Feval (XCAR (args));
814 args = XCDR (args); 823 args = XCDR (args);
815 val = Feval (XCAR (args)); 824 val = Feval (XCAR (args));
816 args = XCDR (args); 825 args = XCDR (args);
817 826
818 GCPRO1 (val); 827 GCPRO1 (val);
819 828
820 LIST_LOOP_3 (form, args, tail) 829 {
821 Feval (form); 830 LIST_LOOP_2 (form, args)
831 Feval (form);
832 }
822 833
823 UNGCPRO; 834 UNGCPRO;
824 return val; 835 return val;
825 } 836 }
826 837
832 Each VALUEFORM can refer to the symbols already bound by this VARLIST. 843 Each VALUEFORM can refer to the symbols already bound by this VARLIST.
833 */ 844 */
834 (args)) 845 (args))
835 { 846 {
836 /* This function can GC */ 847 /* This function can GC */
837 Lisp_Object var, tail;
838 Lisp_Object varlist = XCAR (args); 848 Lisp_Object varlist = XCAR (args);
839 Lisp_Object body = XCDR (args); 849 Lisp_Object body = XCDR (args);
840 int speccount = specpdl_depth(); 850 int speccount = specpdl_depth();
841 851
842 EXTERNAL_LIST_LOOP_3 (var, varlist, tail) 852 EXTERNAL_LIST_LOOP_3 (var, varlist, tail)
873 All the VALUEFORMs are evalled before any symbols are bound. 883 All the VALUEFORMs are evalled before any symbols are bound.
874 */ 884 */
875 (args)) 885 (args))
876 { 886 {
877 /* This function can GC */ 887 /* This function can GC */
878 Lisp_Object var, tail;
879 Lisp_Object varlist = XCAR (args); 888 Lisp_Object varlist = XCAR (args);
880 Lisp_Object body = XCDR (args); 889 Lisp_Object body = XCDR (args);
881 int speccount = specpdl_depth(); 890 int speccount = specpdl_depth();
882 Lisp_Object *temps; 891 Lisp_Object *temps;
883 int idx; 892 int idx;
893 /* Compute the values and store them in `temps' */ 902 /* Compute the values and store them in `temps' */
894 GCPRO1 (*temps); 903 GCPRO1 (*temps);
895 gcpro1.nvars = 0; 904 gcpro1.nvars = 0;
896 905
897 idx = 0; 906 idx = 0;
898 LIST_LOOP_3 (var, varlist, tail) 907 {
899 { 908 LIST_LOOP_2 (var, varlist)
900 Lisp_Object *value = &temps[idx++]; 909 {
901 if (SYMBOLP (var)) 910 Lisp_Object *value = &temps[idx++];
902 *value = Qnil; 911 if (SYMBOLP (var))
903 else 912 *value = Qnil;
904 { 913 else
905 Lisp_Object tem; 914 {
906 CHECK_CONS (var); 915 Lisp_Object tem;
907 tem = XCDR (var); 916 CHECK_CONS (var);
908 if (NILP (tem)) 917 tem = XCDR (var);
909 *value = Qnil; 918 if (NILP (tem))
910 else 919 *value = Qnil;
911 { 920 else
912 CHECK_CONS (tem); 921 {
913 *value = Feval (XCAR (tem)); 922 CHECK_CONS (tem);
914 gcpro1.nvars = idx; 923 *value = Feval (XCAR (tem));
915 924 gcpro1.nvars = idx;
916 if (!NILP (XCDR (tem))) 925
917 signal_simple_error 926 if (!NILP (XCDR (tem)))
918 ("`let' bindings can have only one value-form", var); 927 signal_simple_error
919 } 928 ("`let' bindings can have only one value-form", var);
920 } 929 }
921 } 930 }
931 }
932 }
922 933
923 idx = 0; 934 idx = 0;
924 LIST_LOOP_3 (var, varlist, tail) 935 {
925 { 936 LIST_LOOP_2 (var, varlist)
926 specbind (SYMBOLP (var) ? var : XCAR (var), temps[idx++]); 937 {
927 } 938 specbind (SYMBOLP (var) ? var : XCAR (var), temps[idx++]);
939 }
940 }
928 941
929 UNGCPRO; 942 UNGCPRO;
930 943
931 return unbind_to (speccount, Fprogn (body)); 944 return unbind_to (speccount, Fprogn (body));
932 } 945 }
1053 void.) 1066 void.)
1054 If SYMBOL is buffer-local, its default value is what is set; 1067 If SYMBOL is buffer-local, its default value is what is set;
1055 buffer-local values are not affected. 1068 buffer-local values are not affected.
1056 INITVALUE and DOCSTRING are optional. 1069 INITVALUE and DOCSTRING are optional.
1057 If DOCSTRING starts with *, this variable is identified as a user option. 1070 If DOCSTRING starts with *, this variable is identified as a user option.
1058 This means that M-x set-variable and M-x edit-options recognize it. 1071 This means that M-x set-variable recognizes it.
1059 If INITVALUE is missing, SYMBOL's value is not set. 1072 If INITVALUE is missing, SYMBOL's value is not set.
1060 1073
1061 In lisp-interaction-mode defvar is treated as defconst. 1074 In lisp-interaction-mode defvar is treated as defconst.
1062 */ 1075 */
1063 (args)) 1076 (args))
1103 Always sets the value of SYMBOL to the result of evalling INITVALUE. 1116 Always sets the value of SYMBOL to the result of evalling INITVALUE.
1104 If SYMBOL is buffer-local, its default value is what is set; 1117 If SYMBOL is buffer-local, its default value is what is set;
1105 buffer-local values are not affected. 1118 buffer-local values are not affected.
1106 DOCSTRING is optional. 1119 DOCSTRING is optional.
1107 If DOCSTRING starts with *, this variable is identified as a user option. 1120 If DOCSTRING starts with *, this variable is identified as a user option.
1108 This means that M-x set-variable and M-x edit-options recognize it. 1121 This means that M-x set-variable recognizes it.
1109 1122
1110 Note: do not use `defconst' for user options in libraries that are not 1123 Note: do not use `defconst' for user options in libraries that are not
1111 normally loaded, since it is useful for users to be able to specify 1124 normally loaded, since it is useful for users to be able to specify
1112 their own values for such variables before loading the library. 1125 their own values for such variables before loading the library.
1113 Since `defconst' unconditionally assigns the variable, 1126 Since `defconst' unconditionally assigns the variable,
1171 Return result of expanding macros at top level of FORM. 1184 Return result of expanding macros at top level of FORM.
1172 If FORM is not a macro call, it is returned unchanged. 1185 If FORM is not a macro call, it is returned unchanged.
1173 Otherwise, the macro is expanded and the expansion is considered 1186 Otherwise, the macro is expanded and the expansion is considered
1174 in place of FORM. When a non-macro-call results, it is returned. 1187 in place of FORM. When a non-macro-call results, it is returned.
1175 1188
1176 The second optional arg ENVIRONMENT species an environment of macro 1189 The second optional arg ENVIRONMENT specifies an environment of macro
1177 definitions to shadow the loaded ones for use in file byte-compilation. 1190 definitions to shadow the loaded ones for use in file byte-compilation.
1178 */ 1191 */
1179 (form, env)) 1192 (form, environment))
1180 { 1193 {
1181 /* This function can GC */ 1194 /* This function can GC */
1182 /* With cleanups from Hallvard Furuseth. */ 1195 /* With cleanups from Hallvard Furuseth. */
1183 REGISTER Lisp_Object expander, sym, def, tem; 1196 REGISTER Lisp_Object expander, sym, def, tem;
1184 1197
1195 until we get a symbol that is not an alias. */ 1208 until we get a symbol that is not an alias. */
1196 while (SYMBOLP (def)) 1209 while (SYMBOLP (def))
1197 { 1210 {
1198 QUIT; 1211 QUIT;
1199 sym = def; 1212 sym = def;
1200 tem = Fassq (sym, env); 1213 tem = Fassq (sym, environment);
1201 if (NILP (tem)) 1214 if (NILP (tem))
1202 { 1215 {
1203 def = XSYMBOL (sym)->function; 1216 def = XSYMBOL (sym)->function;
1204 if (!UNBOUNDP (def)) 1217 if (!UNBOUNDP (def))
1205 continue; 1218 continue;
1206 } 1219 }
1207 break; 1220 break;
1208 } 1221 }
1209 /* Right now TEM is the result from SYM in ENV, 1222 /* Right now TEM is the result from SYM in ENVIRONMENT,
1210 and if TEM is nil then DEF is SYM's function definition. */ 1223 and if TEM is nil then DEF is SYM's function definition. */
1211 if (NILP (tem)) 1224 if (NILP (tem))
1212 { 1225 {
1213 /* SYM is not mentioned in ENV. 1226 /* SYM is not mentioned in ENVIRONMENT.
1214 Look at its function definition. */ 1227 Look at its function definition. */
1215 if (UNBOUNDP (def) 1228 if (UNBOUNDP (def)
1216 || !CONSP (def)) 1229 || !CONSP (def))
1217 /* Not defined or definition not suitable */ 1230 /* Not defined or definition not suitable */
1218 break; 1231 break;
1302 return c.val; 1315 return c.val;
1303 } 1316 }
1304 c.val = (*func) (arg); 1317 c.val = (*func) (arg);
1305 if (threw) *threw = 0; 1318 if (threw) *threw = 0;
1306 catchlist = c.next; 1319 catchlist = c.next;
1320 #ifdef ERROR_CHECK_TYPECHECK
1321 check_error_state_sanity ();
1322 #endif
1307 return c.val; 1323 return c.val;
1308 } 1324 }
1309 1325
1310 1326
1311 /* Unwind the specbind, catch, and handler stacks back to CATCH, and 1327 /* Unwind the specbind, catch, and handler stacks back to CATCH, and
1358 /* Unwind the specpdl stack, and then restore the proper set of 1374 /* Unwind the specpdl stack, and then restore the proper set of
1359 handlers. */ 1375 handlers. */
1360 unbind_to (catchlist->pdlcount, Qnil); 1376 unbind_to (catchlist->pdlcount, Qnil);
1361 handlerlist = catchlist->handlerlist; 1377 handlerlist = catchlist->handlerlist;
1362 catchlist = catchlist->next; 1378 catchlist = catchlist->next;
1379 #ifdef ERROR_CHECK_TYPECHECK
1380 check_error_state_sanity ();
1381 #endif
1363 } 1382 }
1364 while (! last_time); 1383 while (! last_time);
1365 #else /* Actual XEmacs code */ 1384 #else /* Actual XEmacs code */
1366 /* Unwind the specpdl stack */ 1385 /* Unwind the specpdl stack */
1367 unbind_to (c->pdlcount, Qnil); 1386 unbind_to (c->pdlcount, Qnil);
1368 catchlist = c->next; 1387 catchlist = c->next;
1388 #ifdef ERROR_CHECK_TYPECHECK
1389 check_error_state_sanity ();
1390 #endif
1369 #endif 1391 #endif
1370 1392
1371 gcprolist = c->gcpro; 1393 gcprolist = c->gcpro;
1372 backtrace_list = c->backlist; 1394 backtrace_list = c->backlist;
1373 lisp_eval_depth = c->lisp_eval_depth; 1395 lisp_eval_depth = c->lisp_eval_depth;
1374 1396
1375 #if 0 /* no longer used */ 1397 #ifdef DEFEND_AGAINST_THROW_RECURSION
1376 throw_level = 0; 1398 throw_level = 0;
1377 #endif 1399 #endif
1378 LONGJMP (c->jmp, 1); 1400 LONGJMP (c->jmp, 1);
1379 } 1401 }
1380 1402
1381 static DOESNT_RETURN 1403 static DOESNT_RETURN
1382 throw_or_bomb_out (Lisp_Object tag, Lisp_Object val, int bomb_out_p, 1404 throw_or_bomb_out (Lisp_Object tag, Lisp_Object val, int bomb_out_p,
1383 Lisp_Object sig, Lisp_Object data) 1405 Lisp_Object sig, Lisp_Object data)
1384 { 1406 {
1385 #if 0 1407 #ifdef DEFEND_AGAINST_THROW_RECURSION
1386 /* die if we recurse more than is reasonable */ 1408 /* die if we recurse more than is reasonable */
1387 if (++throw_level > 20) 1409 if (++throw_level > 20)
1388 abort(); 1410 abort();
1389 #endif 1411 #endif
1390 1412
1633 ungcpro, restoring catchlist and condition_handlers are actually 1655 ungcpro, restoring catchlist and condition_handlers are actually
1634 redundant since unbind_to now restores them. But it looks funny not to 1656 redundant since unbind_to now restores them. But it looks funny not to
1635 have this code here, and it doesn't cost anything, so I'm leaving it.*/ 1657 have this code here, and it doesn't cost anything, so I'm leaving it.*/
1636 UNGCPRO; 1658 UNGCPRO;
1637 catchlist = c.next; 1659 catchlist = c.next;
1660 #ifdef ERROR_CHECK_TYPECHECK
1661 check_error_state_sanity ();
1662 #endif
1638 Vcondition_handlers = XCDR (c.tag); 1663 Vcondition_handlers = XCDR (c.tag);
1639 1664
1640 return unbind_to (speccount, c.val); 1665 return unbind_to (speccount, c.val);
1641 } 1666 }
1642 1667
1673 than a single list of arguments. */ 1698 than a single list of arguments. */
1674 Lisp_Object 1699 Lisp_Object
1675 condition_case_3 (Lisp_Object bodyform, Lisp_Object var, Lisp_Object handlers) 1700 condition_case_3 (Lisp_Object bodyform, Lisp_Object var, Lisp_Object handlers)
1676 { 1701 {
1677 /* This function can GC */ 1702 /* This function can GC */
1678 Lisp_Object handler;
1679
1680 EXTERNAL_LIST_LOOP_2 (handler, handlers) 1703 EXTERNAL_LIST_LOOP_2 (handler, handlers)
1681 { 1704 {
1682 if (NILP (handler)) 1705 if (NILP (handler))
1683 ; 1706 ;
1684 else if (CONSP (handler)) 1707 else if (CONSP (handler))
1687 /* CONDITIONS must a condition name or a list of condition names */ 1710 /* CONDITIONS must a condition name or a list of condition names */
1688 if (SYMBOLP (conditions)) 1711 if (SYMBOLP (conditions))
1689 ; 1712 ;
1690 else 1713 else
1691 { 1714 {
1692 Lisp_Object condition;
1693 EXTERNAL_LIST_LOOP_2 (condition, conditions) 1715 EXTERNAL_LIST_LOOP_2 (condition, conditions)
1694 if (!SYMBOLP (condition)) 1716 if (!SYMBOLP (condition))
1695 goto invalid_condition_handler; 1717 goto invalid_condition_handler;
1696 } 1718 }
1697 } 1719 }
1849 1871
1850 if (!initialized) 1872 if (!initialized)
1851 { 1873 {
1852 /* who knows how much has been initialized? Safest bet is 1874 /* who knows how much has been initialized? Safest bet is
1853 just to bomb out immediately. */ 1875 just to bomb out immediately. */
1876 /* let's not use stderr_out() here, because that does a bunch of
1877 things that might not be safe yet. */
1854 fprintf (stderr, "Error before initialization is complete!\n"); 1878 fprintf (stderr, "Error before initialization is complete!\n");
1855 abort (); 1879 abort ();
1856 } 1880 }
1857 1881
1858 if (gc_in_progress || in_display) 1882 if (gc_in_progress || in_display)
2034 signal_error (Lisp_Object sig, Lisp_Object data) 2058 signal_error (Lisp_Object sig, Lisp_Object data)
2035 { 2059 {
2036 for (;;) 2060 for (;;)
2037 Fsignal (sig, data); 2061 Fsignal (sig, data);
2038 } 2062 }
2063 #ifdef ERROR_CHECK_TYPECHECK
2064 void
2065 check_error_state_sanity (void)
2066 {
2067 struct catchtag *c;
2068 int found_error_tag = 0;
2069
2070 for (c = catchlist; c; c = c->next)
2071 {
2072 if (EQ (c->tag, Qunbound_suspended_errors_tag))
2073 {
2074 found_error_tag = 1;
2075 break;
2076 }
2077 }
2078
2079 assert (found_error_tag || NILP (Vcurrent_error_state));
2080 }
2081 #endif
2082
2083 static Lisp_Object
2084 restore_current_warning_class (Lisp_Object warning_class)
2085 {
2086 Vcurrent_warning_class = warning_class;
2087 return Qnil;
2088 }
2089
2090 static Lisp_Object
2091 restore_current_error_state (Lisp_Object error_state)
2092 {
2093 Vcurrent_error_state = error_state;
2094 return Qnil;
2095 }
2039 2096
2040 static Lisp_Object 2097 static Lisp_Object
2041 call_with_suspended_errors_1 (Lisp_Object opaque_arg) 2098 call_with_suspended_errors_1 (Lisp_Object opaque_arg)
2042 { 2099 {
2043 Lisp_Object val; 2100 Lisp_Object val;
2044 Lisp_Object *kludgy_args = (Lisp_Object *) get_opaque_ptr (opaque_arg); 2101 Lisp_Object *kludgy_args = (Lisp_Object *) get_opaque_ptr (opaque_arg);
2102 Lisp_Object no_error = kludgy_args[2];
2103 int speccount = specpdl_depth ();
2104
2105 if (!EQ (Vcurrent_error_state, no_error))
2106 {
2107 record_unwind_protect (restore_current_error_state,
2108 Vcurrent_error_state);
2109 Vcurrent_error_state = no_error;
2110 }
2045 PRIMITIVE_FUNCALL (val, get_opaque_ptr (kludgy_args[0]), 2111 PRIMITIVE_FUNCALL (val, get_opaque_ptr (kludgy_args[0]),
2046 kludgy_args + 2, XINT (kludgy_args[1])); 2112 kludgy_args + 3, XINT (kludgy_args[1]));
2047 return val; 2113 return unbind_to (speccount, val);
2048 }
2049
2050 static Lisp_Object
2051 restore_current_warning_class (Lisp_Object warning_class)
2052 {
2053 Vcurrent_warning_class = warning_class;
2054 return Qnil;
2055 }
2056
2057 static Lisp_Object
2058 restore_current_error_state (Lisp_Object error_state)
2059 {
2060 Vcurrent_error_state = error_state;
2061 return Qnil;
2062 } 2114 }
2063 2115
2064 /* Many functions would like to do one of three things if an error 2116 /* Many functions would like to do one of three things if an error
2065 occurs: 2117 occurs:
2066 2118
2081 Lisp_Object class, Error_behavior errb, 2133 Lisp_Object class, Error_behavior errb,
2082 int nargs, ...) 2134 int nargs, ...)
2083 { 2135 {
2084 va_list vargs; 2136 va_list vargs;
2085 int speccount; 2137 int speccount;
2086 Lisp_Object kludgy_args[22]; 2138 Lisp_Object kludgy_args[23];
2087 Lisp_Object *args = kludgy_args + 2; 2139 Lisp_Object *args = kludgy_args + 3;
2088 int i; 2140 int i;
2089 Lisp_Object no_error; 2141 Lisp_Object no_error;
2090 2142
2091 assert (SYMBOLP (class)); /* sanity-check */ 2143 assert (SYMBOLP (class)); /* sanity-check */
2092 assert (!NILP (class)); 2144 assert (!NILP (class));
2124 Lisp_Object val; 2176 Lisp_Object val;
2125 PRIMITIVE_FUNCALL (val, fun, args, nargs); 2177 PRIMITIVE_FUNCALL (val, fun, args, nargs);
2126 return val; 2178 return val;
2127 } 2179 }
2128 2180
2129 speccount = specpdl_depth(); 2181 speccount = specpdl_depth ();
2130 if (NILP (class) || NILP (Vcurrent_warning_class)) 2182 if (NILP (class) || NILP (Vcurrent_warning_class))
2131 { 2183 {
2132 /* If we're currently calling for no warnings, then make it so. 2184 /* If we're currently calling for no warnings, then make it so.
2133 If we're currently calling for warnings and we weren't 2185 If we're currently calling for warnings and we weren't
2134 previously, then set our warning class; otherwise, leave 2186 previously, then set our warning class; otherwise, leave
2135 the existing one alone. */ 2187 the existing one alone. */
2136 record_unwind_protect (restore_current_warning_class, 2188 record_unwind_protect (restore_current_warning_class,
2137 Vcurrent_warning_class); 2189 Vcurrent_warning_class);
2138 Vcurrent_warning_class = class; 2190 Vcurrent_warning_class = class;
2139 } 2191 }
2140 if (!EQ (Vcurrent_error_state, no_error))
2141 {
2142 record_unwind_protect (restore_current_error_state,
2143 Vcurrent_error_state);
2144 Vcurrent_error_state = no_error;
2145 }
2146 2192
2147 { 2193 {
2148 int threw; 2194 int threw;
2149 Lisp_Object the_retval; 2195 Lisp_Object the_retval;
2150 Lisp_Object opaque1 = make_opaque_ptr (kludgy_args); 2196 Lisp_Object opaque1 = make_opaque_ptr (kludgy_args);
2152 struct gcpro gcpro1, gcpro2; 2198 struct gcpro gcpro1, gcpro2;
2153 2199
2154 GCPRO2 (opaque1, opaque2); 2200 GCPRO2 (opaque1, opaque2);
2155 kludgy_args[0] = opaque2; 2201 kludgy_args[0] = opaque2;
2156 kludgy_args[1] = make_int (nargs); 2202 kludgy_args[1] = make_int (nargs);
2203 kludgy_args[2] = no_error;
2157 the_retval = internal_catch (Qunbound_suspended_errors_tag, 2204 the_retval = internal_catch (Qunbound_suspended_errors_tag,
2158 call_with_suspended_errors_1, 2205 call_with_suspended_errors_1,
2159 opaque1, &threw); 2206 opaque1, &threw);
2160 free_opaque_ptr (opaque1); 2207 free_opaque_ptr (opaque1);
2161 free_opaque_ptr (opaque2); 2208 free_opaque_ptr (opaque2);
2206 2253
2207 2254
2208 /****************** Error functions class 2 ******************/ 2255 /****************** Error functions class 2 ******************/
2209 2256
2210 /* Class 2: Printf-like functions that signal an error. 2257 /* Class 2: Printf-like functions that signal an error.
2211 These functions signal an error of type Qerror, whose data 2258 These functions signal an error of a specified type, whose data
2212 is a single string, created using the arguments. */ 2259 is a single string, created using the arguments. */
2213 2260
2214 /* dump an error message; called like printf */ 2261 /* dump an error message; called like printf */
2215 2262
2216 DOESNT_RETURN 2263 DOESNT_RETURN
2217 error (CONST char *fmt, ...) 2264 type_error (Lisp_Object type, const char *fmt, ...)
2218 { 2265 {
2219 Lisp_Object obj; 2266 Lisp_Object obj;
2220 va_list args; 2267 va_list args;
2221 2268
2222 va_start (args, fmt); 2269 va_start (args, fmt);
2223 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2270 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2224 args); 2271 args);
2225 va_end (args); 2272 va_end (args);
2226 2273
2227 /* Fsignal GC-protects its args */ 2274 /* Fsignal GC-protects its args */
2228 signal_error (Qerror, list1 (obj)); 2275 signal_error (type, list1 (obj));
2229 } 2276 }
2230 2277
2231 void 2278 void
2232 maybe_error (Lisp_Object class, Error_behavior errb, CONST char *fmt, ...) 2279 maybe_type_error (Lisp_Object type, Lisp_Object class, Error_behavior errb,
2280 const char *fmt, ...)
2233 { 2281 {
2234 Lisp_Object obj; 2282 Lisp_Object obj;
2235 va_list args; 2283 va_list args;
2236 2284
2237 /* Optimization: */ 2285 /* Optimization: */
2238 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2286 if (ERRB_EQ (errb, ERROR_ME_NOT))
2239 return; 2287 return;
2240 2288
2241 va_start (args, fmt); 2289 va_start (args, fmt);
2242 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2290 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2243 args); 2291 args);
2244 va_end (args); 2292 va_end (args);
2245 2293
2246 /* Fsignal GC-protects its args */ 2294 /* Fsignal GC-protects its args */
2247 maybe_signal_error (Qerror, list1 (obj), class, errb); 2295 maybe_signal_error (type, list1 (obj), class, errb);
2248 } 2296 }
2249 2297
2250 Lisp_Object 2298 Lisp_Object
2251 continuable_error (CONST char *fmt, ...) 2299 continuable_type_error (Lisp_Object type, const char *fmt, ...)
2252 { 2300 {
2253 Lisp_Object obj; 2301 Lisp_Object obj;
2254 va_list args; 2302 va_list args;
2255 2303
2256 va_start (args, fmt); 2304 va_start (args, fmt);
2257 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2305 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2258 args); 2306 args);
2259 va_end (args); 2307 va_end (args);
2260 2308
2261 /* Fsignal GC-protects its args */ 2309 /* Fsignal GC-protects its args */
2262 return Fsignal (Qerror, list1 (obj)); 2310 return Fsignal (type, list1 (obj));
2263 } 2311 }
2264 2312
2265 Lisp_Object 2313 Lisp_Object
2266 maybe_continuable_error (Lisp_Object class, Error_behavior errb, 2314 maybe_continuable_type_error (Lisp_Object type, Lisp_Object class,
2267 CONST char *fmt, ...) 2315 Error_behavior errb, const char *fmt, ...)
2268 { 2316 {
2269 Lisp_Object obj; 2317 Lisp_Object obj;
2270 va_list args; 2318 va_list args;
2271 2319
2272 /* Optimization: */ 2320 /* Optimization: */
2273 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2321 if (ERRB_EQ (errb, ERROR_ME_NOT))
2274 return Qnil; 2322 return Qnil;
2275 2323
2276 va_start (args, fmt); 2324 va_start (args, fmt);
2277 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2325 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2278 args); 2326 args);
2279 va_end (args); 2327 va_end (args);
2280 2328
2281 /* Fsignal GC-protects its args */ 2329 /* Fsignal GC-protects its args */
2282 return maybe_signal_continuable_error (Qerror, list1 (obj), class, errb); 2330 return maybe_signal_continuable_error (type, list1 (obj), class, errb);
2283 } 2331 }
2284 2332
2285 2333
2286 /****************** Error functions class 3 ******************/ 2334 /****************** Error functions class 3 ******************/
2287 2335
2288 /* Class 3: Signal an error with a string and an associated object. 2336 /* Class 3: Signal an error with a string and an associated object.
2337 These functions signal an error of a specified type, whose data
2338 is two objects, a string and a related Lisp object (usually the object
2339 where the error is occurring). */
2340
2341 DOESNT_RETURN
2342 signal_type_error (Lisp_Object type, const char *reason, Lisp_Object frob)
2343 {
2344 if (UNBOUNDP (frob))
2345 signal_error (type, list1 (build_translated_string (reason)));
2346 else
2347 signal_error (type, list2 (build_translated_string (reason), frob));
2348 }
2349
2350 void
2351 maybe_signal_type_error (Lisp_Object type, const char *reason,
2352 Lisp_Object frob, Lisp_Object class,
2353 Error_behavior errb)
2354 {
2355 /* Optimization: */
2356 if (ERRB_EQ (errb, ERROR_ME_NOT))
2357 return;
2358 maybe_signal_error (type, list2 (build_translated_string (reason), frob),
2359 class, errb);
2360 }
2361
2362 Lisp_Object
2363 signal_type_continuable_error (Lisp_Object type, const char *reason,
2364 Lisp_Object frob)
2365 {
2366 return Fsignal (type, list2 (build_translated_string (reason), frob));
2367 }
2368
2369 Lisp_Object
2370 maybe_signal_type_continuable_error (Lisp_Object type, const char *reason,
2371 Lisp_Object frob, Lisp_Object class,
2372 Error_behavior errb)
2373 {
2374 /* Optimization: */
2375 if (ERRB_EQ (errb, ERROR_ME_NOT))
2376 return Qnil;
2377 return maybe_signal_continuable_error
2378 (type, list2 (build_translated_string (reason),
2379 frob), class, errb);
2380 }
2381
2382
2383 /****************** Error functions class 4 ******************/
2384
2385 /* Class 4: Printf-like functions that signal an error.
2386 These functions signal an error of a specified type, whose data
2387 is a two objects, a string (created using the arguments) and a
2388 Lisp object.
2389 */
2390
2391 DOESNT_RETURN
2392 type_error_with_frob (Lisp_Object type, Lisp_Object frob, const char *fmt, ...)
2393 {
2394 Lisp_Object obj;
2395 va_list args;
2396
2397 va_start (args, fmt);
2398 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2399 args);
2400 va_end (args);
2401
2402 /* Fsignal GC-protects its args */
2403 signal_error (type, list2 (obj, frob));
2404 }
2405
2406 void
2407 maybe_type_error_with_frob (Lisp_Object type, Lisp_Object frob,
2408 Lisp_Object class, Error_behavior errb,
2409 const char *fmt, ...)
2410 {
2411 Lisp_Object obj;
2412 va_list args;
2413
2414 /* Optimization: */
2415 if (ERRB_EQ (errb, ERROR_ME_NOT))
2416 return;
2417
2418 va_start (args, fmt);
2419 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2420 args);
2421 va_end (args);
2422
2423 /* Fsignal GC-protects its args */
2424 maybe_signal_error (type, list2 (obj, frob), class, errb);
2425 }
2426
2427 Lisp_Object
2428 continuable_type_error_with_frob (Lisp_Object type, Lisp_Object frob,
2429 const char *fmt, ...)
2430 {
2431 Lisp_Object obj;
2432 va_list args;
2433
2434 va_start (args, fmt);
2435 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2436 args);
2437 va_end (args);
2438
2439 /* Fsignal GC-protects its args */
2440 return Fsignal (type, list2 (obj, frob));
2441 }
2442
2443 Lisp_Object
2444 maybe_continuable_type_error_with_frob (Lisp_Object type, Lisp_Object frob,
2445 Lisp_Object class, Error_behavior errb,
2446 const char *fmt, ...)
2447 {
2448 Lisp_Object obj;
2449 va_list args;
2450
2451 /* Optimization: */
2452 if (ERRB_EQ (errb, ERROR_ME_NOT))
2453 return Qnil;
2454
2455 va_start (args, fmt);
2456 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2457 args);
2458 va_end (args);
2459
2460 /* Fsignal GC-protects its args */
2461 return maybe_signal_continuable_error (type, list2 (obj, frob),
2462 class, errb);
2463 }
2464
2465
2466 /****************** Error functions class 5 ******************/
2467
2468 /* Class 5: Signal an error with a string and two associated objects.
2469 These functions signal an error of a specified type, whose data
2470 is three objects, a string and two related Lisp objects. */
2471
2472 DOESNT_RETURN
2473 signal_type_error_2 (Lisp_Object type, const char *reason,
2474 Lisp_Object frob0, Lisp_Object frob1)
2475 {
2476 signal_error (type, list3 (build_translated_string (reason), frob0,
2477 frob1));
2478 }
2479
2480 void
2481 maybe_signal_type_error_2 (Lisp_Object type, const char *reason,
2482 Lisp_Object frob0, Lisp_Object frob1,
2483 Lisp_Object class, Error_behavior errb)
2484 {
2485 /* Optimization: */
2486 if (ERRB_EQ (errb, ERROR_ME_NOT))
2487 return;
2488 maybe_signal_error (type, list3 (build_translated_string (reason), frob0,
2489 frob1), class, errb);
2490 }
2491
2492
2493 Lisp_Object
2494 signal_type_continuable_error_2 (Lisp_Object type, const char *reason,
2495 Lisp_Object frob0, Lisp_Object frob1)
2496 {
2497 return Fsignal (type, list3 (build_translated_string (reason), frob0,
2498 frob1));
2499 }
2500
2501 Lisp_Object
2502 maybe_signal_type_continuable_error_2 (Lisp_Object type, const char *reason,
2503 Lisp_Object frob0, Lisp_Object frob1,
2504 Lisp_Object class, Error_behavior errb)
2505 {
2506 /* Optimization: */
2507 if (ERRB_EQ (errb, ERROR_ME_NOT))
2508 return Qnil;
2509 return maybe_signal_continuable_error
2510 (type, list3 (build_translated_string (reason), frob0,
2511 frob1),
2512 class, errb);
2513 }
2514
2515
2516 /****************** Simple error functions class 2 ******************/
2517
2518 /* Simple class 2: Printf-like functions that signal an error.
2519 These functions signal an error of type Qerror, whose data
2520 is a single string, created using the arguments. */
2521
2522 /* dump an error message; called like printf */
2523
2524 DOESNT_RETURN
2525 error (const char *fmt, ...)
2526 {
2527 Lisp_Object obj;
2528 va_list args;
2529
2530 va_start (args, fmt);
2531 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2532 args);
2533 va_end (args);
2534
2535 /* Fsignal GC-protects its args */
2536 signal_error (Qerror, list1 (obj));
2537 }
2538
2539 void
2540 maybe_error (Lisp_Object class, Error_behavior errb, const char *fmt, ...)
2541 {
2542 Lisp_Object obj;
2543 va_list args;
2544
2545 /* Optimization: */
2546 if (ERRB_EQ (errb, ERROR_ME_NOT))
2547 return;
2548
2549 va_start (args, fmt);
2550 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2551 args);
2552 va_end (args);
2553
2554 /* Fsignal GC-protects its args */
2555 maybe_signal_error (Qerror, list1 (obj), class, errb);
2556 }
2557
2558 Lisp_Object
2559 continuable_error (const char *fmt, ...)
2560 {
2561 Lisp_Object obj;
2562 va_list args;
2563
2564 va_start (args, fmt);
2565 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2566 args);
2567 va_end (args);
2568
2569 /* Fsignal GC-protects its args */
2570 return Fsignal (Qerror, list1 (obj));
2571 }
2572
2573 Lisp_Object
2574 maybe_continuable_error (Lisp_Object class, Error_behavior errb,
2575 const char *fmt, ...)
2576 {
2577 Lisp_Object obj;
2578 va_list args;
2579
2580 /* Optimization: */
2581 if (ERRB_EQ (errb, ERROR_ME_NOT))
2582 return Qnil;
2583
2584 va_start (args, fmt);
2585 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2586 args);
2587 va_end (args);
2588
2589 /* Fsignal GC-protects its args */
2590 return maybe_signal_continuable_error (Qerror, list1 (obj), class, errb);
2591 }
2592
2593
2594 /****************** Simple error functions class 3 ******************/
2595
2596 /* Simple class 3: Signal an error with a string and an associated object.
2289 These functions signal an error of type Qerror, whose data 2597 These functions signal an error of type Qerror, whose data
2290 is two objects, a string and a related Lisp object (usually the object 2598 is two objects, a string and a related Lisp object (usually the object
2291 where the error is occurring). */ 2599 where the error is occurring). */
2292 2600
2293 DOESNT_RETURN 2601 DOESNT_RETURN
2294 signal_simple_error (CONST char *reason, Lisp_Object frob) 2602 signal_simple_error (const char *reason, Lisp_Object frob)
2295 { 2603 {
2296 signal_error (Qerror, list2 (build_translated_string (reason), frob)); 2604 signal_error (Qerror, list2 (build_translated_string (reason), frob));
2297 } 2605 }
2298 2606
2299 void 2607 void
2300 maybe_signal_simple_error (CONST char *reason, Lisp_Object frob, 2608 maybe_signal_simple_error (const char *reason, Lisp_Object frob,
2301 Lisp_Object class, Error_behavior errb) 2609 Lisp_Object class, Error_behavior errb)
2302 { 2610 {
2303 /* Optimization: */ 2611 /* Optimization: */
2304 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2612 if (ERRB_EQ (errb, ERROR_ME_NOT))
2305 return; 2613 return;
2306 maybe_signal_error (Qerror, list2 (build_translated_string (reason), frob), 2614 maybe_signal_error (Qerror, list2 (build_translated_string (reason), frob),
2307 class, errb); 2615 class, errb);
2308 } 2616 }
2309 2617
2310 Lisp_Object 2618 Lisp_Object
2311 signal_simple_continuable_error (CONST char *reason, Lisp_Object frob) 2619 signal_simple_continuable_error (const char *reason, Lisp_Object frob)
2312 { 2620 {
2313 return Fsignal (Qerror, list2 (build_translated_string (reason), frob)); 2621 return Fsignal (Qerror, list2 (build_translated_string (reason), frob));
2314 } 2622 }
2315 2623
2316 Lisp_Object 2624 Lisp_Object
2317 maybe_signal_simple_continuable_error (CONST char *reason, Lisp_Object frob, 2625 maybe_signal_simple_continuable_error (const char *reason, Lisp_Object frob,
2318 Lisp_Object class, Error_behavior errb) 2626 Lisp_Object class, Error_behavior errb)
2319 { 2627 {
2320 /* Optimization: */ 2628 /* Optimization: */
2321 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2629 if (ERRB_EQ (errb, ERROR_ME_NOT))
2322 return Qnil; 2630 return Qnil;
2324 (Qerror, list2 (build_translated_string (reason), 2632 (Qerror, list2 (build_translated_string (reason),
2325 frob), class, errb); 2633 frob), class, errb);
2326 } 2634 }
2327 2635
2328 2636
2329 /****************** Error functions class 4 ******************/ 2637 /****************** Simple error functions class 4 ******************/
2330 2638
2331 /* Class 4: Printf-like functions that signal an error. 2639 /* Simple class 4: Printf-like functions that signal an error.
2332 These functions signal an error of type Qerror, whose data 2640 These functions signal an error of type Qerror, whose data
2333 is a two objects, a string (created using the arguments) and a 2641 is a two objects, a string (created using the arguments) and a
2334 Lisp object. 2642 Lisp object.
2335 */ 2643 */
2336 2644
2337 DOESNT_RETURN 2645 DOESNT_RETURN
2338 error_with_frob (Lisp_Object frob, CONST char *fmt, ...) 2646 error_with_frob (Lisp_Object frob, const char *fmt, ...)
2339 { 2647 {
2340 Lisp_Object obj; 2648 Lisp_Object obj;
2341 va_list args; 2649 va_list args;
2342 2650
2343 va_start (args, fmt); 2651 va_start (args, fmt);
2344 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2652 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2345 args); 2653 args);
2346 va_end (args); 2654 va_end (args);
2347 2655
2348 /* Fsignal GC-protects its args */ 2656 /* Fsignal GC-protects its args */
2349 signal_error (Qerror, list2 (obj, frob)); 2657 signal_error (Qerror, list2 (obj, frob));
2350 } 2658 }
2351 2659
2352 void 2660 void
2353 maybe_error_with_frob (Lisp_Object frob, Lisp_Object class, 2661 maybe_error_with_frob (Lisp_Object frob, Lisp_Object class,
2354 Error_behavior errb, CONST char *fmt, ...) 2662 Error_behavior errb, const char *fmt, ...)
2355 { 2663 {
2356 Lisp_Object obj; 2664 Lisp_Object obj;
2357 va_list args; 2665 va_list args;
2358 2666
2359 /* Optimization: */ 2667 /* Optimization: */
2360 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2668 if (ERRB_EQ (errb, ERROR_ME_NOT))
2361 return; 2669 return;
2362 2670
2363 va_start (args, fmt); 2671 va_start (args, fmt);
2364 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2672 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2365 args); 2673 args);
2366 va_end (args); 2674 va_end (args);
2367 2675
2368 /* Fsignal GC-protects its args */ 2676 /* Fsignal GC-protects its args */
2369 maybe_signal_error (Qerror, list2 (obj, frob), class, errb); 2677 maybe_signal_error (Qerror, list2 (obj, frob), class, errb);
2370 } 2678 }
2371 2679
2372 Lisp_Object 2680 Lisp_Object
2373 continuable_error_with_frob (Lisp_Object frob, CONST char *fmt, ...) 2681 continuable_error_with_frob (Lisp_Object frob, const char *fmt, ...)
2374 { 2682 {
2375 Lisp_Object obj; 2683 Lisp_Object obj;
2376 va_list args; 2684 va_list args;
2377 2685
2378 va_start (args, fmt); 2686 va_start (args, fmt);
2379 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2687 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2380 args); 2688 args);
2381 va_end (args); 2689 va_end (args);
2382 2690
2383 /* Fsignal GC-protects its args */ 2691 /* Fsignal GC-protects its args */
2384 return Fsignal (Qerror, list2 (obj, frob)); 2692 return Fsignal (Qerror, list2 (obj, frob));
2385 } 2693 }
2386 2694
2387 Lisp_Object 2695 Lisp_Object
2388 maybe_continuable_error_with_frob (Lisp_Object frob, Lisp_Object class, 2696 maybe_continuable_error_with_frob (Lisp_Object frob, Lisp_Object class,
2389 Error_behavior errb, CONST char *fmt, ...) 2697 Error_behavior errb, const char *fmt, ...)
2390 { 2698 {
2391 Lisp_Object obj; 2699 Lisp_Object obj;
2392 va_list args; 2700 va_list args;
2393 2701
2394 /* Optimization: */ 2702 /* Optimization: */
2395 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2703 if (ERRB_EQ (errb, ERROR_ME_NOT))
2396 return Qnil; 2704 return Qnil;
2397 2705
2398 va_start (args, fmt); 2706 va_start (args, fmt);
2399 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), Qnil, -1, 2707 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
2400 args); 2708 args);
2401 va_end (args); 2709 va_end (args);
2402 2710
2403 /* Fsignal GC-protects its args */ 2711 /* Fsignal GC-protects its args */
2404 return maybe_signal_continuable_error (Qerror, list2 (obj, frob), 2712 return maybe_signal_continuable_error (Qerror, list2 (obj, frob),
2405 class, errb); 2713 class, errb);
2406 } 2714 }
2407 2715
2408 2716
2409 /****************** Error functions class 5 ******************/ 2717 /****************** Simple error functions class 5 ******************/
2410 2718
2411 /* Class 5: Signal an error with a string and two associated objects. 2719 /* Simple class 5: Signal an error with a string and two associated objects.
2412 These functions signal an error of type Qerror, whose data 2720 These functions signal an error of type Qerror, whose data
2413 is three objects, a string and two related Lisp objects. */ 2721 is three objects, a string and two related Lisp objects. */
2414 2722
2415 DOESNT_RETURN 2723 DOESNT_RETURN
2416 signal_simple_error_2 (CONST char *reason, 2724 signal_simple_error_2 (const char *reason,
2417 Lisp_Object frob0, Lisp_Object frob1) 2725 Lisp_Object frob0, Lisp_Object frob1)
2418 { 2726 {
2419 signal_error (Qerror, list3 (build_translated_string (reason), frob0, 2727 signal_error (Qerror, list3 (build_translated_string (reason), frob0,
2420 frob1)); 2728 frob1));
2421 } 2729 }
2422 2730
2423 void 2731 void
2424 maybe_signal_simple_error_2 (CONST char *reason, Lisp_Object frob0, 2732 maybe_signal_simple_error_2 (const char *reason, Lisp_Object frob0,
2425 Lisp_Object frob1, Lisp_Object class, 2733 Lisp_Object frob1, Lisp_Object class,
2426 Error_behavior errb) 2734 Error_behavior errb)
2427 { 2735 {
2428 /* Optimization: */ 2736 /* Optimization: */
2429 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2737 if (ERRB_EQ (errb, ERROR_ME_NOT))
2432 frob1), class, errb); 2740 frob1), class, errb);
2433 } 2741 }
2434 2742
2435 2743
2436 Lisp_Object 2744 Lisp_Object
2437 signal_simple_continuable_error_2 (CONST char *reason, Lisp_Object frob0, 2745 signal_simple_continuable_error_2 (const char *reason, Lisp_Object frob0,
2438 Lisp_Object frob1) 2746 Lisp_Object frob1)
2439 { 2747 {
2440 return Fsignal (Qerror, list3 (build_translated_string (reason), frob0, 2748 return Fsignal (Qerror, list3 (build_translated_string (reason), frob0,
2441 frob1)); 2749 frob1));
2442 } 2750 }
2443 2751
2444 Lisp_Object 2752 Lisp_Object
2445 maybe_signal_simple_continuable_error_2 (CONST char *reason, Lisp_Object frob0, 2753 maybe_signal_simple_continuable_error_2 (const char *reason, Lisp_Object frob0,
2446 Lisp_Object frob1, Lisp_Object class, 2754 Lisp_Object frob1, Lisp_Object class,
2447 Error_behavior errb) 2755 Error_behavior errb)
2448 { 2756 {
2449 /* Optimization: */ 2757 /* Optimization: */
2450 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2758 if (ERRB_EQ (errb, ERROR_ME_NOT))
2511 DOESNT_RETURN 2819 DOESNT_RETURN
2512 signal_circular_property_list_error (Lisp_Object list) 2820 signal_circular_property_list_error (Lisp_Object list)
2513 { 2821 {
2514 signal_error (Qcircular_property_list, list1 (list)); 2822 signal_error (Qcircular_property_list, list1 (list));
2515 } 2823 }
2824
2825 DOESNT_RETURN
2826 syntax_error (const char *reason, Lisp_Object frob)
2827 {
2828 signal_type_error (Qsyntax_error, reason, frob);
2829 }
2830
2831 DOESNT_RETURN
2832 syntax_error_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
2833 {
2834 signal_type_error_2 (Qsyntax_error, reason, frob1, frob2);
2835 }
2836
2837 DOESNT_RETURN
2838 invalid_argument (const char *reason, Lisp_Object frob)
2839 {
2840 signal_type_error (Qinvalid_argument, reason, frob);
2841 }
2842
2843 DOESNT_RETURN
2844 invalid_argument_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
2845 {
2846 signal_type_error_2 (Qinvalid_argument, reason, frob1, frob2);
2847 }
2848
2849 DOESNT_RETURN
2850 invalid_operation (const char *reason, Lisp_Object frob)
2851 {
2852 signal_type_error (Qinvalid_operation, reason, frob);
2853 }
2854
2855 DOESNT_RETURN
2856 invalid_operation_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
2857 {
2858 signal_type_error_2 (Qinvalid_operation, reason, frob1, frob2);
2859 }
2860
2861 DOESNT_RETURN
2862 invalid_change (const char *reason, Lisp_Object frob)
2863 {
2864 signal_type_error (Qinvalid_change, reason, frob);
2865 }
2866
2867 DOESNT_RETURN
2868 invalid_change_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
2869 {
2870 signal_type_error_2 (Qinvalid_change, reason, frob1, frob2);
2871 }
2872
2516 2873
2517 /************************************************************************/ 2874 /************************************************************************/
2518 /* User commands */ 2875 /* User commands */
2519 /************************************************************************/ 2876 /************************************************************************/
2520 2877
2829 /************************************************************************/ 3186 /************************************************************************/
2830 /* eval, funcall, apply */ 3187 /* eval, funcall, apply */
2831 /************************************************************************/ 3188 /************************************************************************/
2832 3189
2833 static Lisp_Object funcall_lambda (Lisp_Object fun, 3190 static Lisp_Object funcall_lambda (Lisp_Object fun,
2834 int nargs, Lisp_Object args[]); 3191 int nargs, Lisp_Object args[]);
2835 static int in_warnings; 3192 static int in_warnings;
2836 3193
2837 static Lisp_Object 3194 static Lisp_Object
2838 in_warnings_restore (Lisp_Object minimus) 3195 in_warnings_restore (Lisp_Object minimus)
2839 { 3196 {
2955 3312
2956 GCPRO1 (args[0]); 3313 GCPRO1 (args[0]);
2957 gcpro1.nvars = 0; 3314 gcpro1.nvars = 0;
2958 3315
2959 { 3316 {
2960 REGISTER Lisp_Object arg;
2961 LIST_LOOP_2 (arg, original_args) 3317 LIST_LOOP_2 (arg, original_args)
2962 { 3318 {
2963 *p++ = Feval (arg); 3319 *p++ = Feval (arg);
2964 gcpro1.nvars++; 3320 gcpro1.nvars++;
2965 } 3321 }
2985 3341
2986 GCPRO1 (args[0]); 3342 GCPRO1 (args[0]);
2987 gcpro1.nvars = 0; 3343 gcpro1.nvars = 0;
2988 3344
2989 { 3345 {
2990 REGISTER Lisp_Object arg;
2991 LIST_LOOP_2 (arg, original_args) 3346 LIST_LOOP_2 (arg, original_args)
2992 { 3347 {
2993 *p++ = Feval (arg); 3348 *p++ = Feval (arg);
2994 gcpro1.nvars++; 3349 gcpro1.nvars++;
2995 } 3350 }
3017 3372
3018 GCPRO1 (args[0]); 3373 GCPRO1 (args[0]);
3019 gcpro1.nvars = 0; 3374 gcpro1.nvars = 0;
3020 3375
3021 { 3376 {
3022 REGISTER Lisp_Object arg;
3023 LIST_LOOP_2 (arg, original_args) 3377 LIST_LOOP_2 (arg, original_args)
3024 { 3378 {
3025 *p++ = Feval (arg); 3379 *p++ = Feval (arg);
3026 gcpro1.nvars++; 3380 gcpro1.nvars++;
3027 } 3381 }
3062 3416
3063 GCPRO1 (args[0]); 3417 GCPRO1 (args[0]);
3064 gcpro1.nvars = 0; 3418 gcpro1.nvars = 0;
3065 3419
3066 { 3420 {
3067 REGISTER Lisp_Object arg;
3068 LIST_LOOP_2 (arg, original_args) 3421 LIST_LOOP_2 (arg, original_args)
3069 { 3422 {
3070 *p++ = Feval (arg); 3423 *p++ = Feval (arg);
3071 gcpro1.nvars++; 3424 gcpro1.nvars++;
3072 } 3425 }
3274 if (SYMBOLP (function)) 3627 if (SYMBOLP (function))
3275 function = indirect_function (function, 1); 3628 function = indirect_function (function, 1);
3276 3629
3277 if (SUBRP (function)) 3630 if (SUBRP (function))
3278 { 3631 {
3279 return function_min_args_p ? 3632 /* Using return with the ?: operator tickles a DEC CC compiler bug. */
3280 Fsubr_min_args (function): 3633 if (function_min_args_p)
3281 Fsubr_max_args (function); 3634 return Fsubr_min_args (function);
3635 else
3636 return Fsubr_max_args (function);
3282 } 3637 }
3283 else if (COMPILED_FUNCTIONP (function)) 3638 else if (COMPILED_FUNCTIONP (function))
3284 { 3639 {
3285 arglist = compiled_function_arglist (XCOMPILED_FUNCTION (function)); 3640 arglist = compiled_function_arglist (XCOMPILED_FUNCTION (function));
3286 } 3641 }
3293 function = XCDR (function); 3648 function = XCDR (function);
3294 goto retry; 3649 goto retry;
3295 } 3650 }
3296 else if (EQ (funcar, Qautoload)) 3651 else if (EQ (funcar, Qautoload))
3297 { 3652 {
3653 struct gcpro gcpro1;
3654
3655 GCPRO1 (function);
3298 do_autoload (function, orig_function); 3656 do_autoload (function, orig_function);
3657 UNGCPRO;
3658 function = orig_function;
3299 goto retry; 3659 goto retry;
3300 } 3660 }
3301 else if (EQ (funcar, Qlambda)) 3661 else if (EQ (funcar, Qlambda))
3302 { 3662 {
3303 arglist = Fcar (XCDR (function)); 3663 arglist = Fcar (XCDR (function));
3308 } 3668 }
3309 } 3669 }
3310 else 3670 else
3311 { 3671 {
3312 invalid_function: 3672 invalid_function:
3313 return signal_invalid_function_error (function); 3673 return signal_invalid_function_error (orig_function);
3314 } 3674 }
3315 3675
3316 { 3676 {
3317 int argcount = 0; 3677 int argcount = 0;
3318 Lisp_Object arg;
3319 3678
3320 EXTERNAL_LIST_LOOP_2 (arg, arglist) 3679 EXTERNAL_LIST_LOOP_2 (arg, arglist)
3321 { 3680 {
3322 if (EQ (arg, Qand_optional)) 3681 if (EQ (arg, Qand_optional))
3323 { 3682 {
3452 3811
3453 static Lisp_Object 3812 static Lisp_Object
3454 funcall_lambda (Lisp_Object fun, int nargs, Lisp_Object args[]) 3813 funcall_lambda (Lisp_Object fun, int nargs, Lisp_Object args[])
3455 { 3814 {
3456 /* This function can GC */ 3815 /* This function can GC */
3457 Lisp_Object symbol, arglist, body, tail; 3816 Lisp_Object arglist, body, tail;
3458 int speccount = specpdl_depth(); 3817 int speccount = specpdl_depth();
3459 REGISTER int i = 0; 3818 REGISTER int i = 0;
3460 3819
3461 tail = XCDR (fun); 3820 tail = XCDR (fun);
3462 3821
3467 body = XCDR (tail); 3826 body = XCDR (tail);
3468 3827
3469 { 3828 {
3470 int optional = 0, rest = 0; 3829 int optional = 0, rest = 0;
3471 3830
3472 EXTERNAL_LIST_LOOP_3 (symbol, arglist, tail) 3831 EXTERNAL_LIST_LOOP_2 (symbol, arglist)
3473 { 3832 {
3474 if (!SYMBOLP (symbol)) 3833 if (!SYMBOLP (symbol))
3475 goto invalid_function; 3834 goto invalid_function;
3476 if (EQ (symbol, Qand_rest)) 3835 if (EQ (symbol, Qand_rest))
3477 rest = 1; 3836 rest = 1;
4136 (with-output-to-string (display-error errordata)) 4495 (with-output-to-string (display-error errordata))
4137 but that stuff is all in Lisp currently. */ 4496 but that stuff is all in Lisp currently. */
4138 args[1] = errordata; 4497 args[1] = errordata;
4139 warn_when_safe_lispobj 4498 warn_when_safe_lispobj
4140 (Qerror, Qwarning, 4499 (Qerror, Qwarning,
4141 emacs_doprnt_string_lisp ((CONST Bufbyte *) "%s: %s", 4500 emacs_doprnt_string_lisp ((const Bufbyte *) "%s: %s",
4142 Qnil, -1, 2, args)); 4501 Qnil, -1, 2, args));
4143 } 4502 }
4144 return Qunbound; 4503 return Qunbound;
4145 } 4504 }
4146 4505
4179 { 4538 {
4180 return eval_in_buffer (XBUFFER (XCAR (cons)), XCDR (cons)); 4539 return eval_in_buffer (XBUFFER (XCAR (cons)), XCDR (cons));
4181 } 4540 }
4182 4541
4183 Lisp_Object 4542 Lisp_Object
4184 eval_in_buffer_trapping_errors (CONST char *warning_string, 4543 eval_in_buffer_trapping_errors (const char *warning_string,
4185 struct buffer *buf, Lisp_Object form) 4544 struct buffer *buf, Lisp_Object form)
4186 { 4545 {
4187 int speccount = specpdl_depth(); 4546 int speccount = specpdl_depth();
4188 Lisp_Object tem; 4547 Lisp_Object tem;
4189 Lisp_Object buffer; 4548 Lisp_Object buffer;
4219 run_hook (hook_symbol); 4578 run_hook (hook_symbol);
4220 return Qnil; 4579 return Qnil;
4221 } 4580 }
4222 4581
4223 Lisp_Object 4582 Lisp_Object
4224 run_hook_trapping_errors (CONST char *warning_string, Lisp_Object hook_symbol) 4583 run_hook_trapping_errors (const char *warning_string, Lisp_Object hook_symbol)
4225 { 4584 {
4226 int speccount; 4585 int speccount;
4227 Lisp_Object tem; 4586 Lisp_Object tem;
4228 Lisp_Object opaque; 4587 Lisp_Object opaque;
4229 struct gcpro gcpro1; 4588 struct gcpro gcpro1;
4252 4611
4253 /* Same as run_hook_trapping_errors() but also set the hook to nil 4612 /* Same as run_hook_trapping_errors() but also set the hook to nil
4254 if an error occurs. */ 4613 if an error occurs. */
4255 4614
4256 Lisp_Object 4615 Lisp_Object
4257 safe_run_hook_trapping_errors (CONST char *warning_string, 4616 safe_run_hook_trapping_errors (const char *warning_string,
4258 Lisp_Object hook_symbol, 4617 Lisp_Object hook_symbol,
4259 int allow_quit) 4618 int allow_quit)
4260 { 4619 {
4261 int speccount = specpdl_depth(); 4620 int speccount = specpdl_depth();
4262 Lisp_Object tem; 4621 Lisp_Object tem;
4298 /* This function can GC */ 4657 /* This function can GC */
4299 return call0 (function); 4658 return call0 (function);
4300 } 4659 }
4301 4660
4302 Lisp_Object 4661 Lisp_Object
4303 call0_trapping_errors (CONST char *warning_string, Lisp_Object function) 4662 call0_trapping_errors (const char *warning_string, Lisp_Object function)
4304 { 4663 {
4305 int speccount; 4664 int speccount;
4306 Lisp_Object tem; 4665 Lisp_Object tem;
4307 Lisp_Object opaque = Qnil; 4666 Lisp_Object opaque = Qnil;
4308 struct gcpro gcpro1, gcpro2; 4667 struct gcpro gcpro1, gcpro2;
4345 /* This function can GC */ 4704 /* This function can GC */
4346 return call2 (XCAR (cons), XCAR (XCDR (cons)), XCAR (XCDR (XCDR (cons)))); 4705 return call2 (XCAR (cons), XCAR (XCDR (cons)), XCAR (XCDR (XCDR (cons))));
4347 } 4706 }
4348 4707
4349 Lisp_Object 4708 Lisp_Object
4350 call1_trapping_errors (CONST char *warning_string, Lisp_Object function, 4709 call1_trapping_errors (const char *warning_string, Lisp_Object function,
4351 Lisp_Object object) 4710 Lisp_Object object)
4352 { 4711 {
4353 int speccount = specpdl_depth(); 4712 int speccount = specpdl_depth();
4354 Lisp_Object tem; 4713 Lisp_Object tem;
4355 Lisp_Object cons = Qnil; 4714 Lisp_Object cons = Qnil;
4382 /* gc_currently_forbidden = 0; */ 4741 /* gc_currently_forbidden = 0; */
4383 return unbind_to (speccount, tem); 4742 return unbind_to (speccount, tem);
4384 } 4743 }
4385 4744
4386 Lisp_Object 4745 Lisp_Object
4387 call2_trapping_errors (CONST char *warning_string, Lisp_Object function, 4746 call2_trapping_errors (const char *warning_string, Lisp_Object function,
4388 Lisp_Object object1, Lisp_Object object2) 4747 Lisp_Object object1, Lisp_Object object2)
4389 { 4748 {
4390 int speccount = specpdl_depth(); 4749 int speccount = specpdl_depth();
4391 Lisp_Object tem; 4750 Lisp_Object tem;
4392 Lisp_Object cons = Qnil; 4751 Lisp_Object cons = Qnil;
4596 void 4955 void
4597 unbind_to_hairy (int count) 4956 unbind_to_hairy (int count)
4598 { 4957 {
4599 int quitf; 4958 int quitf;
4600 4959
4960 ++specpdl_ptr;
4961 ++specpdl_depth_counter;
4962
4601 check_quit (); /* make Vquit_flag accurate */ 4963 check_quit (); /* make Vquit_flag accurate */
4602 quitf = !NILP (Vquit_flag); 4964 quitf = !NILP (Vquit_flag);
4603 Vquit_flag = Qnil; 4965 Vquit_flag = Qnil;
4604
4605 ++specpdl_ptr;
4606 ++specpdl_depth_counter;
4607 4966
4608 while (specpdl_depth_counter != count) 4967 while (specpdl_depth_counter != count)
4609 { 4968 {
4610 --specpdl_ptr; 4969 --specpdl_ptr;
4611 --specpdl_depth_counter; 4970 --specpdl_depth_counter;
4856 } 5215 }
4857 if (i != 0) write_c_string (" ", stream); 5216 if (i != 0) write_c_string (" ", stream);
4858 Fprin1 (backlist->args[i], stream); 5217 Fprin1 (backlist->args[i], stream);
4859 } 5218 }
4860 } 5219 }
5220 write_c_string (")\n", stream);
4861 } 5221 }
4862 write_c_string (")\n", stream);
4863 backlist = backlist->next; 5222 backlist = backlist->next;
4864 } 5223 }
4865 } 5224 }
4866 Vprint_level = old_level; 5225 Vprint_level = old_level;
4867 print_readably = old_pr; 5226 print_readably = old_pr;
4935 An alternative approach is to just pass some non-string type of 5294 An alternative approach is to just pass some non-string type of
4936 Lisp_Object to warn_when_safe_lispobj(); `prin1-to-string' will 5295 Lisp_Object to warn_when_safe_lispobj(); `prin1-to-string' will
4937 automatically be called when it is safe to do so. */ 5296 automatically be called when it is safe to do so. */
4938 5297
4939 void 5298 void
4940 warn_when_safe (Lisp_Object class, Lisp_Object level, CONST char *fmt, ...) 5299 warn_when_safe (Lisp_Object class, Lisp_Object level, const char *fmt, ...)
4941 { 5300 {
4942 Lisp_Object obj; 5301 Lisp_Object obj;
4943 va_list args; 5302 va_list args;
4944 5303
4945 va_start (args, fmt); 5304 va_start (args, fmt);
4946 obj = emacs_doprnt_string_va ((CONST Bufbyte *) GETTEXT (fmt), 5305 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt),
4947 Qnil, -1, args); 5306 Qnil, -1, args);
4948 va_end (args); 5307 va_end (args);
4949 5308
4950 warn_when_safe_lispobj (class, level, obj); 5309 warn_when_safe_lispobj (class, level, obj);
4951 } 5310 }
4958 /************************************************************************/ 5317 /************************************************************************/
4959 5318
4960 void 5319 void
4961 syms_of_eval (void) 5320 syms_of_eval (void)
4962 { 5321 {
5322 INIT_LRECORD_IMPLEMENTATION (subr);
5323
4963 defsymbol (&Qinhibit_quit, "inhibit-quit"); 5324 defsymbol (&Qinhibit_quit, "inhibit-quit");
4964 defsymbol (&Qautoload, "autoload"); 5325 defsymbol (&Qautoload, "autoload");
4965 defsymbol (&Qdebug_on_error, "debug-on-error"); 5326 defsymbol (&Qdebug_on_error, "debug-on-error");
4966 defsymbol (&Qstack_trace_on_error, "stack-trace-on-error"); 5327 defsymbol (&Qstack_trace_on_error, "stack-trace-on-error");
4967 defsymbol (&Qdebug_on_signal, "debug-on-signal"); 5328 defsymbol (&Qdebug_on_signal, "debug-on-signal");
5052 5413
5053 specpdl_size = 50; 5414 specpdl_size = 50;
5054 specpdl = xnew_array (struct specbinding, specpdl_size); 5415 specpdl = xnew_array (struct specbinding, specpdl_size);
5055 /* XEmacs change: increase these values. */ 5416 /* XEmacs change: increase these values. */
5056 max_specpdl_size = 3000; 5417 max_specpdl_size = 3000;
5057 max_lisp_eval_depth = 500; 5418 max_lisp_eval_depth = 1000;
5058 #if 0 /* no longer used */ 5419 #ifdef DEFEND_AGAINST_THROW_RECURSION
5059 throw_level = 0; 5420 throw_level = 0;
5060 #endif 5421 #endif
5061 } 5422 }
5062 5423
5063 void 5424 void