static Lisp_Object
safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args)
{
- eassert (nargs == 2);
- return call0 (args[1]);
+ eassert (nargs >= 2 && nargs <= 4);
+ switch (nargs)
+ {
+ case 2:
+ return call0 (args[1]);
+ case 3:
+ return call1 (args[1], args[2]);
+ default:
+ return call2 (args[1], args[2], args[3]);
+ }
}
/* Subroutine for safe_run_hooks: handle an error by clearing out the function
static Lisp_Object
safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
{
- eassert (nargs == 2);
+ eassert (nargs >= 2 && nargs <= 4);
/* Yes, run_hook_with_args works with args in the other order. */
- internal_condition_case_n (safe_run_hooks_1,
- 2, ((Lisp_Object []) {args[1], args[0]}),
- Qt, safe_run_hooks_error);
+ switch (nargs)
+ {
+ case 2:
+ internal_condition_case_n (safe_run_hooks_1,
+ 2, ((Lisp_Object []) {args[1], args[0]}),
+ Qt, safe_run_hooks_error);
+ break;
+ case 3:
+ internal_condition_case_n (safe_run_hooks_1,
+ 3, ((Lisp_Object []) {args[1], args[0], args[2]}),
+ Qt, safe_run_hooks_error);
+ break;
+ default:
+ internal_condition_case_n (safe_run_hooks_1,
+ 4, ((Lisp_Object [])
+ {args[1], args[0], args[2], args[3]}),
+ Qt, safe_run_hooks_error);
+ break;
+ }
return Qnil;
}