summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2012-07-30 10:43:46 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2012-07-30 10:43:46 +0400
commit6cd7a13902729007a4d1e14a299bad47c9808353 (patch)
tree4c292449725756a65bca595d97a33740c3851094 /src
parent227f5bd0b41ebec90ec61a2b8832c95cec20c5a9 (diff)
downloademacs-6cd7a13902729007a4d1e14a299bad47c9808353.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/coding.c7
-rw-r--r--src/composite.c12
-rw-r--r--src/keyboard.c9
-rw-r--r--src/lisp.h2
-rw-r--r--src/term.c3
-rw-r--r--src/xdisp.c32
-rw-r--r--src/xfaces.c6
8 files changed, 32 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 78205746c4f..41d7759cfb5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+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>
* s/aix4-2.h (sigmask): No need to undefine it, since syssignal.h
diff --git a/src/coding.c b/src/coding.c
index 7b178b0ce14..e4ed65079d9 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -7931,15 +7931,12 @@ encode_coding_object (struct coding_system *coding,
}
{
- Lisp_Object args[3];
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
old_deactivate_mark);
- args[0] = CODING_ATTR_PRE_WRITE (attrs);
- args[1] = make_number (BEG);
- args[2] = make_number (Z);
- safe_call (3, args);
+ safe_call2 (CODING_ATTR_PRE_WRITE (attrs),
+ make_number (BEG), make_number (Z));
UNGCPRO;
}
if (XBUFFER (coding->src_object) != current_buffer)
diff --git a/src/composite.c b/src/composite.c
index bfc8093a87f..62ab3d04948 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -947,20 +947,12 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t
string);
if (NILP (LGSTRING_ID (lgstring)))
{
- Lisp_Object args[6];
-
/* Save point as marker before calling out to lisp. */
if (NILP (string))
record_unwind_protect (restore_point_unwind,
build_marker (current_buffer, pt, pt_byte));
-
- args[0] = Vauto_composition_function;
- 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);
+ lgstring = safe_call (6, Vauto_composition_function, AREF (rule, 2),
+ pos, make_number (to), font_object, string);
}
return unbind_to (count, lgstring);
}
diff --git a/src/keyboard.c b/src/keyboard.c
index 1f6c47eaf79..00e6f4cbbe9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2185,14 +2185,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
if (!NILP (help) && !STRINGP (help))
{
if (FUNCTIONP (help))
- {
- Lisp_Object args[4];
- args[0] = help;
- args[1] = window;
- args[2] = object;
- args[3] = pos;
- help = safe_call (4, args);
- }
+ help = safe_call (4, help, window, object, pos);
else
help = safe_eval (help);
diff --git a/src/lisp.h b/src/lisp.h
index cf5c70bf1e4..491f648de75 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2842,7 +2842,7 @@ extern _Noreturn void verror (const char *, va_list)
ATTRIBUTE_FORMAT_PRINTF (1, 0);
extern Lisp_Object un_autoload (Lisp_Object);
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_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
extern void init_eval (void);
diff --git a/src/term.c b/src/term.c
index 4d73f896d21..f24caeffebb 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2209,11 +2209,10 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
if (mode != tty->previous_color_mode)
{
- Lisp_Object funsym = intern ("tty-set-up-initial-frame-faces");
tty->previous_color_mode = mode;
tty_setup_colors (tty , mode);
/* This recomputes all the faces given the new color definitions. */
- safe_call (1, &funsym);
+ safe_call (1, intern ("tty-set-up-initial-frame-faces"));
}
}
diff --git a/src/xdisp.c b/src/xdisp.c
index a11b117f067..83f0ae830f8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2403,16 +2403,12 @@ safe_eval_handler (Lisp_Object arg)
return Qnil;
}
-
-/* Evaluate SEXPR and return the result, or nil if something went
+/* Call function FUNC with the rest of NARGS - 1 arguments
+ following. Return the result, or nil if something went
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
-safe_call (ptrdiff_t nargs, Lisp_Object *args)
+safe_call (ptrdiff_t nargs, Lisp_Object func, ...)
{
Lisp_Object val;
@@ -2420,8 +2416,17 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args)
val = Qnil;
else
{
+ va_list ap;
+ ptrdiff_t i;
ptrdiff_t count = SPECPDL_INDEX ();
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.nvars = nargs;
@@ -2444,10 +2449,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args)
Lisp_Object
safe_call1 (Lisp_Object fn, Lisp_Object arg)
{
- Lisp_Object args[2];
- args[0] = fn;
- args[1] = arg;
- return safe_call (2, args);
+ return safe_call (2, fn, arg);
}
static Lisp_Object Qeval;
@@ -2458,17 +2460,13 @@ safe_eval (Lisp_Object 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. */
Lisp_Object
safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
{
- Lisp_Object args[3];
- args[0] = fn;
- args[1] = arg1;
- args[2] = arg2;
- return safe_call (3, args);
+ return safe_call (3, fn, arg1, arg2);
}
diff --git a/src/xfaces.c b/src/xfaces.c
index e9089017c4e..6a34c3c8893 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2254,11 +2254,7 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid)
{
/* Call function with current height as argument.
From is the new height. */
- Lisp_Object args[2];
-
- args[0] = from;
- args[1] = to;
- result = safe_call (2, args);
+ result = safe_call1 (from, to);
/* Ensure that if TO was absolute, so is the result. */
if (INTEGERP (to) && !INTEGERP (result))