diff options
| author | Sean Whitton | 2025-05-14 18:43:22 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-05-15 13:40:04 +0100 |
| commit | f70bb4d7677ba308bf15f445ecc99e30754bad84 (patch) | |
| tree | 84e6638fdbc4101982de71eca2f96f141b4c2fa5 /src | |
| parent | 45627ca7ccd0e84452d497997a7f75535ed83864 (diff) | |
| download | emacs-f70bb4d7677ba308bf15f445ecc99e30754bad84.tar.gz emacs-f70bb4d7677ba308bf15f445ecc99e30754bad84.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/eval.c b/src/eval.c index cc131844428..8721f00389a 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -741,43 +741,39 @@ Internal use only. */) | |||
| 741 | static union specbinding * | 741 | static union specbinding * |
| 742 | default_toplevel_binding (Lisp_Object symbol) | 742 | default_toplevel_binding (Lisp_Object symbol) |
| 743 | { | 743 | { |
| 744 | union specbinding *binding = NULL; | 744 | for (union specbinding *pdl = specpdl; pdl < specpdl_ptr; ++pdl) |
| 745 | union specbinding *pdl = specpdl_ptr; | ||
| 746 | while (pdl > specpdl) | ||
| 747 | { | 745 | { |
| 748 | switch ((--pdl)->kind) | 746 | switch (pdl->kind) |
| 749 | { | 747 | { |
| 750 | case SPECPDL_LET_DEFAULT: | 748 | case SPECPDL_LET_DEFAULT: |
| 751 | case SPECPDL_LET: | 749 | case SPECPDL_LET: |
| 752 | if (EQ (specpdl_symbol (pdl), symbol)) | 750 | if (EQ (specpdl_symbol (pdl), symbol)) |
| 753 | binding = pdl; | 751 | return pdl; |
| 754 | break; | 752 | break; |
| 755 | 753 | ||
| 756 | default: break; | 754 | default: break; |
| 757 | } | 755 | } |
| 758 | } | 756 | } |
| 759 | return binding; | 757 | return NULL; |
| 760 | } | 758 | } |
| 761 | 759 | ||
| 762 | static union specbinding * | 760 | static union specbinding * |
| 763 | local_toplevel_binding (Lisp_Object symbol, Lisp_Object buf) | 761 | local_toplevel_binding (Lisp_Object symbol, Lisp_Object buf) |
| 764 | { | 762 | { |
| 765 | union specbinding *binding = NULL; | 763 | for (union specbinding *pdl = specpdl; pdl < specpdl_ptr; ++pdl) |
| 766 | union specbinding *pdl = specpdl_ptr; | ||
| 767 | while (pdl > specpdl) | ||
| 768 | { | 764 | { |
| 769 | switch ((--pdl)->kind) | 765 | switch (pdl->kind) |
| 770 | { | 766 | { |
| 771 | case SPECPDL_LET_LOCAL: | 767 | case SPECPDL_LET_LOCAL: |
| 772 | if (BASE_EQ (specpdl_where (pdl), buf) | 768 | if (BASE_EQ (specpdl_where (pdl), buf) |
| 773 | && EQ (specpdl_symbol (pdl), symbol)) | 769 | && EQ (specpdl_symbol (pdl), symbol)) |
| 774 | binding = pdl; | 770 | return pdl; |
| 775 | break; | 771 | break; |
| 776 | 772 | ||
| 777 | default: break; | 773 | default: break; |
| 778 | } | 774 | } |
| 779 | } | 775 | } |
| 780 | return binding; | 776 | return NULL; |
| 781 | } | 777 | } |
| 782 | 778 | ||
| 783 | /* Look for a lexical-binding of SYMBOL somewhere up the stack. | 779 | /* Look for a lexical-binding of SYMBOL somewhere up the stack. |