From b5c199b1183944986fac493e2778cdc13e827440 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Mon, 10 Oct 2022 14:07:51 +0200 Subject: [PATCH] Check for keywords differently --- src/data.c | 55 ++++++++++++++++++++++++----------------------------- src/lisp.h | 14 +++++++++----- src/lread.c | 4 ++-- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/data.c b/src/data.c index 5fda374f1f6..226440c2a59 100644 --- a/src/data.c +++ b/src/data.c @@ -357,11 +357,7 @@ This means that it is a symbol with a print name beginning with `:' interned in the initial obarray. */) (Lisp_Object object) { - if (SYMBOLP (object) - && SREF (SYMBOL_NAME (object), 0) == ':' - && SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (object)) - return Qt; - return Qnil; + return pkg_keywordp (object) ? Qt : Qnil; } DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, @@ -1566,28 +1562,30 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ Lisp_Object find_symbol_value (Lisp_Object symbol) { - struct Lisp_Symbol *sym; - CHECK_SYMBOL (symbol); - sym = XSYMBOL (symbol); + struct Lisp_Symbol *sym = XSYMBOL (symbol); - start: - switch (sym->u.s.redirect) - { - case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; - case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym); - case SYMBOL_LOCALIZED: + for (;;) + switch (sym->u.s.redirect) { - struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); - swap_in_symval_forwarding (sym, blv); - return (blv->fwd.fwdptr - ? do_symval_forwarding (blv->fwd) - : blv_value (blv)); + case SYMBOL_VARALIAS: + sym = indirect_variable (sym); + break; + case SYMBOL_PLAINVAL: + return SYMBOL_VAL (sym); + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + swap_in_symval_forwarding (sym, blv); + return (blv->fwd.fwdptr + ? do_symval_forwarding (blv->fwd) + : blv_value (blv)); + } + case SYMBOL_FORWARDED: + return do_symval_forwarding (SYMBOL_FWD (sym)); + default: + emacs_abort (); } - case SYMBOL_FORWARDED: - return do_symval_forwarding (SYMBOL_FWD (sym)); - default: emacs_abort (); - } } DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, @@ -1596,13 +1594,10 @@ Note that if `lexical-binding' is in effect, this returns the global value outside of any lexical scope. */) (Lisp_Object symbol) { - Lisp_Object val; - - val = find_symbol_value (symbol); - if (!BASE_EQ (val, Qunbound)) - return val; - - xsignal1 (Qvoid_variable, symbol); + const Lisp_Object val = find_symbol_value (symbol); + if (EQ (val, Qunbound)) + xsignal1 (Qvoid_variable, symbol); + return val; } DEFUN ("set", Fset, Sset, 2, 2, 0, diff --git a/src/lisp.h b/src/lisp.h index f8267eea151..453f11dc752 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2257,8 +2257,12 @@ XPACKAGE (Lisp_Object a) extern void init_pkg_once (void); extern void init_pkg (void); extern void syms_of_pkg (void); -extern void fix_symbol_packages (void); -extern Lisp_Object pkg_insert_new_symbol (Lisp_Object symbol, Lisp_Object package); +extern Lisp_Object pkg_qualified_symbol (Lisp_Object name, Lisp_Object package, bool external); +extern void pkg_error (const char *fmt, ...); +extern Lisp_Object pkg_unqualified_symbol (Lisp_Object name); +extern bool pkg_keywordp (Lisp_Object obj); +extern Lisp_Object pkg_add_keyword (Lisp_Object sym); +extern Lisp_Object pkg_add_symbol (Lisp_Object symbol, Lisp_Object package); /* Return whether a value might be a valid docstring. @@ -4571,9 +4575,6 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char *, ptrdiff_t, /* Defined in lread.c. */ extern Lisp_Object check_obarray (Lisp_Object); -extern Lisp_Object intern_1 (const char *, ptrdiff_t); -extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); -extern Lisp_Object intern_driver (Lisp_Object, Lisp_Object, Lisp_Object); extern void init_symbol (Lisp_Object, Lisp_Object); extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t); INLINE void @@ -4596,6 +4597,9 @@ extern void init_obarray_once (void); extern void init_lread (void); extern void syms_of_lread (void); extern void mark_lread (void); +extern Lisp_Object intern_1 (const char *str, ptrdiff_t len); +extern Lisp_Object intern_c_string_1 (const char *str, ptrdiff_t len); +extern Lisp_Object intern_driver (Lisp_Object string, Lisp_Object obarray, Lisp_Object index); INLINE Lisp_Object intern (const char *str) diff --git a/src/lread.c b/src/lread.c index 87226907a99..cbf175a06bd 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4742,10 +4742,10 @@ intern_sym (Lisp_Object sym, Lisp_Object obarray, Lisp_Object index) in lexically bound elisp signal an error, as documented. */ XSYMBOL (sym)->u.s.declared_special = true; SET_SYMBOL_VAL (XSYMBOL (sym), sym); - pkg_insert_new_symbol (sym, Vkeyword_package); + pkg_add_keyword (sym); } else - pkg_insert_new_symbol (sym, Vearmuffs_package); + pkg_add_symbol (sym, Vearmuffs_package); ptr = aref_addr (obarray, XFIXNUM (index)); set_symbol_next (sym, SYMBOLP (*ptr) ? XSYMBOL (*ptr) : NULL); -- 2.39.2