aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-12-18 16:57:02 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-12-18 16:57:02 +0000
commit9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb (patch)
treeb3abb07c45253f120ca35e8d2367f1b3a6bd110c
parent84b6d587d13d8b2626b70cc204154a540ab9fcbc (diff)
downloadzsh-9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb.tar.gz
zsh-9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb.tar.xz
zsh-9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb.zip
18013: Handle test of (( float == 0.0)) properly
-rw-r--r--ChangeLog6
-rw-r--r--Src/builtin.c7
-rw-r--r--Src/exec.c7
3 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 15ec73d74..315ecbc72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-12-18 Peter Stephenson <pws@csr.com>
+
+ * 18013: Src/builtin.c, Src/exec.c: let and (( ... )) should
+ return zero status on floating point only if the value compares
+ equal to 0 as a floating point number.
+
2002-12-11 Peter Stephenson <pws@csr.com>
* 17996: Src/builtin.c: Improve formatting with `print -C' by
diff --git a/Src/builtin.c b/Src/builtin.c
index f9f65e961..530bba8c8 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4759,13 +4759,14 @@ bin_ttyctl(char *name, char **argv, Options ops, int func)
int
bin_let(char *name, char **argv, Options ops, int func)
{
- zlong val = 0;
+ mnumber val = zero_mnumber;
while (*argv)
- val = mathevali(*argv++);
+ val = matheval(*argv++);
/* Errors in math evaluation in let are non-fatal. */
errflag = 0;
- return !val;
+ /* should test for fabs(val.u.d) < epsilon? */
+ return (val.type == MN_INTEGER) ? val.u.l == 0 : val.u.d == 0.0;
}
/* umask command. umask may be specified as octal digits, or in the *
diff --git a/Src/exec.c b/Src/exec.c
index 76ca437f4..978470251 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3087,7 +3087,7 @@ static int
execarith(Estate state, int do_exec)
{
char *e;
- zlong val = 0;
+ mnumber val = zero_mnumber;
int htok = 0;
if (isset(XTRACE)) {
@@ -3101,7 +3101,7 @@ execarith(Estate state, int do_exec)
if (isset(XTRACE))
fprintf(xtrerr, " %s", e);
- val = mathevali(e);
+ val = matheval(e);
cmdpop();
@@ -3110,7 +3110,8 @@ execarith(Estate state, int do_exec)
fflush(xtrerr);
}
errflag = 0;
- return !val;
+ /* should test for fabs(val.u.d) < epsilon? */
+ return (val.type == MN_INTEGER) ? val.u.l == 0 : val.u.d == 0.0;
}
/* perform time ... command */