1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-21 12:03:55 -08:00

default_toplevel_binding, local_toplevel_binding: Loop upwards

* src/eval.c (default_toplevel_binding, local_toplevel_binding):
Loop upwards, not downwards, given that we want the earliest
relevant binding present in the stack.
This commit is contained in:
Sean Whitton 2025-05-14 18:43:22 +01:00
parent 45627ca7cc
commit f70bb4d767

View file

@ -741,43 +741,39 @@ Internal use only. */)
static union specbinding *
default_toplevel_binding (Lisp_Object symbol)
{
union specbinding *binding = NULL;
union specbinding *pdl = specpdl_ptr;
while (pdl > specpdl)
for (union specbinding *pdl = specpdl; pdl < specpdl_ptr; ++pdl)
{
switch ((--pdl)->kind)
switch (pdl->kind)
{
case SPECPDL_LET_DEFAULT:
case SPECPDL_LET:
if (EQ (specpdl_symbol (pdl), symbol))
binding = pdl;
return pdl;
break;
default: break;
}
}
return binding;
return NULL;
}
static union specbinding *
local_toplevel_binding (Lisp_Object symbol, Lisp_Object buf)
{
union specbinding *binding = NULL;
union specbinding *pdl = specpdl_ptr;
while (pdl > specpdl)
for (union specbinding *pdl = specpdl; pdl < specpdl_ptr; ++pdl)
{
switch ((--pdl)->kind)
switch (pdl->kind)
{
case SPECPDL_LET_LOCAL:
if (BASE_EQ (specpdl_where (pdl), buf)
&& EQ (specpdl_symbol (pdl), symbol))
binding = pdl;
return pdl;
break;
default: break;
}
}
return binding;
return NULL;
}
/* Look for a lexical-binding of SYMBOL somewhere up the stack.