(gnus-decay-score): Protect against arithmetic errors. From Norbert Koch.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 4 Nov 2003 04:04:44 +0000 (04:04 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 4 Nov 2003 04:04:44 +0000 (04:04 +0000)
lisp/ChangeLog
lisp/gnus-score.el

index 66a0623..9f91ea3 100644 (file)
@@ -1,3 +1,8 @@
+2003-11-04  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * gnus-score.el (gnus-decay-score): Protect against arithmetic
+       errors.  Tiny patch from Norbert Koch <viteno@xemacs.org>.
+
 2003-10-31  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * spam.el
index 22f7c07..a33bce5 100644 (file)
@@ -2918,13 +2918,15 @@ If ADAPT, return the home adaptive file instead."
 
 (defun gnus-decay-score (score)
   "Decay SCORE according to `gnus-score-decay-constant' and `gnus-score-decay-scale'."
-  (floor
-   (- score
-      (* (if (< score 0) -1 1)
-        (min (abs score)
-             (max gnus-score-decay-constant
-                  (* (abs score)
-                     gnus-score-decay-scale)))))))
+  (condition-case nil
+      (floor
+       (- score
+         (* (if (< score 0) -1 1)
+            (min (abs score)
+                 (max gnus-score-decay-constant
+                      (* (abs score)
+                         gnus-score-decay-scale))))))
+    (arith-error (lsh -1 -1))))
 
 (defun gnus-decay-scores (alist day)
   "Decay non-permanent scores in ALIST."