emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109274: calc/calc.el (math-normalize


From: Jay Belanger
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109274: calc/calc.el (math-normalize-error): New variable.
Date: Sun, 29 Jul 2012 13:51:16 -0500
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109274
committer: Jay Belanger <address@hidden>
branch nick: trunk
timestamp: Sun 2012-07-29 13:51:16 -0500
message:
  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. 
modified:
  lisp/ChangeLog
  lisp/calc/calc-alg.el
  lisp/calc/calc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-07-29 18:27:35 +0000
+++ b/lisp/ChangeLog    2012-07-29 18:51:16 +0000
@@ -1,3 +1,12 @@
+2012-07-29  Jay Belanger  <address@hidden>
+
+       * 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.
+
 2012-07-29  Eli Zaretskii  <address@hidden>
 
        * international/mule-cmds.el (set-locale-environment): Revert last

=== modified file 'lisp/calc/calc-alg.el'
--- a/lisp/calc/calc-alg.el     2012-07-25 02:38:36 +0000
+++ b/lisp/calc/calc-alg.el     2012-07-29 18:51:16 +0000
@@ -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)
 

=== modified file 'lisp/calc/calc.el'
--- a/lisp/calc/calc.el 2012-07-26 01:27:33 +0000
+++ b/lisp/calc/calc.el 2012-07-29 18:51:16 +0000
@@ -2583,7 +2583,11 @@
 ;;; Reduce an object to canonical (normalized) form.  [O o; Z Z] [Public]
 
 (defvar math-normalize-a)
+(defvar math-normalize-error nil
+  "Non-nil if the last call the `math-normalize' returned an error.")
+
 (defun math-normalize (math-normalize-a)
+  (setq math-normalize-error nil)
   (cond
    ((not (consp math-normalize-a))
     (if (integerp math-normalize-a)
@@ -2672,31 +2676,38 @@
                                        (fboundp (car math-normalize-a))))
                               (apply (car math-normalize-a) args)))))
                (wrong-number-of-arguments
+                 (setq math-normalize-error t)
                 (calc-record-why "*Wrong number of arguments"
                                  (cons (car math-normalize-a) args))
                 nil)
                (wrong-type-argument
+                 (setq math-normalize-error t)
                 (or calc-next-why
                      (calc-record-why "Wrong type of argument"
                                       (cons (car math-normalize-a) args)))
                 nil)
                (args-out-of-range
+                 (setq math-normalize-error t)
                 (calc-record-why "*Argument out of range"
                                   (cons (car math-normalize-a) args))
                 nil)
                (inexact-result
+                 (setq math-normalize-error t)
                 (calc-record-why "No exact representation for result"
                                  (cons (car math-normalize-a) args))
                 nil)
                (math-overflow
+                 (setq math-normalize-error t)
                 (calc-record-why "*Floating-point overflow occurred"
                                  (cons (car math-normalize-a) args))
                 nil)
                (math-underflow
+                 (setq math-normalize-error t)
                 (calc-record-why "*Floating-point underflow occurred"
                                  (cons (car math-normalize-a) args))
                 nil)
                (void-variable
+                 (setq math-normalize-error t)
                 (if (eq (nth 1 err) 'var-EvalRules)
                     (progn
                       (setq var-EvalRules nil)


reply via email to

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