diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2002-12-18 16:57:02 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2002-12-18 16:57:02 +0000 |
commit | 9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb (patch) | |
tree | b3abb07c45253f120ca35e8d2367f1b3a6bd110c /Src | |
parent | 84b6d587d13d8b2626b70cc204154a540ab9fcbc (diff) | |
download | zsh-9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb.tar.gz zsh-9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb.tar.xz zsh-9a8dfbb7b5ac843c7ae8dd12339911c0ea8103fb.zip |
18013: Handle test of (( float == 0.0)) properly
Diffstat (limited to 'Src')
-rw-r--r-- | Src/builtin.c | 7 | ||||
-rw-r--r-- | Src/exec.c | 7 |
2 files changed, 8 insertions, 6 deletions
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 */ |