From: Mattias EngdegÄrd Date: Thu, 30 May 2019 21:34:45 +0000 (-0700) Subject: Fix `memql' for bignums X-Git-Tag: emacs-27.0.90~2751 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b354935902d3820f59e34e18a47264122e99c1a4;p=emacs.git Fix `memql' for bignums * src/fns.c (Fmemql): Make `memql' work for bignums. * test/src/fns-tests.el (test-bignum-eql): Also test `memql'. --- diff --git a/src/fns.c b/src/fns.c index 6b1f7331f55..da830a90004 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 6ebab4287f7..a9d4d11795c 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -614,7 +614,8 @@ (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."