summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-alg.el
diff options
context:
space:
mode:
authorJay Belanger <jay.p.belanger@gmail.com>2012-07-29 13:51:16 -0500
committerJay Belanger <jay.p.belanger@gmail.com>2012-07-29 13:51:16 -0500
commit9052f9f01ea219b9e9819b3cb3c6bfd9a6751460 (patch)
treef91f9bb81ba964b29001af7bcd4aab35102c3751 /lisp/calc/calc-alg.el
parent26918d77f774755ffb1621d614364cd38c9736ab (diff)
downloademacs-9052f9f01ea219b9e9819b3cb3c6bfd9a6751460.tar.gz
calc/calc.el (math-normalize-error): New variable.
(math-normalize): Set `math-normalize-error' to t when there's an error. calc/calc-alg.el (math-simplify): Don't simplify when `math-normalize' returns an error.
Diffstat (limited to 'lisp/calc/calc-alg.el')
-rw-r--r--lisp/calc/calc-alg.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el
index 50b31400a6a..3182e85a8c6 100644
--- a/lisp/calc/calc-alg.el
+++ b/lisp/calc/calc-alg.el
@@ -356,6 +356,8 @@
;; math-simplify-step, which is called by math-simplify.
(defvar math-top-only)
+;; math-normalize-error is declared in calc.el.
+(defvar math-normalize-error)
(defun math-simplify (top-expr)
(let ((math-simplifying t)
(math-top-only (consp calc-simplify-mode))
@@ -383,10 +385,12 @@
(calc-with-default-simplification
(while (let ((r simp-rules))
(setq res (math-normalize top-expr))
- (while r
- (setq res (math-rewrite res (car r))
- r (cdr r)))
- (not (equal top-expr (setq res (math-simplify-step res)))))
+ (if (not math-normalize-error)
+ (progn
+ (while r
+ (setq res (math-rewrite res (car r))
+ r (cdr r)))
+ (not (equal top-expr (setq res (math-simplify-step res)))))))
(setq top-expr res)))))
top-expr)