Commit 6cd7a139 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

Convert safe_call to use variable number of arguments.

* xdisp.c (safe_call): Convert to use varargs.  Adjust users.
(safe_call2): Fix comment.
* lisp.h (safe_call): Adjust prototype.
* coding.c (encode_coding_object): Change to use safe_call2.
* xfaces.c (merge_face_heights): Change to use safe_call1.
parent 227f5bd0
2012-07-30 Dmitry Antipov <dmantipov@yandex.ru>
Convert safe_call to use variable number of arguments.
* xdisp.c (safe_call): Convert to use varargs. Adjust users.
(safe_call2): Fix comment.
* lisp.h (safe_call): Adjust prototype.
* coding.c (encode_coding_object): Change to use safe_call2.
* xfaces.c (merge_face_heights): Change to use safe_call1.
2012-07-30 Glenn Morris <rgm@gnu.org> 2012-07-30 Glenn Morris <rgm@gnu.org>
   
* s/aix4-2.h (sigmask): No need to undefine it, since syssignal.h * s/aix4-2.h (sigmask): No need to undefine it, since syssignal.h
......
...@@ -7931,15 +7931,12 @@ encode_coding_object (struct coding_system *coding, ...@@ -7931,15 +7931,12 @@ encode_coding_object (struct coding_system *coding,
} }
{ {
Lisp_Object args[3];
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
old_deactivate_mark); old_deactivate_mark);
args[0] = CODING_ATTR_PRE_WRITE (attrs); safe_call2 (CODING_ATTR_PRE_WRITE (attrs),
args[1] = make_number (BEG); make_number (BEG), make_number (Z));
args[2] = make_number (Z);
safe_call (3, args);
UNGCPRO; UNGCPRO;
} }
if (XBUFFER (coding->src_object) != current_buffer) if (XBUFFER (coding->src_object) != current_buffer)
......
...@@ -947,20 +947,12 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t ...@@ -947,20 +947,12 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t
string); string);
if (NILP (LGSTRING_ID (lgstring))) if (NILP (LGSTRING_ID (lgstring)))
{ {
Lisp_Object args[6];
/* Save point as marker before calling out to lisp. */ /* Save point as marker before calling out to lisp. */
if (NILP (string)) if (NILP (string))
record_unwind_protect (restore_point_unwind, record_unwind_protect (restore_point_unwind,
build_marker (current_buffer, pt, pt_byte)); build_marker (current_buffer, pt, pt_byte));
lgstring = safe_call (6, Vauto_composition_function, AREF (rule, 2),
args[0] = Vauto_composition_function; pos, make_number (to), font_object, string);
args[1] = AREF (rule, 2);
args[2] = pos;
args[3] = make_number (to);
args[4] = font_object;
args[5] = string;
lgstring = safe_call (6, args);
} }
return unbind_to (count, lgstring); return unbind_to (count, lgstring);
} }
......
...@@ -2185,14 +2185,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, ...@@ -2185,14 +2185,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
if (!NILP (help) && !STRINGP (help)) if (!NILP (help) && !STRINGP (help))
{ {
if (FUNCTIONP (help)) if (FUNCTIONP (help))
{ help = safe_call (4, help, window, object, pos);
Lisp_Object args[4];
args[0] = help;
args[1] = window;
args[2] = object;
args[3] = pos;
help = safe_call (4, args);
}
else else
help = safe_eval (help); help = safe_eval (help);
......
...@@ -2842,7 +2842,7 @@ extern _Noreturn void verror (const char *, va_list) ...@@ -2842,7 +2842,7 @@ extern _Noreturn void verror (const char *, va_list)
ATTRIBUTE_FORMAT_PRINTF (1, 0); ATTRIBUTE_FORMAT_PRINTF (1, 0);
extern Lisp_Object un_autoload (Lisp_Object); extern Lisp_Object un_autoload (Lisp_Object);
extern void init_eval_once (void); extern void init_eval_once (void);
extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *); extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
extern void init_eval (void); extern void init_eval (void);
......
...@@ -2209,11 +2209,10 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f) ...@@ -2209,11 +2209,10 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
if (mode != tty->previous_color_mode) if (mode != tty->previous_color_mode)
{ {
Lisp_Object funsym = intern ("tty-set-up-initial-frame-faces");
tty->previous_color_mode = mode; tty->previous_color_mode = mode;
tty_setup_colors (tty , mode); tty_setup_colors (tty , mode);
/* This recomputes all the faces given the new color definitions. */ /* This recomputes all the faces given the new color definitions. */
safe_call (1, &funsym); safe_call (1, intern ("tty-set-up-initial-frame-faces"));
} }
} }
......
...@@ -2403,16 +2403,12 @@ safe_eval_handler (Lisp_Object arg) ...@@ -2403,16 +2403,12 @@ safe_eval_handler (Lisp_Object arg)
return Qnil; return Qnil;
} }
   
