1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-01 18:30:55 +01:00

18013: Handle test of (( float == 0.0)) properly

This commit is contained in:
Peter Stephenson 2002-12-18 16:57:02 +00:00
parent 84b6d587d1
commit 9a8dfbb7b5
3 changed files with 14 additions and 6 deletions

View file

@ -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

View file

@ -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 *

View file

@ -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 */