all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: 35868@debbugs.gnu.org
Subject: bug#35868: [PATCH] `memql' does not work for bignums
Date: Thu, 23 May 2019 17:07:11 +0200	[thread overview]
Message-ID: <79AE2738-3B42-410A-AA9A-F0FDE7865162@acm.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 73 bytes --]

(memql (ash 1 100) (list (ash 1 100))) => nil

Proposed patch attached.


[-- Attachment #2: 0001-Fix-memql-for-bignums.patch --]
[-- Type: application/octet-stream, Size: 2218 bytes --]

From afe2c459cff312e8c378e8381a36110f444dcb01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Thu, 23 May 2019 17:01:27 +0200
Subject: [PATCH] Fix `memql' for bignums

* src/fns.c (Fmemql): Make `memql' work for bignums.
* test/src/fns-tests.el (test-bignum-eql): Also test `memql'.
---
 src/fns.c             | 34 ++++++++++++++++++++++++----------
 test/src/fns-tests.el |  3 ++-
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/fns.c b/src/fns.c
index 6b1f7331f5..da830a9000 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1567,18 +1567,32 @@ DEFUN ("memql", Fmemql, Smemql, 2, 2, 0,
 The value is actually the tail of LIST whose car is ELT.  */)
   (Lisp_Object elt, Lisp_Object list)
 {
-  if (!FLOATP (elt))
-    return Fmemq (elt, list);
-
-  Lisp_Object tail = list;
-  FOR_EACH_TAIL (tail)
+  if (FLOATP (elt))
     {
-      Lisp_Object tem = XCAR (tail);
-      if (FLOATP (tem) && same_float (elt, tem))
-	return tail;
+      Lisp_Object tail = list;
+      FOR_EACH_TAIL (tail)
+        {
+          Lisp_Object tem = XCAR (tail);
+          if (FLOATP (tem) && same_float (elt, tem))
+            return tail;
+        }
+      CHECK_LIST_END (tail, list);
+      return Qnil;
     }
-  CHECK_LIST_END (tail, list);
-  return Qnil;
+  else if (BIGNUMP (elt))
+    {
+      Lisp_Object tail = list;
+      FOR_EACH_TAIL (tail)
+        {
+          Lisp_Object tem = XCAR (tail);
+          if (equal_no_quit (elt, tem))
+            return tail;
+        }
+      CHECK_LIST_END (tail, list);
+      return Qnil;
+    }
+  else
+    return Fmemq (elt, list);
 }
 
 DEFUN ("assq", Fassq, Sassq, 2, 2, 0,
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 6ebab4287f..a9d4d11795 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -614,7 +614,8 @@ dot2
     (should (eq x x))
     (should (eql x y))
     (should (equal x y))
-    (should-not (eql x 0.0e+NaN))))
+    (should-not (eql x 0.0e+NaN))
+    (should (memql x (list y)))))
 
 (ert-deftest test-bignum-hash ()
   "Test that hash tables work for bignums."
-- 
2.20.1 (Apple Git-117)


[-- Attachment #3: Type: text/plain, Size: 1 bytes --]

 

             reply	other threads:[~2019-05-23 15:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 15:07 Mattias Engdegård [this message]
2019-05-30 22:01 ` bug#35868: [PATCH] `memql' does not work for bignums Paul Eggert
2019-06-02 13:12   ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79AE2738-3B42-410A-AA9A-F0FDE7865162@acm.org \
    --to=mattiase@acm.org \
    --cc=35868@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.