Commit 6194477a authored by Stefan Monnier's avatar Stefan Monnier

* src/eval.c (backtrace_eval_unrewind): Rewind also the excursions.

(Fapply): Try and simplify the control flow.
parent 64755ed3
2014-12-04 Stefan Monnier <monnier@iro.umontreal.ca>
* eval.c (backtrace_eval_unrewind): Rewind also the excursions.
(Fapply): Try and simplify the control flow.
2014-12-03 Chris Zheng <chriszheng99@gmail.com> (tiny change) 2014-12-03 Chris Zheng <chriszheng99@gmail.com> (tiny change)
* gnutls.c (init_gnutls_functions, gnutls_certificate_details): * gnutls.c (init_gnutls_functions, gnutls_certificate_details):
......
...@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "commands.h" #include "commands.h"
#include "keyboard.h" #include "keyboard.h"
#include "dispextern.h" #include "dispextern.h"
#include "buffer.h"
/* Chain of condition and catch handlers currently in effect. */ /* Chain of condition and catch handlers currently in effect. */
...@@ -2272,14 +2273,12 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) ...@@ -2272,14 +2273,12 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
(ptrdiff_t nargs, Lisp_Object *args) (ptrdiff_t nargs, Lisp_Object *args)
{ {
ptrdiff_t i, numargs, funcall_nargs; ptrdiff_t i, numargs, funcall_nargs;
register Lisp_Object spread_arg; register Lisp_Object *funcall_args = NULL;
register Lisp_Object *funcall_args; register Lisp_Object spread_arg = args[nargs - 1];
Lisp_Object fun, retval; Lisp_Object fun = args[0];
Lisp_Object retval;
USE_SAFE_ALLOCA; USE_SAFE_ALLOCA;
fun = args [0];
funcall_args = 0;
spread_arg = args [nargs - 1];
CHECK_LIST (spread_arg); CHECK_LIST (spread_arg);
numargs = XINT (Flength (spread_arg)); numargs = XINT (Flength (spread_arg));
...@@ -2297,34 +2296,27 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) ...@@ -2297,34 +2296,27 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
/* Optimize for no indirection. */ /* Optimize for no indirection. */
if (SYMBOLP (fun) && !NILP (fun) if (SYMBOLP (fun) && !NILP (fun)
&& (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
fun = indirect_function (fun);
if (NILP (fun))
{ {
/* Let funcall get the error. */ fun = indirect_function (fun);
fun = args[0]; if (NILP (fun))
goto funcall; /* Let funcall get the error. */
fun = args[0];
} }
if (SUBRP (fun)) if (SUBRP (fun) && XSUBR (fun)->max_args > numargs
/* Don't hide an error by adding missing arguments. */
&& numargs >= XSUBR (fun)->min_args)
{ {
if (numargs < XSUBR (fun)->min_args /* Avoid making funcall cons up a yet another new vector of arguments
|| (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) by explicitly supplying nil's for optional values. */
goto funcall; /* Let funcall get the error. */ SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args);
else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs) for (i = numargs; i < XSUBR (fun)->max_args; /* nothing */)
{ funcall_args[++i] = Qnil;
/* Avoid making funcall cons up a yet another new vector of arguments funcall_nargs = 1 + XSUBR (fun)->max_args;
by explicitly supplying nil's for optional values. */
SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args);
for (i = numargs; i < XSUBR (fun)->max_args; /* nothing */)
funcall_args[++i] = Qnil;
funcall_nargs = 1 + XSUBR (fun)->max_args;
}
} }
funcall: else
/* We add 1 to numargs because funcall_args includes the { /* We add 1 to numargs because funcall_args includes the
function itself as well as its arguments. */ function itself as well as its arguments. */
if (!funcall_args)
{
SAFE_ALLOCA_LISP (funcall_args, 1 + numargs); SAFE_ALLOCA_LISP (funcall_args, 1 + numargs);
funcall_nargs = 1 + numargs; funcall_nargs = 1 + numargs;
} }
...@@ -3420,6 +3412,18 @@ backtrace_eval_unrewind (int distance) ...@@ -3420,6 +3412,18 @@ backtrace_eval_unrewind (int distance)
unwind_protect, but the problem is that we don't know how to unwind_protect, but the problem is that we don't know how to
rewind them afterwards. */ rewind them afterwards. */
case SPECPDL_UNWIND: case SPECPDL_UNWIND:
{
Lisp_Object oldarg = tmp->unwind.arg;
if (tmp->unwind.func == set_buffer_if_live)
tmp->unwind.arg = Fcurrent_buffer ();
else if (tmp->unwind.func == save_excursion_restore)
tmp->unwind.arg = save_excursion_save ();
else
break;
tmp->unwind.func (oldarg);
break;
}
case SPECPDL_UNWIND_PTR: case SPECPDL_UNWIND_PTR:
case SPECPDL_UNWIND_INT: case SPECPDL_UNWIND_INT:
case SPECPDL_UNWIND_VOID: case SPECPDL_UNWIND_VOID:
......
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