emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 c2b8ce4: Calc: don't treat nil as an integer (bug#40155)


From: Mattias Engdegård
Subject: emacs-27 c2b8ce4: Calc: don't treat nil as an integer (bug#40155)
Date: Sat, 28 Mar 2020 07:51:56 -0400 (EDT)

branch: emacs-27
commit c2b8ce4439935e2e158d4357d234135a251c5767
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Calc: don't treat nil as an integer (bug#40155)
    
    Make Math-num-integerp return false for nil, following Math-integerp
    which was changed in the bignum reform.  This fixes a crash in
    calc-graph-fast.
    
    Reported by Narendra Joshi.
    
    * lisp/calc/calc-macs.el (Math-num-integerp): Not true for nil.
    * test/lisp/calc/calc-tests.el (calc-Math-integerp): New tests.
---
 lisp/calc/calc-macs.el       |  5 +++--
 test/lisp/calc/calc-tests.el | 11 +++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/calc/calc-macs.el b/lisp/calc/calc-macs.el
index e73d108..257d369 100644
--- a/lisp/calc/calc-macs.el
+++ b/lisp/calc/calc-macs.el
@@ -161,8 +161,9 @@
                      hms date mod var))))
 
 (defsubst Math-num-integerp (a)
-  (or (not (consp a))
-      (and (eq (car a) 'float)
+  (or (integerp a)
+      (and (consp a)
+           (eq (car a) 'float)
           (>= (nth 2 a) 0))))
 
 (defsubst Math-equal-int (a b)
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el
index 784b404..8fffb7c 100644
--- a/test/lisp/calc/calc-tests.el
+++ b/test/lisp/calc/calc-tests.el
@@ -334,6 +334,17 @@ An existing calc stack is reused, otherwise a new one is 
created."
         (should (equal tos '(- (* 2 (var x var-x)) 4)))
         (should (equal trail "pdiv 2 * x - 4\nprem 8 * x + 1\n"))))))
 
+(ert-deftest calc-Math-integerp ()
+  (should (Math-integerp -7))
+  (should (Math-integerp (ash 1 65)))
+  (should-not (Math-integerp '(float 1 0)))
+  (should-not (Math-integerp nil))
+
+  (should (Math-num-integerp -7))
+  (should (Math-num-integerp (ash 1 65)))
+  (should (Math-num-integerp '(float 1 0)))
+  (should-not (Math-integerp nil)))
+
 (provide 'calc-tests)
 ;;; calc-tests.el ends here
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]