From d6d92270be84b819556b2b47c301bf8cf8bb4701 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Fri, 21 Oct 2022 16:14:48 +0200 Subject: [PATCH] Fixes for obarray-tests * src/pkg.c (pkg_emacs_unintern): Take args, and return a value consistent with traditional unintern. --- src/pkg.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/pkg.c b/src/pkg.c index 8570990bebe..47b647aed4f 100644 --- a/src/pkg.c +++ b/src/pkg.c @@ -562,7 +562,7 @@ pkg_emacs_intern_soft (Lisp_Object name, Lisp_Object package) name = SYMBOL_NAME (name); CHECK_STRING (name); - /* PKG-FIXME: We are assuming that this is intended to be a keyword + /* PKG-FIXME? We are assuming that this is intended to be a keyword like it was before. */ if (SREF (name, 0) == ':' && NILP (package)) { @@ -591,10 +591,37 @@ pkg_emacs_intern_soft (Lisp_Object name, Lisp_Object package) Lisp_Object pkg_emacs_unintern (Lisp_Object name, Lisp_Object package) { + /* unintern allows symbols. */ + Lisp_Object orig = name; + if (SYMBOLP (name)) + name = SYMBOL_NAME (name); + CHECK_STRING (name); + + /* PKG-FIXME? We are assuming that this is intended to be a keyword + like it was before. */ + if (SREF (name, 0) == ':' && NILP (package)) + { + name = Fsubstring (name, make_fixnum (1), Qnil); + package = Vkeyword_package; + } + + if (VECTORP (package)) + package = pkg_fake_me_an_obarray (package); + package = pkg_package_or_default (package); + + Lisp_Object found = pkg_find_symbol (name, package, NULL); + if (EQ (found, Qunbound)) + return Qnil; + + if (SYMBOLP (orig) && !EQ (found, orig)) + return Qnil; + + /* We should never find an uninterned symbol in a package. */ + eassert (!NILP (SYMBOL_PACKAGE (found))); if (VECTORP (package)) package = pkg_fake_me_an_obarray (package); package = pkg_package_or_default (package); - return pkg_unintern_symbol (name, package); + return pkg_unintern_symbol (found, package); } /* Implements Emacs mapatoms. */ -- 2.39.2