comparison src/eval.c @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents 623d57b7fbe8 2ade80e8c640
children 2a462149bd6a
comparison
equal deleted inserted replaced
5124:623d57b7fbe8 5125:b5df3737028a
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, 2001, 2002, 2003, 2004 Ben Wing. 4 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2010 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 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
9 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
424 424
425 static void 425 static void
426 print_subr (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag)) 426 print_subr (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag))
427 { 427 {
428 Lisp_Subr *subr = XSUBR (obj); 428 Lisp_Subr *subr = XSUBR (obj);
429 const CIbyte *header = 429 const Ascbyte *header =
430 (subr->max_args == UNEVALLED) ? "#<special-form " : "#<subr "; 430 (subr->max_args == UNEVALLED) ? "#<special-operator " : "#<subr ";
431 const CIbyte *name = subr_name (subr); 431 const Ascbyte *name = subr_name (subr);
432 const CIbyte *trailer = subr->prompt ? " (interactive)>" : ">"; 432 const Ascbyte *trailer = subr->prompt ? " (interactive)>" : ">";
433 433
434 if (print_readably) 434 if (print_readably)
435 printing_unreadable_object ("%s%s%s", header, name, trailer); 435 printing_unreadable_object ("%s%s%s", header, name, trailer);
436 436
437 write_c_string (printcharfun, header); 437 write_ascstring (printcharfun, header);
438 write_c_string (printcharfun, name); 438 write_ascstring (printcharfun, name);
439 write_c_string (printcharfun, trailer); 439 write_ascstring (printcharfun, trailer);
440 } 440 }
441 441
442 static const struct memory_description subr_description[] = { 442 static const struct memory_description subr_description[] = {
443 { XD_DOC_STRING, offsetof (Lisp_Subr, doc), 0, { 0 }, XD_FLAG_NO_KKCC }, 443 { XD_DOC_STRING, offsetof (Lisp_Subr, doc), 0, { 0 }, XD_FLAG_NO_KKCC },
444 { XD_END } 444 { XD_END }
735 specbind (Qstack_trace_on_error, Qnil); 735 specbind (Qstack_trace_on_error, Qnil);
736 specbind (Qdebug_on_signal, Qnil); 736 specbind (Qdebug_on_signal, Qnil);
737 specbind (Qstack_trace_on_signal, Qnil); 737 specbind (Qstack_trace_on_signal, Qnil);
738 738
739 if (!noninteractive) 739 if (!noninteractive)
740 internal_with_output_to_temp_buffer (build_string ("*Backtrace*"), 740 internal_with_output_to_temp_buffer (build_ascstring ("*Backtrace*"),
741 backtrace_259, 741 backtrace_259,
742 Qnil, 742 Qnil,
743 Qnil); 743 Qnil);
744 else /* in batch mode, we want this going to stderr. */ 744 else /* in batch mode, we want this going to stderr. */
745 backtrace_259 (Qnil); 745 backtrace_259 (Qnil);
777 specbind (Qstack_trace_on_error, Qnil); 777 specbind (Qstack_trace_on_error, Qnil);
778 specbind (Qdebug_on_signal, Qnil); 778 specbind (Qdebug_on_signal, Qnil);
779 specbind (Qstack_trace_on_signal, Qnil); 779 specbind (Qstack_trace_on_signal, Qnil);
780 780
781 if (!noninteractive) 781 if (!noninteractive)
782 internal_with_output_to_temp_buffer (build_string ("*Backtrace*"), 782 internal_with_output_to_temp_buffer (build_ascstring ("*Backtrace*"),
783 backtrace_259, 783 backtrace_259,
784 Qnil, 784 Qnil,
785 Qnil); 785 Qnil);
786 else /* in batch mode, we want this going to stderr. */ 786 else /* in batch mode, we want this going to stderr. */
787 backtrace_259 (Qnil); 787 backtrace_259 (Qnil);
820 820
821 /************************************************************************/ 821 /************************************************************************/
822 /* The basic special forms */ 822 /* The basic special forms */
823 /************************************************************************/ 823 /************************************************************************/
824 824
825 /* Except for Fprogn(), the basic special forms below are only called 825 /* Except for Fprogn(), the basic special operators below are only called
826 from interpreted code. The byte compiler turns them into bytecodes. */ 826 from interpreted code. The byte compiler turns them into bytecodes. */
827 827
828 DEFUN ("or", For, 0, UNEVALLED, 0, /* 828 DEFUN ("or", For, 0, UNEVALLED, 0, /*
829 Eval ARGS until one of them yields non-nil, then return that value. 829 Eval ARGS until one of them yields non-nil, then return that value.
830 The remaining ARGS are not evalled at all. 830 The remaining ARGS are not evalled at all.
2607 else if (ERRB_EQ (errb, ERROR_ME_DEBUG_WARN)) 2607 else if (ERRB_EQ (errb, ERROR_ME_DEBUG_WARN))
2608 warn_when_safe_lispobj (class_, Qdebug, Fcons (sig, data)); 2608 warn_when_safe_lispobj (class_, Qdebug, Fcons (sig, data));
2609 else if (ERRB_EQ (errb, ERROR_ME_WARN)) 2609 else if (ERRB_EQ (errb, ERROR_ME_WARN))
2610 warn_when_safe_lispobj (class_, Qwarning, Fcons (sig, data)); 2610 warn_when_safe_lispobj (class_, Qwarning, Fcons (sig, data));
2611 else 2611 else
2612 for (;;) 2612 signal_error_1 (sig, data);
2613 Fsignal (sig, data);
2614 } 2613 }
2615 2614
2616 /* Signal a continuable error or display a warning or do nothing, 2615 /* Signal a continuable error or display a warning or do nothing,
2617 according to ERRB. */ 2616 according to ERRB. */
2618 2617
2651 2650
2652 /* Out of REASON and FROB, return a list of elements suitable for passing 2651 /* Out of REASON and FROB, return a list of elements suitable for passing
2653 to signal_error_1(). */ 2652 to signal_error_1(). */
2654 2653
2655 Lisp_Object 2654 Lisp_Object
2656 build_error_data (const CIbyte *reason, Lisp_Object frob) 2655 build_error_data (const Ascbyte *reason, Lisp_Object frob)
2657 { 2656 {
2658 if (EQ (frob, Qunbound)) 2657 if (EQ (frob, Qunbound))
2659 frob = Qnil; 2658 frob = Qnil;
2660 else if (CONSP (frob) && EQ (XCAR (frob), Qunbound)) 2659 else if (CONSP (frob) && EQ (XCAR (frob), Qunbound))
2661 frob = XCDR (frob); 2660 frob = XCDR (frob);
2666 else 2665 else
2667 return Fcons (build_msg_string (reason), frob); 2666 return Fcons (build_msg_string (reason), frob);
2668 } 2667 }
2669 2668
2670 DOESNT_RETURN 2669 DOESNT_RETURN
2671 signal_error (Lisp_Object type, const CIbyte *reason, Lisp_Object frob) 2670 signal_error (Lisp_Object type, const Ascbyte *reason, Lisp_Object frob)
2672 { 2671 {
2673 signal_error_1 (type, build_error_data (reason, frob)); 2672 signal_error_1 (type, build_error_data (reason, frob));
2674 } 2673 }
2675 2674
2675 /* NOTE NOTE NOTE: If you feel you need signal_ierror() or something
2676 similar when reason is a non-ASCII message, you're probably doing
2677 something wrong. When you have an error message from an external
2678 source, you should put the error message as the first item in FROB and
2679 put a string in REASON indicating what you were doing when the error
2680 message occurred. Use signal_error_2() for such a case. */
2681
2676 void 2682 void
2677 maybe_signal_error (Lisp_Object type, const CIbyte *reason, 2683 maybe_signal_error (Lisp_Object type, const Ascbyte *reason,
2678 Lisp_Object frob, Lisp_Object class_, 2684 Lisp_Object frob, Lisp_Object class_,
2679 Error_Behavior errb) 2685 Error_Behavior errb)
2680 { 2686 {
2681 /* Optimization: */ 2687 /* Optimization: */
2682 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2688 if (ERRB_EQ (errb, ERROR_ME_NOT))
2683 return; 2689 return;
2684 maybe_signal_error_1 (type, build_error_data (reason, frob), class_, errb); 2690 maybe_signal_error_1 (type, build_error_data (reason, frob), class_, errb);
2685 } 2691 }
2686 2692
2687 Lisp_Object 2693 Lisp_Object
2688 signal_continuable_error (Lisp_Object type, const CIbyte *reason, 2694 signal_continuable_error (Lisp_Object type, const Ascbyte *reason,
2689 Lisp_Object frob) 2695 Lisp_Object frob)
2690 { 2696 {
2691 return Fsignal (type, build_error_data (reason, frob)); 2697 return Fsignal (type, build_error_data (reason, frob));
2692 } 2698 }
2693 2699
2694 Lisp_Object 2700 Lisp_Object
2695 maybe_signal_continuable_error (Lisp_Object type, const CIbyte *reason, 2701 maybe_signal_continuable_error (Lisp_Object type, const Ascbyte *reason,
2696 Lisp_Object frob, Lisp_Object class_, 2702 Lisp_Object frob, Lisp_Object class_,
2697 Error_Behavior errb) 2703 Error_Behavior errb)
2698 { 2704 {
2699 /* Optimization: */ 2705 /* Optimization: */
2700 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2706 if (ERRB_EQ (errb, ERROR_ME_NOT))
2712 is three objects, a string and two related Lisp objects. 2718 is three objects, a string and two related Lisp objects.
2713 (The equivalent could be accomplished using the class 2 functions, 2719 (The equivalent could be accomplished using the class 2 functions,
2714 but these are more convenient in this particular case.) */ 2720 but these are more convenient in this particular case.) */
2715 2721
2716 DOESNT_RETURN 2722 DOESNT_RETURN
2717 signal_error_2 (Lisp_Object type, const CIbyte *reason, 2723 signal_error_2 (Lisp_Object type, const Ascbyte *reason,
2718 Lisp_Object frob0, Lisp_Object frob1) 2724 Lisp_Object frob0, Lisp_Object frob1)
2719 { 2725 {
2720 signal_error_1 (type, list3 (build_msg_string (reason), frob0, 2726 signal_error_1 (type, list3 (build_msg_string (reason), frob0,
2721 frob1)); 2727 frob1));
2722 } 2728 }
2723 2729
2724 void 2730 void
2725 maybe_signal_error_2 (Lisp_Object type, const CIbyte *reason, 2731 maybe_signal_error_2 (Lisp_Object type, const Ascbyte *reason,
2726 Lisp_Object frob0, Lisp_Object frob1, 2732 Lisp_Object frob0, Lisp_Object frob1,
2727 Lisp_Object class_, Error_Behavior errb) 2733 Lisp_Object class_, Error_Behavior errb)
2728 { 2734 {
2729 /* Optimization: */ 2735 /* Optimization: */
2730 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2736 if (ERRB_EQ (errb, ERROR_ME_NOT))
2732 maybe_signal_error_1 (type, list3 (build_msg_string (reason), frob0, 2738 maybe_signal_error_1 (type, list3 (build_msg_string (reason), frob0,
2733 frob1), class_, errb); 2739 frob1), class_, errb);
2734 } 2740 }
2735 2741
2736 Lisp_Object 2742 Lisp_Object
2737 signal_continuable_error_2 (Lisp_Object type, const CIbyte *reason, 2743 signal_continuable_error_2 (Lisp_Object type, const Ascbyte *reason,
2738 Lisp_Object frob0, Lisp_Object frob1) 2744 Lisp_Object frob0, Lisp_Object frob1)
2739 { 2745 {
2740 return Fsignal (type, list3 (build_msg_string (reason), frob0, 2746 return Fsignal (type, list3 (build_msg_string (reason), frob0,
2741 frob1)); 2747 frob1));
2742 } 2748 }
2743 2749
2744 Lisp_Object 2750 Lisp_Object
2745 maybe_signal_continuable_error_2 (Lisp_Object type, const CIbyte *reason, 2751 maybe_signal_continuable_error_2 (Lisp_Object type, const Ascbyte *reason,
2746 Lisp_Object frob0, Lisp_Object frob1, 2752 Lisp_Object frob0, Lisp_Object frob1,
2747 Lisp_Object class_, Error_Behavior errb) 2753 Lisp_Object class_, Error_Behavior errb)
2748 { 2754 {
2749 /* Optimization: */ 2755 /* Optimization: */
2750 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2756 if (ERRB_EQ (errb, ERROR_ME_NOT))
2760 /* Class 4: Printf-like functions that signal an error. 2766 /* Class 4: Printf-like functions that signal an error.
2761 These functions signal an error of a specified type, whose data 2767 These functions signal an error of a specified type, whose data
2762 is a single string, created using the arguments. */ 2768 is a single string, created using the arguments. */
2763 2769
2764 DOESNT_RETURN 2770 DOESNT_RETURN
2765 signal_ferror (Lisp_Object type, const CIbyte *fmt, ...) 2771 signal_ferror (Lisp_Object type, const Ascbyte *fmt, ...)
2766 { 2772 {
2767 Lisp_Object obj; 2773 Lisp_Object obj;
2768 va_list args; 2774 va_list args;
2769 2775
2770 va_start (args, fmt); 2776 va_start (args, fmt);
2771 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2777 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2772 va_end (args); 2778 va_end (args);
2773 2779
2774 /* Fsignal GC-protects its args */ 2780 /* Fsignal GC-protects its args */
2775 signal_error (type, 0, obj); 2781 signal_error (type, 0, obj);
2776 } 2782 }
2777 2783
2778 void 2784 void
2779 maybe_signal_ferror (Lisp_Object type, Lisp_Object class_, Error_Behavior errb, 2785 maybe_signal_ferror (Lisp_Object type, Lisp_Object class_, Error_Behavior errb,
2780 const CIbyte *fmt, ...) 2786 const Ascbyte *fmt, ...)
2781 { 2787 {
2782 Lisp_Object obj; 2788 Lisp_Object obj;
2783 va_list args; 2789 va_list args;
2784 2790
2785 /* Optimization: */ 2791 /* Optimization: */
2786 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2792 if (ERRB_EQ (errb, ERROR_ME_NOT))
2787 return; 2793 return;
2788 2794
2789 va_start (args, fmt); 2795 va_start (args, fmt);
2790 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2796 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2791 va_end (args); 2797 va_end (args);
2792 2798
2793 /* Fsignal GC-protects its args */ 2799 /* Fsignal GC-protects its args */
2794 maybe_signal_error (type, 0, obj, class_, errb); 2800 maybe_signal_error (type, 0, obj, class_, errb);
2795 } 2801 }
2796 2802
2797 Lisp_Object 2803 Lisp_Object
2798 signal_continuable_ferror (Lisp_Object type, const CIbyte *fmt, ...) 2804 signal_continuable_ferror (Lisp_Object type, const Ascbyte *fmt, ...)
2799 { 2805 {
2800 Lisp_Object obj; 2806 Lisp_Object obj;
2801 va_list args; 2807 va_list args;
2802 2808
2803 va_start (args, fmt); 2809 va_start (args, fmt);
2804 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2810 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2805 va_end (args); 2811 va_end (args);
2806 2812
2807 /* Fsignal GC-protects its args */ 2813 /* Fsignal GC-protects its args */
2808 return Fsignal (type, list1 (obj)); 2814 return Fsignal (type, list1 (obj));
2809 } 2815 }
2810 2816
2811 Lisp_Object 2817 Lisp_Object
2812 maybe_signal_continuable_ferror (Lisp_Object type, Lisp_Object class_, 2818 maybe_signal_continuable_ferror (Lisp_Object type, Lisp_Object class_,
2813 Error_Behavior errb, const CIbyte *fmt, ...) 2819 Error_Behavior errb, const Ascbyte *fmt, ...)
2814 { 2820 {
2815 Lisp_Object obj; 2821 Lisp_Object obj;
2816 va_list args; 2822 va_list args;
2817 2823
2818 /* Optimization: */ 2824 /* Optimization: */
2819 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2825 if (ERRB_EQ (errb, ERROR_ME_NOT))
2820 return Qnil; 2826 return Qnil;
2821 2827
2822 va_start (args, fmt); 2828 va_start (args, fmt);
2823 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2829 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2824 va_end (args); 2830 va_end (args);
2825 2831
2826 /* Fsignal GC-protects its args */ 2832 /* Fsignal GC-protects its args */
2827 return maybe_signal_continuable_error (type, 0, obj, class_, errb); 2833 return maybe_signal_continuable_error (type, 0, obj, class_, errb);
2828 } 2834 }
2841 elements, the first of which is Qunbound), and these functions are 2847 elements, the first of which is Qunbound), and these functions are
2842 not commonly used. 2848 not commonly used.
2843 */ 2849 */
2844 2850
2845 DOESNT_RETURN 2851 DOESNT_RETURN
2846 signal_ferror_with_frob (Lisp_Object type, Lisp_Object frob, const CIbyte *fmt, 2852 signal_ferror_with_frob (Lisp_Object type, Lisp_Object frob, const Ascbyte *fmt,
2847 ...) 2853 ...)
2848 { 2854 {
2849 Lisp_Object obj; 2855 Lisp_Object obj;
2850 va_list args; 2856 va_list args;
2851 2857
2852 va_start (args, fmt); 2858 va_start (args, fmt);
2853 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2859 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2854 va_end (args); 2860 va_end (args);
2855 2861
2856 /* Fsignal GC-protects its args */ 2862 /* Fsignal GC-protects its args */
2857 signal_error_1 (type, Fcons (obj, build_error_data (0, frob))); 2863 signal_error_1 (type, Fcons (obj, build_error_data (0, frob)));
2858 } 2864 }
2859 2865
2860 void 2866 void
2861 maybe_signal_ferror_with_frob (Lisp_Object type, Lisp_Object frob, 2867 maybe_signal_ferror_with_frob (Lisp_Object type, Lisp_Object frob,
2862 Lisp_Object class_, Error_Behavior errb, 2868 Lisp_Object class_, Error_Behavior errb,
2863 const CIbyte *fmt, ...) 2869 const Ascbyte *fmt, ...)
2864 { 2870 {
2865 Lisp_Object obj; 2871 Lisp_Object obj;
2866 va_list args; 2872 va_list args;
2867 2873
2868 /* Optimization: */ 2874 /* Optimization: */
2869 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2875 if (ERRB_EQ (errb, ERROR_ME_NOT))
2870 return; 2876 return;
2871 2877
2872 va_start (args, fmt); 2878 va_start (args, fmt);
2873 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2879 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2874 va_end (args); 2880 va_end (args);
2875 2881
2876 /* Fsignal GC-protects its args */ 2882 /* Fsignal GC-protects its args */
2877 maybe_signal_error_1 (type, Fcons (obj, build_error_data (0, frob)), class_, 2883 maybe_signal_error_1 (type, Fcons (obj, build_error_data (0, frob)), class_,
2878 errb); 2884 errb);
2879 } 2885 }
2880 2886
2881 Lisp_Object 2887 Lisp_Object
2882 signal_continuable_ferror_with_frob (Lisp_Object type, Lisp_Object frob, 2888 signal_continuable_ferror_with_frob (Lisp_Object type, Lisp_Object frob,
2883 const CIbyte *fmt, ...) 2889 const Ascbyte *fmt, ...)
2884 { 2890 {
2885 Lisp_Object obj; 2891 Lisp_Object obj;
2886 va_list args; 2892 va_list args;
2887 2893
2888 va_start (args, fmt); 2894 va_start (args, fmt);
2889 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2895 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2890 va_end (args); 2896 va_end (args);
2891 2897
2892 /* Fsignal GC-protects its args */ 2898 /* Fsignal GC-protects its args */
2893 return Fsignal (type, Fcons (obj, build_error_data (0, frob))); 2899 return Fsignal (type, Fcons (obj, build_error_data (0, frob)));
2894 } 2900 }
2895 2901
2896 Lisp_Object 2902 Lisp_Object
2897 maybe_signal_continuable_ferror_with_frob (Lisp_Object type, Lisp_Object frob, 2903 maybe_signal_continuable_ferror_with_frob (Lisp_Object type, Lisp_Object frob,
2898 Lisp_Object class_, 2904 Lisp_Object class_,
2899 Error_Behavior errb, 2905 Error_Behavior errb,
2900 const CIbyte *fmt, ...) 2906 const Ascbyte *fmt, ...)
2901 { 2907 {
2902 Lisp_Object obj; 2908 Lisp_Object obj;
2903 va_list args; 2909 va_list args;
2904 2910
2905 /* Optimization: */ 2911 /* Optimization: */
2906 if (ERRB_EQ (errb, ERROR_ME_NOT)) 2912 if (ERRB_EQ (errb, ERROR_ME_NOT))
2907 return Qnil; 2913 return Qnil;
2908 2914
2909 va_start (args, fmt); 2915 va_start (args, fmt);
2910 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 2916 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
2911 va_end (args); 2917 va_end (args);
2912 2918
2913 /* Fsignal GC-protects its args */ 2919 /* Fsignal GC-protects its args */
2914 return maybe_signal_continuable_error_1 (type, 2920 return maybe_signal_continuable_error_1 (type,
2915 Fcons (obj, 2921 Fcons (obj,
2984 signal_error (Qcircular_property_list, 0, list); 2990 signal_error (Qcircular_property_list, 0, list);
2985 } 2991 }
2986 2992
2987 /* Called from within emacs_doprnt_1, so REASON is not formatted. */ 2993 /* Called from within emacs_doprnt_1, so REASON is not formatted. */
2988 DOESNT_RETURN 2994 DOESNT_RETURN
2989 syntax_error (const CIbyte *reason, Lisp_Object frob) 2995 syntax_error (const Ascbyte *reason, Lisp_Object frob)
2990 { 2996 {
2991 signal_error (Qsyntax_error, reason, frob); 2997 signal_error (Qsyntax_error, reason, frob);
2992 } 2998 }
2993 2999
2994 DOESNT_RETURN 3000 DOESNT_RETURN
2995 syntax_error_2 (const CIbyte *reason, Lisp_Object frob1, Lisp_Object frob2) 3001 syntax_error_2 (const Ascbyte *reason, Lisp_Object frob1, Lisp_Object frob2)
2996 { 3002 {
2997 signal_error_2 (Qsyntax_error, reason, frob1, frob2); 3003 signal_error_2 (Qsyntax_error, reason, frob1, frob2);
2998 } 3004 }
2999 3005
3000 void 3006 void
3001 maybe_syntax_error (const CIbyte *reason, Lisp_Object frob, 3007 maybe_syntax_error (const Ascbyte *reason, Lisp_Object frob,
3002 Lisp_Object class_, Error_Behavior errb) 3008 Lisp_Object class_, Error_Behavior errb)
3003 { 3009 {
3004 maybe_signal_error (Qsyntax_error, reason, frob, class_, errb); 3010 maybe_signal_error (Qsyntax_error, reason, frob, class_, errb);
3005 } 3011 }
3006 3012
3007 DOESNT_RETURN 3013 DOESNT_RETURN
3008 sferror (const CIbyte *reason, Lisp_Object frob) 3014 sferror (const Ascbyte *reason, Lisp_Object frob)
3009 { 3015 {
3010 signal_error (Qstructure_formation_error, reason, frob); 3016 signal_error (Qstructure_formation_error, reason, frob);
3011 } 3017 }
3012 3018
3013 DOESNT_RETURN 3019 DOESNT_RETURN
3014 sferror_2 (const CIbyte *reason, Lisp_Object frob1, Lisp_Object frob2) 3020 sferror_2 (const Ascbyte *reason, Lisp_Object frob1, Lisp_Object frob2)
3015 { 3021 {
3016 signal_error_2 (Qstructure_formation_error, reason, frob1, frob2); 3022 signal_error_2 (Qstructure_formation_error, reason, frob1, frob2);
3017 } 3023 }
3018 3024
3019 void 3025 void
3020 maybe_sferror (const CIbyte *reason, Lisp_Object frob, 3026 maybe_sferror (const Ascbyte *reason, Lisp_Object frob,
3021 Lisp_Object class_, Error_Behavior errb) 3027 Lisp_Object class_, Error_Behavior errb)
3022 { 3028 {
3023 maybe_signal_error (Qstructure_formation_error, reason, frob, class_, errb); 3029 maybe_signal_error (Qstructure_formation_error, reason, frob, class_, errb);
3024 } 3030 }
3025 3031
3026 DOESNT_RETURN 3032 DOESNT_RETURN
3027 invalid_argument (const CIbyte *reason, Lisp_Object frob) 3033 invalid_argument (const Ascbyte *reason, Lisp_Object frob)
3028 { 3034 {
3029 signal_error (Qinvalid_argument, reason, frob); 3035 signal_error (Qinvalid_argument, reason, frob);
3030 } 3036 }
3031 3037
3032 DOESNT_RETURN 3038 DOESNT_RETURN
3033 invalid_argument_2 (const CIbyte *reason, Lisp_Object frob1, 3039 invalid_argument_2 (const Ascbyte *reason, Lisp_Object frob1,
3034 Lisp_Object frob2) 3040 Lisp_Object frob2)
3035 { 3041 {
3036 signal_error_2 (Qinvalid_argument, reason, frob1, frob2); 3042 signal_error_2 (Qinvalid_argument, reason, frob1, frob2);
3037 } 3043 }
3038 3044
3039 void 3045 void
3040 maybe_invalid_argument (const CIbyte *reason, Lisp_Object frob, 3046 maybe_invalid_argument (const Ascbyte *reason, Lisp_Object frob,
3041 Lisp_Object class_, Error_Behavior errb) 3047 Lisp_Object class_, Error_Behavior errb)
3042 { 3048 {
3043 maybe_signal_error (Qinvalid_argument, reason, frob, class_, errb); 3049 maybe_signal_error (Qinvalid_argument, reason, frob, class_, errb);
3044 } 3050 }
3045 3051
3046 DOESNT_RETURN 3052 DOESNT_RETURN
3047 invalid_constant (const CIbyte *reason, Lisp_Object frob) 3053 invalid_constant (const Ascbyte *reason, Lisp_Object frob)
3048 { 3054 {
3049 signal_error (Qinvalid_constant, reason, frob); 3055 signal_error (Qinvalid_constant, reason, frob);
3050 } 3056 }
3051 3057
3052 DOESNT_RETURN 3058 DOESNT_RETURN
3053 invalid_constant_2 (const CIbyte *reason, Lisp_Object frob1, 3059 invalid_constant_2 (const Ascbyte *reason, Lisp_Object frob1,
3054 Lisp_Object frob2) 3060 Lisp_Object frob2)
3055 { 3061 {
3056 signal_error_2 (Qinvalid_constant, reason, frob1, frob2); 3062 signal_error_2 (Qinvalid_constant, reason, frob1, frob2);
3057 } 3063 }
3058 3064
3059 void 3065 void
3060 maybe_invalid_constant (const CIbyte *reason, Lisp_Object frob, 3066 maybe_invalid_constant (const Ascbyte *reason, Lisp_Object frob,
3061 Lisp_Object class_, Error_Behavior errb) 3067 Lisp_Object class_, Error_Behavior errb)
3062 { 3068 {
3063 maybe_signal_error (Qinvalid_constant, reason, frob, class_, errb); 3069 maybe_signal_error (Qinvalid_constant, reason, frob, class_, errb);
3064 } 3070 }
3065 3071
3066 DOESNT_RETURN 3072 DOESNT_RETURN
3067 invalid_operation (const CIbyte *reason, Lisp_Object frob) 3073 invalid_operation (const Ascbyte *reason, Lisp_Object frob)
3068 { 3074 {
3069 signal_error (Qinvalid_operation, reason, frob); 3075 signal_error (Qinvalid_operation, reason, frob);
3070 } 3076 }
3071 3077
3072 DOESNT_RETURN 3078 DOESNT_RETURN
3073 invalid_operation_2 (const CIbyte *reason, Lisp_Object frob1, 3079 invalid_operation_2 (const Ascbyte *reason, Lisp_Object frob1,
3074 Lisp_Object frob2) 3080 Lisp_Object frob2)
3075 { 3081 {
3076 signal_error_2 (Qinvalid_operation, reason, frob1, frob2); 3082 signal_error_2 (Qinvalid_operation, reason, frob1, frob2);
3077 } 3083 }
3078 3084
3079 void 3085 void
3080 maybe_invalid_operation (const CIbyte *reason, Lisp_Object frob, 3086 maybe_invalid_operation (const Ascbyte *reason, Lisp_Object frob,
3081 Lisp_Object class_, Error_Behavior errb) 3087 Lisp_Object class_, Error_Behavior errb)
3082 { 3088 {
3083 maybe_signal_error (Qinvalid_operation, reason, frob, class_, errb); 3089 maybe_signal_error (Qinvalid_operation, reason, frob, class_, errb);
3084 } 3090 }
3085 3091
3086 DOESNT_RETURN 3092 DOESNT_RETURN
3087 invalid_change (const CIbyte *reason, Lisp_Object frob) 3093 invalid_change (const Ascbyte *reason, Lisp_Object frob)
3088 { 3094 {
3089 signal_error (Qinvalid_change, reason, frob); 3095 signal_error (Qinvalid_change, reason, frob);
3090 } 3096 }
3091 3097
3092 DOESNT_RETURN 3098 DOESNT_RETURN
3093 invalid_change_2 (const CIbyte *reason, Lisp_Object frob1, Lisp_Object frob2) 3099 invalid_change_2 (const Ascbyte *reason, Lisp_Object frob1, Lisp_Object frob2)
3094 { 3100 {
3095 signal_error_2 (Qinvalid_change, reason, frob1, frob2); 3101 signal_error_2 (Qinvalid_change, reason, frob1, frob2);
3096 } 3102 }
3097 3103
3098 void 3104 void
3099 maybe_invalid_change (const CIbyte *reason, Lisp_Object frob, 3105 maybe_invalid_change (const Ascbyte *reason, Lisp_Object frob,
3100 Lisp_Object class_, Error_Behavior errb) 3106 Lisp_Object class_, Error_Behavior errb)
3101 { 3107 {
3102 maybe_signal_error (Qinvalid_change, reason, frob, class_, errb); 3108 maybe_signal_error (Qinvalid_change, reason, frob, class_, errb);
3103 } 3109 }
3104 3110
3105 DOESNT_RETURN 3111 DOESNT_RETURN
3106 invalid_state (const CIbyte *reason, Lisp_Object frob) 3112 invalid_state (const Ascbyte *reason, Lisp_Object frob)
3107 { 3113 {
3108 signal_error (Qinvalid_state, reason, frob); 3114 signal_error (Qinvalid_state, reason, frob);
3109 } 3115 }
3110 3116
3111 DOESNT_RETURN 3117 DOESNT_RETURN
3112 invalid_state_2 (const CIbyte *reason, Lisp_Object frob1, Lisp_Object frob2) 3118 invalid_state_2 (const Ascbyte *reason, Lisp_Object frob1, Lisp_Object frob2)
3113 { 3119 {
3114 signal_error_2 (Qinvalid_state, reason, frob1, frob2); 3120 signal_error_2 (Qinvalid_state, reason, frob1, frob2);
3115 } 3121 }
3116 3122
3117 void 3123 void
3118 maybe_invalid_state (const CIbyte *reason, Lisp_Object frob, 3124 maybe_invalid_state (const Ascbyte *reason, Lisp_Object frob,
3119 Lisp_Object class_, Error_Behavior errb) 3125 Lisp_Object class_, Error_Behavior errb)
3120 { 3126 {
3121 maybe_signal_error (Qinvalid_state, reason, frob, class_, errb); 3127 maybe_signal_error (Qinvalid_state, reason, frob, class_, errb);
3122 } 3128 }
3123 3129
3124 DOESNT_RETURN 3130 DOESNT_RETURN
3125 wtaerror (const CIbyte *reason, Lisp_Object frob) 3131 wtaerror (const Ascbyte *reason, Lisp_Object frob)
3126 { 3132 {
3127 signal_error (Qwrong_type_argument, reason, frob); 3133 signal_error (Qwrong_type_argument, reason, frob);
3128 } 3134 }
3129 3135
3130 DOESNT_RETURN 3136 DOESNT_RETURN
3131 stack_overflow (const CIbyte *reason, Lisp_Object frob) 3137 stack_overflow (const Ascbyte *reason, Lisp_Object frob)
3132 { 3138 {
3133 signal_error (Qstack_overflow, reason, frob); 3139 signal_error (Qstack_overflow, reason, frob);
3134 } 3140 }
3135 3141
3136 DOESNT_RETURN 3142 DOESNT_RETURN
3137 out_of_memory (const CIbyte *reason, Lisp_Object frob) 3143 out_of_memory (const Ascbyte *reason, Lisp_Object frob)
3138 { 3144 {
3139 signal_error (Qout_of_memory, reason, frob); 3145 signal_error (Qout_of_memory, reason, frob);
3140 }
3141
3142 DOESNT_RETURN
3143 printing_unreadable_object (const CIbyte *fmt, ...)
3144 {
3145 Lisp_Object obj;
3146 va_list args;
3147
3148 va_start (args, fmt);
3149 obj = emacs_vsprintf_string (CGETTEXT (fmt), args);
3150 va_end (args);
3151
3152 /* Fsignal GC-protects its args */
3153 signal_error (Qprinting_unreadable_object, 0, obj);
3154 } 3146 }
3155 3147
3156 3148
3157 /************************************************************************/ 3149 /************************************************************************/
3158 /* User commands */ 3150 /* User commands */
3313 byte-compiled functions, we'll accept it for now. */ 3305 byte-compiled functions, we'll accept it for now. */
3314 if (EQ (*btp->function, Qbyte_code)) 3306 if (EQ (*btp->function, Qbyte_code))
3315 btp = btp->next; 3307 btp = btp->next;
3316 3308
3317 /* If this isn't a byte-compiled function, then we may now be 3309 /* If this isn't a byte-compiled function, then we may now be
3318 looking at several frames for special forms. Skip past them. */ 3310 looking at several frames for special operators. Skip past them. */
3319 while (btp && 3311 while (btp &&
3320 btp->nargs == UNEVALLED) 3312 btp->nargs == UNEVALLED)
3321 btp = btp->next; 3313 btp = btp->next;
3322 3314
3323 #else 3315 #else
3631 } 3623 }
3632 3624
3633 { 3625 {
3634 Lisp_Object value = 3626 Lisp_Object value =
3635 execute_optimized_program ((Opbyte *) XOPAQUE_DATA (f->instructions), 3627 execute_optimized_program ((Opbyte *) XOPAQUE_DATA (f->instructions),
3628 #ifdef ERROR_CHECK_BYTE_CODE
3629 XOPAQUE_SIZE (f->instructions) /
3630 sizeof (Opbyte),
3631 #endif
3636 f->stack_depth, 3632 f->stack_depth,
3637 XVECTOR_DATA (f->constants)); 3633 XVECTOR_DATA (f->constants));
3638 3634
3639 /* The attempt to optimize this by only unbinding variables failed 3635 /* The attempt to optimize this by only unbinding variables failed
3640 because using buffer-local variables as function parameters 3636 because using buffer-local variables as function parameters
4071 { 4067 {
4072 PROFILE_ENTER_FUNCTION (); 4068 PROFILE_ENTER_FUNCTION ();
4073 val = SUBR_FUNCTION (subr, MANY) (fun_nargs, fun_args); 4069 val = SUBR_FUNCTION (subr, MANY) (fun_nargs, fun_args);
4074 PROFILE_EXIT_FUNCTION (); 4070 PROFILE_EXIT_FUNCTION ();
4075 } 4071 }
4076 else if (max_args == UNEVALLED) /* Can't funcall a special form */ 4072 else if (max_args == UNEVALLED) /* Can't funcall a special operator */
4077 { 4073 {
4078 /* Ugh, ugh, ugh. */ 4074 /* Ugh, ugh, ugh. */
4079 if (EQ (fun, XSYMBOL_FUNCTION (Qthrow))) 4075 if (EQ (fun, XSYMBOL_FUNCTION (Qthrow)))
4080 { 4076 {
4081 args[0] = Qobsolete_throw; 4077 args[0] = Qobsolete_throw;
4141 (object)) 4137 (object))
4142 { 4138 {
4143 if (SYMBOLP (object)) 4139 if (SYMBOLP (object))
4144 object = indirect_function (object, 0); 4140 object = indirect_function (object, 0);
4145 4141
4146 if (COMPILED_FUNCTIONP (object) || SUBRP (object)) 4142 if (COMPILED_FUNCTIONP (object)
4143 || (SUBRP (object)
4144 && (XSUBR (object)->max_args != UNEVALLED)))
4147 return Qt; 4145 return Qt;
4148 if (CONSP (object)) 4146 if (CONSP (object))
4149 { 4147 {
4150 Lisp_Object car = XCAR (object); 4148 Lisp_Object car = XCAR (object);
4151 if (EQ (car, Qlambda)) 4149 if (EQ (car, Qlambda))
4152 return Qt; 4150 return Qt;
4153 if (EQ (car, Qautoload) 4151 if (EQ (car, Qautoload)
4154 && NILP (Fcar_safe (Fcdr_safe (Fcdr_safe (Fcdr_safe (XCDR (object))))))) 4152 && NILP (Fcar_safe (Fcdr_safe(Fcdr_safe
4153 (Fcdr_safe (XCDR (object)))))))
4155 return Qt; 4154 return Qt;
4156 } 4155 }
4157 return Qnil; 4156 return Qnil;
4158 } 4157 }
4159 4158
4251 } 4250 }
4252 4251
4253 DEFUN ("function-min-args", Ffunction_min_args, 1, 1, 0, /* 4252 DEFUN ("function-min-args", Ffunction_min_args, 1, 1, 0, /*
4254 Return the minimum number of arguments a function may be called with. 4253 Return the minimum number of arguments a function may be called with.
4255 The function may be any form that can be passed to `funcall', 4254 The function may be any form that can be passed to `funcall',
4256 any special form, or any macro. 4255 any special operator, or any macro.
4257 4256
4258 To check if a function can be called with a specified number of 4257 To check if a function can be called with a specified number of
4259 arguments, use `function-allows-args'. 4258 arguments, use `function-allows-args'.
4260 */ 4259 */
4261 (function)) 4260 (function))
4264 } 4263 }
4265 4264
4266 DEFUN ("function-max-args", Ffunction_max_args, 1, 1, 0, /* 4265 DEFUN ("function-max-args", Ffunction_max_args, 1, 1, 0, /*
4267 Return the maximum number of arguments a function may be called with. 4266 Return the maximum number of arguments a function may be called with.
4268 The function may be any form that can be passed to `funcall', 4267 The function may be any form that can be passed to `funcall',
4269 any special form, or any macro. 4268 any special operator, or any macro.
4270 If the function takes an arbitrary number of arguments or is 4269 If the function takes an arbitrary number of arguments or is
4271 a built-in special form, nil is returned. 4270 a built-in special operator, nil is returned.
4272 4271
4273 To check if a function can be called with a specified number of 4272 To check if a function can be called with a specified number of
4274 arguments, use `function-allows-args'. 4273 arguments, use `function-allows-args'.
4275 */ 4274 */
4276 (function)) 4275 (function))
4423 /* Multiple values. 4422 /* Multiple values.
4424 4423
4425 A multiple value object is returned by #'values if: 4424 A multiple value object is returned by #'values if:
4426 4425
4427 -- The number of arguments to #'values is not one, and: 4426 -- The number of arguments to #'values is not one, and:
4428 -- Some special form in the call stack is prepared to handle more than 4427 -- Some special operator in the call stack is prepared to handle more than
4429 one multiple value. 4428 one multiple value.
4430 4429
4431 The return value of #'values-list is analogous to that of #'values. 4430 The return value of #'values-list is analogous to that of #'values.
4432 4431
4433 Henry Baker, in https://eprints.kfupm.edu.sa/31898/1/31898.pdf ("CONS 4432 Henry Baker, in https://eprints.kfupm.edu.sa/31898/1/31898.pdf ("CONS
4438 something not true for us. As far as I can tell, it also ignores the 4437 something not true for us. As far as I can tell, it also ignores the
4439 contexts where multiple-values need to be thrown, or maybe it thinks such 4438 contexts where multiple-values need to be thrown, or maybe it thinks such
4440 objects should be converted to heap allocation at that point. 4439 objects should be converted to heap allocation at that point.
4441 4440
4442 The specific multiple values saved and returned depend on how many 4441 The specific multiple values saved and returned depend on how many
4443 multiple-values special forms in the stack are interested in; for 4442 multiple-values special operators in the stack are interested in; for
4444 example, if #'multiple-value-call is somewhere in the call stack, all 4443 example, if #'multiple-value-call is somewhere in the call stack, all
4445 values passed to #'values will be saved and returned. If an expansion of 4444 values passed to #'values will be saved and returned. If an expansion of
4446 #'multiple-value-setq with 10 SYMS is the only part of the call stack 4445 #'multiple-value-setq with 10 SYMS is the only part of the call stack
4447 interested in multiple values, then a maximum of ten multiple values will 4446 interested in multiple values, then a maximum of ten multiple values will
4448 be saved and returned. 4447 be saved and returned.
4581 printing_unreadable_object ("multiple values"); 4580 printing_unreadable_object ("multiple values");
4582 } 4581 }
4583 4582
4584 if (0 == count) 4583 if (0 == count)
4585 { 4584 {
4586 write_c_string (printcharfun, "#<zero-length multiple value>"); 4585 write_msg_string (printcharfun, "#<zero-length multiple value>");
4587 } 4586 }
4588 4587
4589 for (index = 0; index < count;) 4588 for (index = 0; index < count;)
4590 { 4589 {
4591 if (index != 0 && 4590 if (index != 0 &&
4603 4602
4604 ++index; 4603 ++index;
4605 4604
4606 if (count > 1 && index < count) 4605 if (count > 1 && index < count)
4607 { 4606 {
4608 write_c_string (printcharfun, " ;\n"); 4607 write_ascstring (printcharfun, " ;\n");
4609 } 4608 }
4610 } 4609 }
4611 } 4610 }
4612 4611
4613 static Lisp_Object 4612 static Lisp_Object
4721 { 4720 {
4722 result = args[i]; 4721 result = args[i];
4723 if (MULTIPLE_VALUEP (result)) 4722 if (MULTIPLE_VALUEP (result))
4724 { 4723 {
4725 Lisp_Object val; 4724 Lisp_Object val;
4726 Elemcount i, count = XMULTIPLE_VALUE_COUNT (result); 4725 Elemcount j, count = XMULTIPLE_VALUE_COUNT (result);
4727 4726
4728 for (i = 0; i < count; i++) 4727 for (j = 0; j < count; j++)
4729 { 4728 {
4730 val = multiple_value_aref (result, i); 4729 val = multiple_value_aref (result, j);
4731 assert (!UNBOUNDP (val)); 4730 assert (!UNBOUNDP (val));
4732 4731
4733 XSETCDR (list_offset, Fcons (val, Qnil)); 4732 XSETCDR (list_offset, Fcons (val, Qnil));
4734 list_offset = XCDR (list_offset); 4733 list_offset = XCDR (list_offset);
4735 } 4734 }
5721 Lisp_Object errstr = 5720 Lisp_Object errstr =
5722 emacs_sprintf_string_lisp 5721 emacs_sprintf_string_lisp
5723 ("%s: Attempt to throw outside of function:" 5722 ("%s: Attempt to throw outside of function:"
5724 "To catch `%s' with value `%s'\n\nBacktrace follows:\n\n%s", 5723 "To catch `%s' with value `%s'\n\nBacktrace follows:\n\n%s",
5725 Qnil, 4, 5724 Qnil, 4,
5726 build_msg_string (warning_string ? warning_string : "error"), 5725 build_msg_cistring (warning_string ? warning_string : "error"),
5727 p->thrown_tag, p->thrown_value, p->backtrace); 5726 p->thrown_tag, p->thrown_value, p->backtrace);
5728 warn_when_safe_lispobj (Qerror, current_warning_level (), errstr); 5727 warn_when_safe_lispobj (Qerror, current_warning_level (), errstr);
5729 } 5728 }
5730 else if (p->caught_error && !EQ (p->error_conditions, Qquit)) 5729 else if (p->caught_error && !EQ (p->error_conditions, Qquit))
5731 { 5730 {
5736 but that stuff is all in Lisp currently. */ 5735 but that stuff is all in Lisp currently. */
5737 errstr = 5736 errstr =
5738 emacs_sprintf_string_lisp 5737 emacs_sprintf_string_lisp
5739 ("%s: (%s %s)\n\nBacktrace follows:\n\n%s", 5738 ("%s: (%s %s)\n\nBacktrace follows:\n\n%s",
5740 Qnil, 4, 5739 Qnil, 4,
5741 build_msg_string (warning_string ? warning_string : "error"), 5740 build_msg_cistring (warning_string ? warning_string : "error"),
5742 p->error_conditions, p->data, p->backtrace); 5741 p->error_conditions, p->data, p->backtrace);
5743 5742
5744 warn_when_safe_lispobj (warning_class, current_warning_level (), 5743 warn_when_safe_lispobj (warning_class, current_warning_level (),
5745 errstr); 5744 errstr);
5746 } 5745 }
6339 } 6338 }
6340 6339
6341 static Lisp_Object 6340 static Lisp_Object
6342 safe_run_hook_trapping_problems_1 (void *puta) 6341 safe_run_hook_trapping_problems_1 (void *puta)
6343 { 6342 {
6344 Lisp_Object hook = VOID_TO_LISP (puta); 6343 Lisp_Object hook = GET_LISP_FROM_VOID (puta);
6345 6344
6346 run_hook (hook); 6345 run_hook (hook);
6347 return Qnil; 6346 return Qnil;
6348 } 6347 }
6349 6348
6367 GCPRO2 (hook_symbol, tem); 6366 GCPRO2 (hook_symbol, tem);
6368 tem = call_trapping_problems (Qerror, NULL, 6367 tem = call_trapping_problems (Qerror, NULL,
6369 flags | POSTPONE_WARNING_ISSUE, 6368 flags | POSTPONE_WARNING_ISSUE,
6370 &prob, 6369 &prob,
6371 safe_run_hook_trapping_problems_1, 6370 safe_run_hook_trapping_problems_1,
6372 LISP_TO_VOID (hook_symbol)); 6371 STORE_LISP_IN_VOID (hook_symbol));
6373 { 6372 {
6374 Lisp_Object hook_name = XSYMBOL_NAME (hook_symbol); 6373 Lisp_Object hook_name = XSYMBOL_NAME (hook_symbol);
6375 Ibyte *hook_str = XSTRING_DATA (hook_name); 6374 Ibyte *hook_str = XSTRING_DATA (hook_name);
6376 Ibyte *err = alloca_ibytes (XSTRING_LENGTH (hook_name) + 100); 6375 Ibyte *err = alloca_ibytes (XSTRING_LENGTH (hook_name) + 100);
6377 6376
6699 } 6698 }
6700 6699
6701 static Lisp_Object 6700 static Lisp_Object
6702 restore_lisp_object (Lisp_Object cons) 6701 restore_lisp_object (Lisp_Object cons)
6703 { 6702 {
6704 Lisp_Object opaque = XCAR (cons); 6703 Lisp_Object laddr = XCAR (cons);
6705 Lisp_Object *addr = (Lisp_Object *) get_opaque_ptr (opaque); 6704 Lisp_Object *addr = (Lisp_Object *) GET_VOID_FROM_LISP (laddr);
6706 *addr = XCDR (cons); 6705 *addr = XCDR (cons);
6707 free_opaque_ptr (opaque);
6708 free_cons (cons); 6706 free_cons (cons);
6709 return Qnil; 6707 return Qnil;
6710 } 6708 }
6711 6709
6712 /* Establish an unwind-protect which will restore the Lisp_Object pointed to 6710 /* Establish an unwind-protect which will restore the Lisp_Object pointed to
6713 by ADDR with the value VAL. */ 6711 by ADDR with the value VAL. */
6714 static int 6712 static int
6715 record_unwind_protect_restoring_lisp_object (Lisp_Object *addr, 6713 record_unwind_protect_restoring_lisp_object (Lisp_Object *addr,
6716 Lisp_Object val) 6714 Lisp_Object val)
6717 { 6715 {
6718 Lisp_Object opaque = make_opaque_ptr (addr); 6716 /* We use a cons rather than a malloc()ed structure because we want the
6717 Lisp object to have garbage-collection protection */
6718 Lisp_Object laddr = STORE_VOID_IN_LISP (addr);
6719 return record_unwind_protect (restore_lisp_object, 6719 return record_unwind_protect (restore_lisp_object,
6720 noseeum_cons (opaque, val)); 6720 noseeum_cons (laddr, val));
6721 } 6721 }
6722 6722
6723 /* Similar to specbind() but for any C variable whose value is a 6723 /* Similar to specbind() but for any C variable whose value is a
6724 Lisp_Object. Sets up an unwind-protect to restore the variable 6724 Lisp_Object. Sets up an unwind-protect to restore the variable
6725 pointed to by ADDR to its existing value, and then changes its 6725 pointed to by ADDR to its existing value, and then changes its
6732 record_unwind_protect_restoring_lisp_object (addr, *addr); 6732 record_unwind_protect_restoring_lisp_object (addr, *addr);
6733 *addr = newval; 6733 *addr = newval;
6734 return count; 6734 return count;
6735 } 6735 }
6736 6736
6737 struct restore_int
6738 {
6739 int *addr;
6740 int val;
6741 };
6742
6737 static Lisp_Object 6743 static Lisp_Object
6738 restore_int (Lisp_Object cons) 6744 restore_int (Lisp_Object obj)
6739 { 6745 {
6740 Lisp_Object opaque = XCAR (cons); 6746 struct restore_int *ri = (struct restore_int *) GET_VOID_FROM_LISP (obj);
6741 Lisp_Object lval = XCDR (cons); 6747 *(ri->addr) = ri->val;
6742 int *addr = (int *) get_opaque_ptr (opaque); 6748 xfree (ri);
6743 int val;
6744
6745 /* In the event that a C integer will always fit in an Emacs int, we
6746 haven't ever stored a C integer as an opaque pointer. This #ifdef
6747 eliminates a warning on AMD 64, where EMACS_INT has 63 value bits and C
6748 integers have 32 value bits. */
6749 #if INT_VALBITS < INTBITS
6750 if (INTP (lval))
6751 {
6752 val = XINT (lval);
6753 }
6754 else
6755 {
6756 val = (int) get_opaque_ptr (lval);
6757 free_opaque_ptr (lval);
6758 }
6759 #else /* !(INT_VALBITS < INTBITS) */
6760 val = XINT(lval);
6761 #endif /* INT_VALBITS < INTBITS */
6762
6763 *addr = val;
6764 free_opaque_ptr (opaque);
6765 free_cons (cons);
6766 return Qnil; 6749 return Qnil;
6767 } 6750 }
6768 6751
6769 /* Establish an unwind-protect which will restore the int pointed to 6752 /* Establish an unwind-protect which will restore the int pointed to
6770 by ADDR with the value VAL. This function works correctly with 6753 by ADDR with the value VAL. This function works correctly with
6771 all ints, even those that don't fit into a Lisp integer. */ 6754 all ints, even those that don't fit into a Lisp integer. */
6772 int 6755 int
6773 record_unwind_protect_restoring_int (int *addr, int val) 6756 record_unwind_protect_restoring_int (int *addr, int val)
6774 { 6757 {
6775 Lisp_Object opaque = make_opaque_ptr (addr); 6758 struct restore_int *ri = xnew (struct restore_int);
6776 Lisp_Object lval; 6759 ri->addr = addr;
6777 6760 ri->val = val;
6778 /* In the event that a C integer will always fit in an Emacs int, we don't 6761 return record_unwind_protect (restore_int, STORE_VOID_IN_LISP (ri));
6779 ever want to store a C integer as an opaque pointer. This #ifdef
6780 eliminates a warning on AMD 64, where EMACS_INT has 63 value bits and C
6781 integers have 32 value bits. */
6782 #if INT_VALBITS <= INTBITS
6783 if (NUMBER_FITS_IN_AN_EMACS_INT (val))
6784 lval = make_int (val);
6785 else
6786 lval = make_opaque_ptr ((void *) val);
6787 #else /* !(INT_VALBITS < INTBITS) */
6788 lval = make_int (val);
6789 #endif /* INT_VALBITS <= INTBITS */
6790
6791 return record_unwind_protect (restore_int, noseeum_cons (opaque, lval));
6792 } 6762 }
6793 6763
6794 /* Similar to specbind() but for any C variable whose value is an int. 6764 /* Similar to specbind() but for any C variable whose value is an int.
6795 Sets up an unwind-protect to restore the variable pointed to by 6765 Sets up an unwind-protect to restore the variable pointed to by
6796 ADDR to its existing value, and then changes its value to NEWVAL. 6766 ADDR to its existing value, and then changes its value to NEWVAL.
6807 } 6777 }
6808 6778
6809 static Lisp_Object 6779 static Lisp_Object
6810 free_pointer (Lisp_Object opaque) 6780 free_pointer (Lisp_Object opaque)
6811 { 6781 {
6812 xfree (get_opaque_ptr (opaque), void *); 6782 void *ptr = GET_VOID_FROM_LISP (opaque);
6813 free_opaque_ptr (opaque); 6783 xfree (ptr);
6814 return Qnil; 6784 return Qnil;
6815 } 6785 }
6816 6786
6817 /* Establish an unwind-protect which will free the specified block. 6787 /* Establish an unwind-protect which will free the specified block.
6818 */ 6788 */
6819 int 6789 int
6820 record_unwind_protect_freeing (void *ptr) 6790 record_unwind_protect_freeing (void *ptr)
6821 { 6791 {
6822 Lisp_Object opaque = make_opaque_ptr (ptr); 6792 return record_unwind_protect (free_pointer, STORE_VOID_IN_LISP (ptr));
6823 return record_unwind_protect (free_pointer, opaque);
6824 } 6793 }
6825 6794
6826 static Lisp_Object 6795 static Lisp_Object
6827 free_dynarr (Lisp_Object opaque) 6796 free_dynarr (Lisp_Object opaque)
6828 { 6797 {
6829 Dynarr_free (get_opaque_ptr (opaque)); 6798 Dynarr_free (GET_VOID_FROM_LISP (opaque));
6830 free_opaque_ptr (opaque);
6831 return Qnil; 6799 return Qnil;
6832 } 6800 }
6833 6801
6834 int 6802 int
6835 record_unwind_protect_freeing_dynarr (void *ptr) 6803 record_unwind_protect_freeing_dynarr (void *ptr)
6836 { 6804 {
6837 Lisp_Object opaque = make_opaque_ptr (ptr); 6805 return record_unwind_protect (free_dynarr, STORE_VOID_IN_LISP (ptr));
6838 return record_unwind_protect (free_dynarr, opaque);
6839 } 6806 }
6840 6807
6841 /* Unwind the stack till specpdl_depth() == COUNT. 6808 /* Unwind the stack till specpdl_depth() == COUNT.
6842 VALUE is not used, except that, purely as a convenience to the 6809 VALUE is not used, except that, purely as a convenience to the
6843 caller, it is protected from garbage-protection and returned. */ 6810 caller, it is protected from garbage-protection and returned. */
7008 { 6975 {
7009 if (specpdl[speccount - 1].func == 0 6976 if (specpdl[speccount - 1].func == 0
7010 || specpdl[speccount - 1].func == specbind_unwind_local 6977 || specpdl[speccount - 1].func == specbind_unwind_local
7011 || specpdl[speccount - 1].func == specbind_unwind_wasnt_local) 6978 || specpdl[speccount - 1].func == specbind_unwind_wasnt_local)
7012 { 6979 {
7013 write_c_string (stream, !printing_bindings ? " # bind (" : " "); 6980 write_ascstring (stream, !printing_bindings ? " # bind (" : " ");
7014 Fprin1 (specpdl[speccount - 1].symbol, stream); 6981 Fprin1 (specpdl[speccount - 1].symbol, stream);
7015 printing_bindings = 1; 6982 printing_bindings = 1;
7016 } 6983 }
7017 else 6984 else
7018 { 6985 {
7019 if (printing_bindings) write_c_string (stream, ")\n"); 6986 if (printing_bindings) write_ascstring (stream, ")\n");
7020 write_c_string (stream, " # (unwind-protect ...)\n"); 6987 write_ascstring (stream, " # (unwind-protect ...)\n");
7021 printing_bindings = 0; 6988 printing_bindings = 0;
7022 } 6989 }
7023 } 6990 }
7024 if (printing_bindings) write_c_string (stream, ")\n"); 6991 if (printing_bindings) write_ascstring (stream, ")\n");
7025 } 6992 }
7026 6993
7027 static Lisp_Object 6994 static Lisp_Object
7028 backtrace_unevalled_args (Lisp_Object *args) 6995 backtrace_unevalled_args (Lisp_Object *args)
7029 { 6996 {
7030 if (args) 6997 if (args)
7031 return *args; 6998 return *args;
7032 else 6999 else
7033 return list1 (build_string ("[internal]")); 7000 return list1 (build_ascstring ("[internal]"));
7034 } 7001 }
7035 7002
7036 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /* 7003 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /*
7037 Print a trace of Lisp function calls currently active. 7004 Print a trace of Lisp function calls currently active.
7038 Optional arg STREAM specifies the output stream to send the backtrace to, 7005 Optional arg STREAM specifies the output stream to send the backtrace to,
7086 backtrace_specials (speccount, catchpdl, stream); 7053 backtrace_specials (speccount, catchpdl, stream);
7087 7054
7088 speccount = catches->pdlcount; 7055 speccount = catches->pdlcount;
7089 if (catchpdl == speccount) 7056 if (catchpdl == speccount)
7090 { 7057 {
7091 write_c_string (stream, " # (catch "); 7058 write_ascstring (stream, " # (catch ");
7092 Fprin1 (catches->tag, stream); 7059 Fprin1 (catches->tag, stream);
7093 write_c_string (stream, " ...)\n"); 7060 write_ascstring (stream, " ...)\n");
7094 } 7061 }
7095 else 7062 else
7096 { 7063 {
7097 write_c_string (stream, " # (condition-case ... . "); 7064 write_ascstring (stream, " # (condition-case ... . ");
7098 Fprin1 (Fcdr (Fcar (catches->tag)), stream); 7065 Fprin1 (Fcdr (Fcar (catches->tag)), stream);
7099 write_c_string (stream, ")\n"); 7066 write_ascstring (stream, ")\n");
7100 } 7067 }
7101 catches = catches->next; 7068 catches = catches->next;
7102 } 7069 }
7103 else if (!backlist) 7070 else if (!backlist)
7104 break; 7071 break;
7107 if (!NILP (detailed) && backlist->pdlcount < speccount) 7074 if (!NILP (detailed) && backlist->pdlcount < speccount)
7108 { 7075 {
7109 backtrace_specials (speccount, backlist->pdlcount, stream); 7076 backtrace_specials (speccount, backlist->pdlcount, stream);
7110 speccount = backlist->pdlcount; 7077 speccount = backlist->pdlcount;
7111 } 7078 }
7112 write_c_string (stream, backlist->debug_on_exit ? "* " : " "); 7079 write_ascstring (stream, backlist->debug_on_exit ? "* " : " ");
7113 if (backlist->nargs == UNEVALLED) 7080 if (backlist->nargs == UNEVALLED)
7114 { 7081 {
7115 Fprin1 (Fcons (*backlist->function, 7082 Fprin1 (Fcons (*backlist->function,
7116 backtrace_unevalled_args (backlist->args)), 7083 backtrace_unevalled_args (backlist->args)),
7117 stream); 7084 stream);
7118 write_c_string (stream, "\n"); /* from FSFmacs 19.30 */ 7085 write_ascstring (stream, "\n"); /* from FSFmacs 19.30 */
7119 } 7086 }
7120 else 7087 else
7121 { 7088 {
7122 Lisp_Object tem = *backlist->function; 7089 Lisp_Object tem = *backlist->function;
7123 Fprin1 (tem, stream); /* This can QUIT */ 7090 Fprin1 (tem, stream); /* This can QUIT */
7124 write_c_string (stream, "("); 7091 write_ascstring (stream, "(");
7125 if (backlist->nargs == MANY) 7092 if (backlist->nargs == MANY)
7126 { 7093 {
7127 int i; 7094 int i;
7128 Lisp_Object tail = Qnil; 7095 Lisp_Object tail = Qnil;
7129 struct gcpro ngcpro1; 7096 struct gcpro ngcpro1;
7131 NGCPRO1 (tail); 7098 NGCPRO1 (tail);
7132 for (tail = *backlist->args, i = 0; 7099 for (tail = *backlist->args, i = 0;
7133 !NILP (tail); 7100 !NILP (tail);
7134 tail = Fcdr (tail), i++) 7101 tail = Fcdr (tail), i++)
7135 { 7102 {
7136 if (i != 0) write_c_string (stream, " "); 7103 if (i != 0) write_ascstring (stream, " ");
7137 Fprin1 (Fcar (tail), stream); 7104 Fprin1 (Fcar (tail), stream);
7138 } 7105 }
7139 NUNGCPRO; 7106 NUNGCPRO;
7140 } 7107 }
7141 else 7108 else
7143 int i; 7110 int i;
7144 for (i = 0; i < backlist->nargs; i++) 7111 for (i = 0; i < backlist->nargs; i++)
7145 { 7112 {
7146 if (!i && EQ (tem, Qbyte_code)) 7113 if (!i && EQ (tem, Qbyte_code))
7147 { 7114 {
7148 write_c_string (stream, "\"...\""); 7115 write_ascstring (stream, "\"...\"");
7149 continue; 7116 continue;
7150 } 7117 }
7151 if (i != 0) write_c_string (stream, " "); 7118 if (i != 0) write_ascstring (stream, " ");
7152 Fprin1 (backlist->args[i], stream); 7119 Fprin1 (backlist->args[i], stream);
7153 } 7120 }
7154 } 7121 }
7155 write_c_string (stream, ")\n"); 7122 write_ascstring (stream, ")\n");
7156 } 7123 }
7157 backlist = backlist->next; 7124 backlist = backlist->next;
7158 } 7125 }
7159 } 7126 }
7160 Vprint_level = old_level; 7127 Vprint_level = old_level;
7166 } 7133 }
7167 7134
7168 7135
7169 DEFUN ("backtrace-frame", Fbacktrace_frame, 1, 1, 0, /* 7136 DEFUN ("backtrace-frame", Fbacktrace_frame, 1, 1, 0, /*
7170 Return the function and arguments NFRAMES up from current execution point. 7137 Return the function and arguments NFRAMES up from current execution point.
7171 If that frame has not evaluated the arguments yet (or is a special form), 7138 If that frame has not evaluated the arguments yet (or involves a special
7172 the value is (nil FUNCTION ARG-FORMS...). 7139 operator), the value is (nil FUNCTION ARG-FORMS...).
7173 If that frame has evaluated its arguments and called its function already, 7140 If that frame has evaluated its arguments and called its function already,
7174 the value is (t FUNCTION ARG-VALUES...). 7141 the value is (t FUNCTION ARG-VALUES...).
7175 A &rest arg is represented as the tail of the list ARG-VALUES. 7142 A &rest arg is represented as the tail of the list ARG-VALUES.
7176 FUNCTION is whatever was supplied as car of evaluated list, 7143 FUNCTION is whatever was supplied as car of evaluated list,
7177 or a lambda expression for macro calls. 7144 or a lambda expression for macro calls.
7242 An alternative approach is to just pass some non-string type of 7209 An alternative approach is to just pass some non-string type of
7243 Lisp_Object to warn_when_safe_lispobj(); `prin1-to-string' will 7210 Lisp_Object to warn_when_safe_lispobj(); `prin1-to-string' will
7244 automatically be called when it is safe to do so. */ 7211 automatically be called when it is safe to do so. */
7245 7212
7246 void 7213 void
7247 warn_when_safe (Lisp_Object class_, Lisp_Object level, const CIbyte *fmt, ...) 7214 warn_when_safe (Lisp_Object class_, Lisp_Object level, const Ascbyte *fmt, ...)
7248 { 7215 {
7249 Lisp_Object obj; 7216 Lisp_Object obj;
7250 va_list args; 7217 va_list args;
7251 7218
7252 if (warning_will_be_discarded (level)) 7219 if (warning_will_be_discarded (level))
7253 return; 7220 return;
7254 7221
7255 va_start (args, fmt); 7222 va_start (args, fmt);
7256 obj = emacs_vsprintf_string (CGETTEXT (fmt), args); 7223 obj = emacs_vsprintf_string (GETTEXT (fmt), args);
7257 va_end (args); 7224 va_end (args);
7258 7225
7259 warn_when_safe_lispobj (class_, level, obj); 7226 warn_when_safe_lispobj (class_, level, obj);
7260 } 7227 }
7261 7228
7535 7502
7536 DEFVAR_CONST_INT ("multiple-values-limit", &Vmultiple_values_limit /* 7503 DEFVAR_CONST_INT ("multiple-values-limit", &Vmultiple_values_limit /*
7537 The exclusive upper bound on the number of multiple values. 7504 The exclusive upper bound on the number of multiple values.
7538 7505
7539 This applies to `values', `values-list', `multiple-value-bind' and related 7506 This applies to `values', `values-list', `multiple-value-bind' and related
7540 macros and special forms. 7507 macros and special operators.
7541 */); 7508 */);
7542 Vmultiple_values_limit = EMACS_INT_MAX > INT_MAX ? INT_MAX : EMACS_INT_MAX; 7509 Vmultiple_values_limit = EMACS_INT_MAX > INT_MAX ? INT_MAX : EMACS_INT_MAX;
7543 7510
7544 staticpro (&Vcatch_everything_tag); 7511 staticpro (&Vcatch_everything_tag);
7545 Vcatch_everything_tag = make_opaque (OPAQUE_CLEAR, 0); 7512 Vcatch_everything_tag = make_opaque (OPAQUE_CLEAR, 0);