summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2007-04-25 14:04:12 +0000
committerEric Blake <ebb9@byu.net>2007-09-21 15:48:17 -0600
commitb5180b4f731b0227efc25f8c56c2d1eb1860a50a (patch)
treeb1e007a15d0f75eb3e8f6b1ae9fbfb3f4c76c57a
parentb5ee646ef03f8b6c94a353692fa0e8e60720eae7 (diff)
downloadm4-b5180b4f731b0227efc25f8c56c2d1eb1860a50a.tar.gz
Fix negative division within eval, regression of 2007-01-06.
* doc/m4.texinfo (Eval): Catch this bug. * src/eval.c (mult_term): Fix it. * NEWS: Document this. * THANKS: Update. Reported by Cesar Strauss.
-rw-r--r--ChangeLog9
-rw-r--r--NEWS3
-rw-r--r--THANKS1
-rw-r--r--doc/m4.texinfo8
-rw-r--r--src/eval.c4
5 files changed, 21 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index c5512d66..9ee849b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-04-25 Eric Blake <ebb9@byu.net>
+
+ Fix negative division within eval, regression of 2007-01-06.
+ * doc/m4.texinfo (Eval): Catch this bug.
+ * src/eval.c (mult_term): Fix it.
+ * NEWS: Document this.
+ * THANKS: Update.
+ Reported by Cesar Strauss.
+
2007-04-23 Eric Blake <ebb9@byu.net>
Start 1.4.9a.
diff --git a/NEWS b/NEWS
index 7f7070c5..868e1e33 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,8 @@ Foundation, Inc.
Version 1.4.10 - ?? ??? 2007, by ???? (CVS version 1.4.9a)
-*
+* Fix regression introduced in 1.4.9 in the `eval' builtin when performing
+ division.
Version 1.4.9 - 23 Mar 2007, by Eric Blake (CVS version 1.4.8c)
diff --git a/THANKS b/THANKS
index a2743071..fc95b231 100644
--- a/THANKS
+++ b/THANKS
@@ -23,6 +23,7 @@ Bjorn R. Bjornsson brb@falcon.is
Bob Badour bob@badour.net
Brendan Kehoe brendan@cygnus.com
Bruno Haible bruno@clisp.org
+Cesar Strauss cestrauss@gmail.com
Chris McGuire chris@wso.net
Damian Menscher menscher@uiuc.edu
Dan Jacobson jidanni@jidanni.org
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 719c97c5..0c97fa12 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -4966,6 +4966,12 @@ Here are a few examples of use of @code{eval}.
@example
eval(`-3 * 5')
@result{}-15
+eval(`-99 / 10')
+@result{}-9
+eval(`-99 % 10')
+@result{}-9
+eval(`99 % -10')
+@result{}9
eval(index(`Hello world', `llo') >= 0)
@result{}1
eval(`0r1:0111 + 0b100 + 0r3:12')
@@ -4979,7 +4985,7 @@ square(square(`5')` + 1')
define(`foo', `666')
@result{}
eval(`foo / 6')
-@error{}m4:stdin:8: bad expression in eval: foo / 6
+@error{}m4:stdin:11: bad expression in eval: foo / 6
@result{}
eval(foo / 6)
@result{}111
diff --git a/src/eval.c b/src/eval.c
index b76014f8..01d13efd 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -718,10 +718,10 @@ mult_term (eval_token et, int32_t *v1)
if (v2 == 0)
return DIVIDE_ZERO;
else if (v2 == -1)
- /* Avoid the x86 SIGFPE on INT_MIN / -1. */
+ /* Avoid overflow, and the x86 SIGFPE on INT_MIN / -1. */
*v1 = (int32_t) -(uint32_t) *v1;
else
- *v1 = (int32_t) ((uint32_t) *v1 / (uint32_t) v2);
+ *v1 /= v2;
break;
case MODULO: