]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix `memql' for bignums
authorMattias EngdegÄrd <mattiase@acm.org>
Thu, 30 May 2019 21:34:45 +0000 (14:34 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 30 May 2019 21:58:13 +0000 (14:58 -0700)
* src/fns.c (Fmemql): Make `memql' work for bignums.
* test/src/fns-tests.el (test-bignum-eql): Also test `memql'.

src/fns.c
test/src/fns-tests.el

index 6b1f7331f55040f7d014044888c28deddeaa07a5..da830a9000494cd17a772d96159cfb4ebc9ce804 100644 (file)
--- 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,
index 6ebab4287f76abe64aed9cb878276cbacd7c034d..a9d4d11795c31ee724ebe70dd58a06f5f9a9bcab 100644 (file)
     (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."