XEmacs 21.2.28 "Hermes".
[chise/xemacs-chise.git.1] / src / eval.c
index 6ace437..962fab8 100644 (file)
@@ -77,8 +77,7 @@ struct backtrace *backtrace_list;
   Lisp_Object *PF_av = (av);                                   \
   switch (ac)                                                  \
     {                                                          \
-    default: abort();                                          \
-    case 0: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 0); break;  \
+    default:rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 0); break;  \
     case 1: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 1); break;  \
     case 2: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 2); break;  \
     case 3: rv = PRIMITIVE_FUNCALL_1(PF_fn, PF_av, 3); break;  \
@@ -296,7 +295,7 @@ print_subr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
 }
 
 static const struct lrecord_description subr_description[] = {
-  { XD_DOC_STRING, offsetof(Lisp_Subr, doc)    },
+  { XD_DOC_STRING, offsetof (Lisp_Subr, doc) },
   { XD_END }
 };
 
@@ -1483,7 +1482,7 @@ If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.
 static Lisp_Object
 condition_bind_unwind (Lisp_Object loser)
 {
-  struct Lisp_Cons *victim;
+  Lisp_Cons *victim;
   /* ((handler-fun . handler-args) ... other handlers) */
   Lisp_Object tem = XCAR (loser);
 
@@ -1505,7 +1504,7 @@ condition_bind_unwind (Lisp_Object loser)
 static Lisp_Object
 condition_case_unwind (Lisp_Object loser)
 {
-  struct Lisp_Cons *victim;
+  Lisp_Cons *victim;
 
   /* ((<unbound> . clauses) ... other handlers */
   victim = XCONS (XCAR (loser));
@@ -2471,47 +2470,48 @@ signal_quit (void)
 
 \f
 /* Used in core lisp functions for efficiency */
-void
+Lisp_Object
 signal_void_function_error (Lisp_Object function)
 {
-  Fsignal (Qvoid_function, list1 (function));
+  return Fsignal (Qvoid_function, list1 (function));
 }
 
-static void
+Lisp_Object
 signal_invalid_function_error (Lisp_Object function)
 {
-  Fsignal (Qinvalid_function, list1 (function));
+  return Fsignal (Qinvalid_function, list1 (function));
 }
 
-static void
+Lisp_Object
 signal_wrong_number_of_arguments_error (Lisp_Object function, int nargs)
 {
-  Fsignal (Qwrong_number_of_arguments, list2 (function, make_int (nargs)));
+  return Fsignal (Qwrong_number_of_arguments,
+                 list2 (function, make_int (nargs)));
 }
 
 /* Used in list traversal macros for efficiency. */
-void
+DOESNT_RETURN
 signal_malformed_list_error (Lisp_Object list)
 {
-  Fsignal (Qmalformed_list, list1 (list));
+  signal_error (Qmalformed_list, list1 (list));
 }
 
-void
+DOESNT_RETURN
 signal_malformed_property_list_error (Lisp_Object list)
 {
-  Fsignal (Qmalformed_property_list, list1 (list));
+  signal_error (Qmalformed_property_list, list1 (list));
 }
 
-void
+DOESNT_RETURN
 signal_circular_list_error (Lisp_Object list)
 {
-  Fsignal (Qcircular_list, list1 (list));
+  signal_error (Qcircular_list, list1 (list));
 }
 
-void
+DOESNT_RETURN
 signal_circular_property_list_error (Lisp_Object list)
 {
-  Fsignal (Qcircular_property_list, list1 (list));
+  signal_error (Qcircular_property_list, list1 (list));
 }
 \f
 /************************************************************************/
@@ -2740,7 +2740,7 @@ this does nothing and returns nil.
       /* Attempt to avoid consing identical (string=) pure strings. */
       file = Fsymbol_name (Fintern (file, Qnil));
     }
-  
+
   return Ffset (function, Fcons (Qautoload, list4 (file,
                                                   docstring,
                                                   interactive,
@@ -3006,7 +3006,7 @@ Evaluate FORM and return its value.
       else
        {
        wrong_number_of_arguments:
-         signal_wrong_number_of_arguments_error (fun, nargs);
+         val = signal_wrong_number_of_arguments_error (original_fun, nargs);
        }
     }
   else if (COMPILED_FUNCTIONP (fun))
@@ -3094,7 +3094,7 @@ Evaluate FORM and return its value.
   else /* ! (SUBRP (fun) || COMPILED_FUNCTIONP (fun) || CONSP (fun)) */
     {
     invalid_function:
-      signal_invalid_function_error (fun);
+      val = signal_invalid_function_error (fun);
     }
 
   lisp_eval_depth--;
@@ -3169,14 +3169,15 @@ Thus, (funcall 'cons 'x 'y) returns (x . y).
       int max_args = subr->max_args;
       Lisp_Object spacious_args[SUBR_MAX_ARGS];
 
-      if (fun_nargs < subr->min_args)
-       goto wrong_number_of_arguments;
-
       if (fun_nargs == max_args) /* Optimize for the common case */
        {
        funcall_subr:
          FUNCALL_SUBR (val, subr, fun_args, max_args);
        }
+      else if (fun_nargs < subr->min_args)
+       {
+         goto wrong_number_of_arguments;
+       }
       else if (fun_nargs < max_args)
        {
          Lisp_Object *p = spacious_args;
@@ -3192,8 +3193,7 @@ Thus, (funcall 'cons 'x 'y) returns (x . y).
        }
       else if (max_args == MANY)
        {
-         val = ((Lisp_Object (*) (int, Lisp_Object *)) subr_function (subr))
-           (fun_nargs, fun_args);
+         val = SUBR_FUNCTION (subr, MANY) (fun_nargs, fun_args);
        }
       else if (max_args == UNEVALLED) /* Can't funcall a special form */
        {
@@ -3202,7 +3202,7 @@ Thus, (funcall 'cons 'x 'y) returns (x . y).
       else
        {
        wrong_number_of_arguments:
-         signal_wrong_number_of_arguments_error (fun, fun_nargs);
+         val = signal_wrong_number_of_arguments_error (fun, fun_nargs);
        }
     }
   else if (COMPILED_FUNCTIONP (fun))
@@ -3229,12 +3229,12 @@ Thus, (funcall 'cons 'x 'y) returns (x . y).
     }
   else if (UNBOUNDP (fun))
     {
-      signal_void_function_error (args[0]);
+      val = signal_void_function_error (args[0]);
     }
   else
     {
     invalid_function:
-      signal_invalid_function_error (fun);
+      val = signal_invalid_function_error (fun);
     }
 
   lisp_eval_depth--;
@@ -3310,7 +3310,7 @@ function_argcount (Lisp_Object function, int function_min_args_p)
   else
     {
     invalid_function:
-      return Fsignal (Qinvalid_function, list1 (function));
+      return signal_invalid_function_error (function);
     }
 
   {
@@ -3497,10 +3497,10 @@ funcall_lambda (Lisp_Object fun, int nargs, Lisp_Object args[])
   return unbind_to (speccount, Fprogn (body));
 
  wrong_number_of_arguments:
-  return Fsignal (Qwrong_number_of_arguments, list2 (fun, make_int (nargs)));
+  return signal_wrong_number_of_arguments_error (fun, nargs);
 
  invalid_function:
-  return Fsignal (Qinvalid_function, list1 (fun));
+  return signal_invalid_function_error (fun);
 }
 
 \f
@@ -4463,7 +4463,7 @@ specbind_unwind_local (Lisp_Object ovalue)
 {
   Lisp_Object current = Fcurrent_buffer ();
   Lisp_Object symbol = specpdl_ptr->symbol;
-  struct Lisp_Cons *victim = XCONS (ovalue);
+  Lisp_Cons *victim = XCONS (ovalue);
   Lisp_Object buf = get_buffer (victim->car, 0);
   ovalue = victim->cdr;
 
@@ -4617,7 +4617,7 @@ unbind_to_hairy (int count)
        {
          /* We checked symbol for validity when we specbound it,
             so only need to call Fset if symbol has magic value.  */
-         struct Lisp_Symbol *sym = XSYMBOL (specpdl_ptr->symbol);
+         Lisp_Symbol *sym = XSYMBOL (specpdl_ptr->symbol);
          if (!SYMBOL_VALUE_MAGIC_P (sym->value))
            sym->value = specpdl_ptr->old_value;
          else
@@ -4743,7 +4743,7 @@ backtrace_specials (int speccount, int speclimit, Lisp_Object stream)
 
 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /*
 Print a trace of Lisp function calls currently active.
-Option arg STREAM specifies the output stream to send the backtrace to,
+Optional arg STREAM specifies the output stream to send the backtrace to,
 and defaults to the value of `standard-output'.  Optional second arg
 DETAILED means show places where currently active variable bindings,
 catches, condition-cases, and unwind-protects were made as well as
@@ -4786,8 +4786,8 @@ function calls.
       if (!NILP (detailed) && catches && catches->backlist == backlist)
        {
           int catchpdl = catches->pdlcount;
-          if (specpdl[catchpdl].func == condition_case_unwind
-              && speccount > catchpdl)
+          if (speccount > catchpdl
+             && specpdl[catchpdl].func == condition_case_unwind)
             /* This is a condition-case catchpoint */
             catchpdl = catchpdl + 1;