diff options
| author | Dmitry Antipov | 2012-07-30 10:43:46 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-30 10:43:46 +0400 |
| commit | 6cd7a13902729007a4d1e14a299bad47c9808353 (patch) | |
| tree | 4c292449725756a65bca595d97a33740c3851094 /src | |
| parent | 227f5bd0b41ebec90ec61a2b8832c95cec20c5a9 (diff) | |
| download | emacs-6cd7a13902729007a4d1e14a299bad47c9808353.tar.gz emacs-6cd7a13902729007a4d1e14a299bad47c9808353.zip | |
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/ChangeLog | 9 | ||||
| -rw-r--r-- | src/coding.c | 7 | ||||
| -rw-r--r-- | src/composite.c | 12 | ||||
| -rw-r--r-- | src/keyboard.c | 9 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/term.c | 3 | ||||
| -rw-r--r-- | src/xdisp.c | 32 | ||||
| -rw-r--r-- | src/xfaces.c | 6 |
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 @@ | |||
| 1 | 2012-07-30 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Convert safe_call to use variable number of arguments. | ||
| 4 | * xdisp.c (safe_call): Convert to use varargs. Adjust users. | ||
| 5 | (safe_call2): Fix comment. | ||
| 6 | * lisp.h (safe_call): Adjust prototype. | ||
| 7 | * coding.c (encode_coding_object): Change to use safe_call2. | ||
| 8 | * xfaces.c (merge_face_heights): Change to use safe_call1. | ||
| 9 | |||
| 1 | 2012-07-30 Glenn Morris <rgm@gnu.org> | 10 | 2012-07-30 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * s/aix4-2.h (sigmask): No need to undefine it, since syssignal.h | 12 | * 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, | |||
| 7931 | } | 7931 | } |
| 7932 | 7932 | ||
| 7933 | { | 7933 | { |
| 7934 | Lisp_Object args[3]; | ||
| 7935 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 7934 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 7936 | 7935 | ||
| 7937 | GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, | 7936 | GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, |
| 7938 | old_deactivate_mark); | 7937 | old_deactivate_mark); |
| 7939 | args[0] = CODING_ATTR_PRE_WRITE (attrs); | 7938 | safe_call2 (CODING_ATTR_PRE_WRITE (attrs), |
| 7940 | args[1] = make_number (BEG); | 7939 | make_number (BEG), make_number (Z)); |
| 7941 | args[2] = make_number (Z); | ||
| 7942 | safe_call (3, args); | ||
| 7943 | UNGCPRO; | 7940 | UNGCPRO; |
| 7944 | } | 7941 | } |
| 7945 | if (XBUFFER (coding->src_object) != current_buffer) | 7942 | 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 | |||
| 947 | string); | 947 | string); |
| 948 | if (NILP (LGSTRING_ID (lgstring))) | 948 | if (NILP (LGSTRING_ID (lgstring))) |
| 949 | { | 949 | { |
| 950 | Lisp_Object args[6]; | ||
| 951 | |||
| 952 | /* Save point as marker before calling out to lisp. */ | 950 | /* Save point as marker before calling out to lisp. */ |
| 953 | if (NILP (string)) | 951 | if (NILP (string)) |
| 954 | record_unwind_protect (restore_point_unwind, | 952 | record_unwind_protect (restore_point_unwind, |
| 955 | build_marker (current_buffer, pt, pt_byte)); | 953 | build_marker (current_buffer, pt, pt_byte)); |
| 956 | 954 | lgstring = safe_call (6, Vauto_composition_function, AREF (rule, 2), | |
| 957 | args[0] = Vauto_composition_function; | 955 | pos, make_number (to), font_object, string); |
| 958 | args[1] = AREF (rule, 2); | ||
| 959 | args[2] = pos; | ||
| 960 | args[3] = make_number (to); | ||
| 961 | args[4] = font_object; | ||
| 962 | args[5] = string; | ||
| 963 | lgstring = safe_call (6, args); | ||
| 964 | } | 956 | } |
| 965 | return unbind_to (count, lgstring); | 957 | return unbind_to (count, lgstring); |
| 966 | } | 958 | } |
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, | |||
| 2185 | if (!NILP (help) && !STRINGP (help)) | 2185 | if (!NILP (help) && !STRINGP (help)) |
| 2186 | { | 2186 | { |
| 2187 | if (FUNCTIONP (help)) | 2187 | if (FUNCTIONP (help)) |
| 2188 | { | 2188 | help = safe_call (4, help, window, object, pos); |
| 2189 | Lisp_Object args[4]; | ||
| 2190 | args[0] = help; | ||
| 2191 | args[1] = window; | ||
| 2192 | args[2] = object; | ||
| 2193 | args[3] = pos; | ||
| 2194 | help = safe_call (4, args); | ||
| 2195 | } | ||
| 2196 | else | 2189 | else |
| 2197 | help = safe_eval (help); | 2190 | help = safe_eval (help); |
| 2198 | 2191 | ||
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) | |||
| 2842 | ATTRIBUTE_FORMAT_PRINTF (1, 0); | 2842 | ATTRIBUTE_FORMAT_PRINTF (1, 0); |
| 2843 | extern Lisp_Object un_autoload (Lisp_Object); | 2843 | extern Lisp_Object un_autoload (Lisp_Object); |
| 2844 | extern void init_eval_once (void); | 2844 | extern void init_eval_once (void); |
| 2845 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *); | 2845 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); |
| 2846 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); | 2846 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); |
| 2847 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); | 2847 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 2848 | extern void init_eval (void); | 2848 | 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) | |||
| 2209 | 2209 | ||
| 2210 | if (mode != tty->previous_color_mode) | 2210 | if (mode != tty->previous_color_mode) |
| 2211 | { | 2211 | { |
| 2212 | Lisp_Object funsym = intern ("tty-set-up-initial-frame-faces"); | ||
| 2213 | tty->previous_color_mode = mode; | 2212 | tty->previous_color_mode = mode; |
| 2214 | tty_setup_colors (tty , mode); | 2213 | tty_setup_colors (tty , mode); |
| 2215 | /* This recomputes all the faces given the new color definitions. */ | 2214 | /* This recomputes all the faces given the new color definitions. */ |
| 2216 | safe_call (1, &funsym); | 2215 | safe_call (1, intern ("tty-set-up-initial-frame-faces")); |
| 2217 | } | 2216 | } |
| 2218 | } | 2217 | } |
| 2219 | 2218 | ||
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) | |||
| 2403 | return Qnil; | 2403 | return Qnil; |
| 2404 | } | 2404 | } |
| 2405 | 2405 | ||
| 2406 | 2406 | /* Call function FUNC with the rest of NARGS - 1 arguments | |
| 2407 | /* Evaluate SEXPR and return the result, or nil if something went | 2407 | following. Return the result, or nil if something went |
| 2408 | wrong. Prevent redisplay during the evaluation. */ | 2408 | wrong. Prevent redisplay during the evaluation. */ |
| 2409 | 2409 | ||
| 2410 | /* Call function ARGS[0] with arguments ARGS[1] to ARGS[NARGS - 1]. | ||
| 2411 | Return the result, or nil if something went wrong. Prevent | ||
| 2412 | redisplay during the evaluation. */ | ||
| 2413 | |||
| 2414 | Lisp_Object | 2410 | Lisp_Object |
| 2415 | safe_call (ptrdiff_t nargs, Lisp_Object *args) | 2411 | safe_call (ptrdiff_t nargs, Lisp_Object func, ...) |
| 2416 | { | 2412 | { |
| 2417 | Lisp_Object val; | 2413 | Lisp_Object val; |
| 2418 | 2414 | ||
| @@ -2420,8 +2416,17 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args) | |||
| 2420 | val = Qnil; | 2416 | val = Qnil; |
| 2421 | else | 2417 | else |
| 2422 | { | 2418 | { |
| 2419 | va_list ap; | ||
| 2420 | ptrdiff_t i; | ||
| 2423 | ptrdiff_t count = SPECPDL_INDEX (); | 2421 | ptrdiff_t count = SPECPDL_INDEX (); |
| 2424 | struct gcpro gcpro1; | 2422 | struct gcpro gcpro1; |
| 2423 | Lisp_Object *args = alloca (nargs * sizeof (Lisp_Object)); | ||
| 2424 | |||
| 2425 | args[0] = func; | ||
| 2426 | va_start (ap, func); | ||
| 2427 | for (i = 1; i < nargs; i++) | ||
| 2428 | args[i] = va_arg (ap, Lisp_Object); | ||
| 2429 | va_end (ap); | ||
| 2425 | 2430 | ||
| 2426 | GCPRO1 (args[0]); | 2431 | GCPRO1 (args[0]); |
| 2427 | gcpro1.nvars = nargs; | 2432 | gcpro1.nvars = nargs; |
| @@ -2444,10 +2449,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object *args) | |||
| 2444 | Lisp_Object | 2449 | Lisp_Object |
| 2445 | safe_call1 (Lisp_Object fn, Lisp_Object arg) | 2450 | safe_call1 (Lisp_Object fn, Lisp_Object arg) |
| 2446 | { | 2451 | { |
| 2447 | Lisp_Object args[2]; | 2452 | return safe_call (2, fn, arg); |
| 2448 | args[0] = fn; | ||
| 2449 | args[1] = arg; | ||
| 2450 | return safe_call (2, args); | ||
| 2451 | } | 2453 | } |
| 2452 | 2454 | ||
| 2453 | static Lisp_Object Qeval; | 2455 | static Lisp_Object Qeval; |
| @@ -2458,17 +2460,13 @@ safe_eval (Lisp_Object sexpr) | |||
| 2458 | return safe_call1 (Qeval, sexpr); | 2460 | return safe_call1 (Qeval, sexpr); |
| 2459 | } | 2461 | } |
| 2460 | 2462 | ||
| 2461 | /* Call function FN with one argument ARG. | 2463 | /* Call function FN with two arguments ARG1 and ARG2. |
| 2462 | Return the result, or nil if something went wrong. */ | 2464 | Return the result, or nil if something went wrong. */ |
| 2463 | 2465 | ||
| 2464 | Lisp_Object | 2466 | Lisp_Object |
| 2465 | safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2) | 2467 | safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2) |
| 2466 | { | 2468 | { |
| 2467 | Lisp_Object args[3]; | 2469 | return safe_call (3, fn, arg1, arg2); |
| 2468 | args[0] = fn; | ||
| 2469 | args[1] = arg1; | ||
| 2470 | args[2] = arg2; | ||
| 2471 | return safe_call (3, args); | ||
| 2472 | } | 2470 | } |
| 2473 | 2471 | ||
| 2474 | 2472 | ||
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) | |||
| 2254 | { | 2254 | { |
| 2255 | /* Call function with current height as argument. | 2255 | /* Call function with current height as argument. |
| 2256 | From is the new height. */ | 2256 | From is the new height. */ |
| 2257 | Lisp_Object args[2]; | 2257 | result = safe_call1 (from, to); |
| 2258 | |||
| 2259 | args[0] = from; | ||
| 2260 | args[1] = to; | ||
| 2261 | result = safe_call (2, args); | ||
| 2262 | 2258 | ||
| 2263 | /* Ensure that if TO was absolute, so is the result. */ | 2259 | /* Ensure that if TO was absolute, so is the result. */ |
| 2264 | if (INTEGERP (to) && !INTEGERP (result)) | 2260 | if (INTEGERP (to) && !INTEGERP (result)) |