comparison src/eval.c @ 50644:0c4bf42e6557

(Fapply): Undo last change and add a comment about why.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 19 Apr 2003 18:58:56 +0000
parents dfbdcffdcfc9
children f38d1373681e
comparison
equal deleted inserted replaced
50643:da94760ca8cb 50644:0c4bf42e6557
2159 { 2159 {
2160 register int i, numargs; 2160 register int i, numargs;
2161 register Lisp_Object spread_arg; 2161 register Lisp_Object spread_arg;
2162 register Lisp_Object *funcall_args; 2162 register Lisp_Object *funcall_args;
2163 Lisp_Object fun; 2163 Lisp_Object fun;
2164 int nvars; 2164 struct gcpro gcpro1;
2165 2165
2166 fun = args [0]; 2166 fun = args [0];
2167 funcall_args = 0; 2167 funcall_args = 0;
2168 spread_arg = args [nargs - 1]; 2168 spread_arg = args [nargs - 1];
2169 CHECK_LIST (spread_arg); 2169 CHECK_LIST (spread_arg);
2199 by explicitly supplying nil's for optional values */ 2199 by explicitly supplying nil's for optional values */
2200 funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args) 2200 funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args)
2201 * sizeof (Lisp_Object)); 2201 * sizeof (Lisp_Object));
2202 for (i = numargs; i < XSUBR (fun)->max_args;) 2202 for (i = numargs; i < XSUBR (fun)->max_args;)
2203 funcall_args[++i] = Qnil; 2203 funcall_args[++i] = Qnil;
2204 nvars = 1 + XSUBR (fun)->max_args; 2204 GCPRO1 (*funcall_args);
2205 gcpro1.nvars = 1 + XSUBR (fun)->max_args;
2205 } 2206 }
2206 } 2207 }
2207 funcall: 2208 funcall:
2208 /* We add 1 to numargs because funcall_args includes the 2209 /* We add 1 to numargs because funcall_args includes the
2209 function itself as well as its arguments. */ 2210 function itself as well as its arguments. */
2210 if (!funcall_args) 2211 if (!funcall_args)
2211 { 2212 {
2212 funcall_args = (Lisp_Object *) alloca ((1 + numargs) 2213 funcall_args = (Lisp_Object *) alloca ((1 + numargs)
2213 * sizeof (Lisp_Object)); 2214 * sizeof (Lisp_Object));
2214 nvars = 1 + numargs; 2215 GCPRO1 (*funcall_args);
2216 gcpro1.nvars = 1 + numargs;
2215 } 2217 }
2216 2218
2217 bcopy (args, funcall_args, nargs * sizeof (Lisp_Object)); 2219 bcopy (args, funcall_args, nargs * sizeof (Lisp_Object));
2218 /* Spread the last arg we got. Its first element goes in 2220 /* Spread the last arg we got. Its first element goes in
2219 the slot that it used to occupy, hence this value of I. */ 2221 the slot that it used to occupy, hence this value of I. */
2222 { 2224 {
2223 funcall_args [i++] = XCAR (spread_arg); 2225 funcall_args [i++] = XCAR (spread_arg);
2224 spread_arg = XCDR (spread_arg); 2226 spread_arg = XCDR (spread_arg);
2225 } 2227 }
2226 2228
2227 return Ffuncall (nvars, funcall_args); 2229 /* By convention, the caller needs to gcpro Ffuncall's args. */
2230 RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));
2228 } 2231 }
2229 2232
2230 /* Run hook variables in various ways. */ 2233 /* Run hook variables in various ways. */
2231 2234
2232 enum run_hooks_condition {to_completion, until_success, until_failure}; 2235 enum run_hooks_condition {to_completion, until_success, until_failure};