/* Call function FUNC with the rest of NARGS - 1 arguments
/* Evaluate SEXPR and return the result, or nil if something went following. Return the result, or nil if something went
wrong. Prevent redisplay during the evaluation. */ wrong. Prevent redisplay during the evaluation. */
   
/* Call function ARGS[0] with arguments ARGS[1] to ARGS[NARGS - 1].
Return the result, or nil if something went wrong. Prevent
redisplay during the evaluation. */
Lisp_Object Lisp_Object
safe_call (ptrdiff_t nargs, Lisp_Object *args) safe_call (ptrdiff_t nargs, Lisp_Object func, ...)
{ {
Lisp_Object val; Lisp_Object val;
   
...@@ -2420,8 +2416,17 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args) ...@@ -2420,8 +2416,17 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args)
val = Qnil; val = Qnil;
else else
{ {
va_list ap;
ptrdiff_t i;
ptrdiff_t count = SPECPDL_INDEX (); ptrdiff_t count = SPECPDL_INDEX ();
struct gcpro gcpro1; struct gcpro gcpro1;
Lisp_Object *args = alloca (nargs * sizeof (Lisp_Object));
args[0] = func;
va_start (ap, func);
for (i = 1; i < nargs; i++)
args[i] = va_arg (ap, Lisp_Object);
va_end (ap);
   
GCPRO1 (args[0]); GCPRO1 (args[0]);
gcpro1.nvars = nargs; gcpro1.nvars = nargs;
...@@ -2444,10 +2449,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args) ...@@ -2444,10 +2449,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args)
Lisp_Object Lisp_Object
safe_call1 (Lisp_Object fn, Lisp_Object arg) safe_call1 (Lisp_Object fn, Lisp_Object arg)
{ {
Lisp_Object args[2]; return safe_call (2, fn, arg);
args[0] = fn;
args[1] = arg;
return safe_call (2, args);
} }
   
static Lisp_Object Qeval; static Lisp_Object Qeval;
...@@ -2458,17 +2460,13 @@ safe_eval (Lisp_Object sexpr) ...@@ -2458,17 +2460,13 @@ safe_eval (Lisp_Object sexpr)
return safe_call1 (Qeval, sexpr); return safe_call1 (Qeval, sexpr);
} }
   
/* Call function FN with one argument ARG. /* Call function FN with two arguments ARG1 and ARG2.
Return the result, or nil if something went wrong. */ Return the result, or nil if something went wrong. */
   
Lisp_Object Lisp_Object
safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2) safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
{ {
Lisp_Object args[3]; return safe_call (3, fn, arg1, arg2);
args[0] = fn;
args[1] = arg1;
args[2] = arg2;
return safe_call (3, args);
} }
   
   
......
...@@ -2254,11 +2254,7 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) ...@@ -2254,11 +2254,7 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid)
{ {
/* Call function with current height as argument. /* Call function with current height as argument.
From is the new height. */ From is the new height. */
Lisp_Object args[2]; result = safe_call1 (from, to);
args[0] = from;
args[1] = to;
result = safe_call (2, args);
/* Ensure that if TO was absolute, so is the result. */ /* Ensure that if TO was absolute, so is the result. */
if (INTEGERP (to) && !INTEGERP (result)) if (INTEGERP (to) && !INTEGERP (result))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment