diff options
| author | Stefan Monnier | 2014-12-04 14:16:59 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2014-12-04 14:16:59 -0500 |
| commit | 6194477a622ce9293162d16a7ba98c9cfc18d124 (patch) | |
| tree | a3e03ea931b77fc317a65b73e4afb144aedc3cc8 /src | |
| parent | 64755ed3add17e10a4bd3e4e270cae51cfe1d8c7 (diff) | |
| download | emacs-6194477a622ce9293162d16a7ba98c9cfc18d124.tar.gz emacs-6194477a622ce9293162d16a7ba98c9cfc18d124.zip | |
* src/eval.c (backtrace_eval_unrewind): Rewind also the excursions.
(Fapply): Try and simplify the control flow.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/eval.c | 62 |
2 files changed, 38 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a48788380f9..2f64a9758bc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-12-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * eval.c (backtrace_eval_unrewind): Rewind also the excursions. | ||
| 4 | (Fapply): Try and simplify the control flow. | ||
| 5 | |||
| 1 | 2014-12-03 Chris Zheng <chriszheng99@gmail.com> (tiny change) | 6 | 2014-12-03 Chris Zheng <chriszheng99@gmail.com> (tiny change) |
| 2 | 7 | ||
| 3 | * gnutls.c (init_gnutls_functions, gnutls_certificate_details): | 8 | * gnutls.c (init_gnutls_functions, gnutls_certificate_details): |
diff --git a/src/eval.c b/src/eval.c index 77b1db95397..8a83fdb7880 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 27 | #include "commands.h" | 27 | #include "commands.h" |
| 28 | #include "keyboard.h" | 28 | #include "keyboard.h" |
| 29 | #include "dispextern.h" | 29 | #include "dispextern.h" |
| 30 | #include "buffer.h" | ||
| 30 | 31 | ||
| 31 | /* Chain of condition and catch handlers currently in effect. */ | 32 | /* Chain of condition and catch handlers currently in effect. */ |
| 32 | 33 | ||
| @@ -2272,14 +2273,12 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) | |||
| 2272 | (ptrdiff_t nargs, Lisp_Object *args) | 2273 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2273 | { | 2274 | { |
| 2274 | ptrdiff_t i, numargs, funcall_nargs; | 2275 | ptrdiff_t i, numargs, funcall_nargs; |
| 2275 | register Lisp_Object spread_arg; | 2276 | register Lisp_Object *funcall_args = NULL; |
| 2276 | register Lisp_Object *funcall_args; | 2277 | register Lisp_Object spread_arg = args[nargs - 1]; |
| 2277 | Lisp_Object fun, retval; | 2278 | Lisp_Object fun = args[0]; |
| 2279 | Lisp_Object retval; | ||
| 2278 | USE_SAFE_ALLOCA; | 2280 | USE_SAFE_ALLOCA; |
| 2279 | 2281 | ||
| 2280 | fun = args [0]; | ||
| 2281 | funcall_args = 0; | ||
| 2282 | spread_arg = args [nargs - 1]; | ||
| 2283 | CHECK_LIST (spread_arg); | 2282 | CHECK_LIST (spread_arg); |
| 2284 | 2283 | ||
| 2285 | numargs = XINT (Flength (spread_arg)); | 2284 | numargs = XINT (Flength (spread_arg)); |
| @@ -2297,34 +2296,27 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) | |||
| 2297 | /* Optimize for no indirection. */ | 2296 | /* Optimize for no indirection. */ |
| 2298 | if (SYMBOLP (fun) && !NILP (fun) | 2297 | if (SYMBOLP (fun) && !NILP (fun) |
| 2299 | && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) | 2298 | && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) |
| 2300 | fun = indirect_function (fun); | ||
| 2301 | if (NILP (fun)) | ||
| 2302 | { | 2299 | { |
| 2303 | /* Let funcall get the error. */ | 2300 | fun = indirect_function (fun); |
| 2304 | fun = args[0]; | 2301 | if (NILP (fun)) |
| 2305 | goto funcall; | 2302 | /* Let funcall get the error. */ |
| 2303 | fun = args[0]; | ||
| 2306 | } | 2304 | } |
| 2307 | 2305 | ||
| 2308 | if (SUBRP (fun)) | 2306 | if (SUBRP (fun) && XSUBR (fun)->max_args > numargs |
| 2307 | /* Don't hide an error by adding missing arguments. */ | ||
| 2308 | && numargs >= XSUBR (fun)->min_args) | ||
| 2309 | { | 2309 | { |
| 2310 | if (numargs < XSUBR (fun)->min_args | 2310 | /* Avoid making funcall cons up a yet another new vector of arguments |
| 2311 | || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | 2311 | by explicitly supplying nil's for optional values. */ |
| 2312 | goto funcall; /* Let funcall get the error. */ | 2312 | SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args); |
| 2313 | else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs) | 2313 | for (i = numargs; i < XSUBR (fun)->max_args; /* nothing */) |
| 2314 | { | 2314 | funcall_args[++i] = Qnil; |
| 2315 | /* Avoid making funcall cons up a yet another new vector of arguments | 2315 | funcall_nargs = 1 + XSUBR (fun)->max_args; |
| 2316 | by explicitly supplying nil's for optional values. */ | ||
| 2317 | SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args); | ||
| 2318 | for (i = numargs; i < XSUBR (fun)->max_args; /* nothing */) | ||
| 2319 | funcall_args[++i] = Qnil; | ||
| 2320 | funcall_nargs = 1 + XSUBR (fun)->max_args; | ||
| 2321 | } | ||
| 2322 | } | 2316 | } |
| 2323 | funcall: | 2317 | else |
| 2324 | /* We add 1 to numargs because funcall_args includes the | 2318 | { /* We add 1 to numargs because funcall_args includes the |
| 2325 | function itself as well as its arguments. */ | 2319 | function itself as well as its arguments. */ |
| 2326 | if (!funcall_args) | ||
| 2327 | { | ||
| 2328 | SAFE_ALLOCA_LISP (funcall_args, 1 + numargs); | 2320 | SAFE_ALLOCA_LISP (funcall_args, 1 + numargs); |
| 2329 | funcall_nargs = 1 + numargs; | 2321 | funcall_nargs = 1 + numargs; |
| 2330 | } | 2322 | } |
| @@ -3420,6 +3412,18 @@ backtrace_eval_unrewind (int distance) | |||
| 3420 | unwind_protect, but the problem is that we don't know how to | 3412 | unwind_protect, but the problem is that we don't know how to |
| 3421 | rewind them afterwards. */ | 3413 | rewind them afterwards. */ |
| 3422 | case SPECPDL_UNWIND: | 3414 | case SPECPDL_UNWIND: |
| 3415 | { | ||
| 3416 | Lisp_Object oldarg = tmp->unwind.arg; | ||
| 3417 | if (tmp->unwind.func == set_buffer_if_live) | ||
| 3418 | tmp->unwind.arg = Fcurrent_buffer (); | ||
| 3419 | else if (tmp->unwind.func == save_excursion_restore) | ||
| 3420 | tmp->unwind.arg = save_excursion_save (); | ||
| 3421 | else | ||
| 3422 | break; | ||
| 3423 | tmp->unwind.func (oldarg); | ||
| 3424 | break; | ||
| 3425 | } | ||
| 3426 | |||
| 3423 | case SPECPDL_UNWIND_PTR: | 3427 | case SPECPDL_UNWIND_PTR: |
| 3424 | case SPECPDL_UNWIND_INT: | 3428 | case SPECPDL_UNWIND_INT: |
| 3425 | case SPECPDL_UNWIND_VOID: | 3429 | case SPECPDL_UNWIND_VOID: |