diff options
author | Peter Stephenson <pws@zsh.org> | 2015-04-15 18:14:27 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-04-15 18:14:27 +0100 |
commit | 493fe2b4440679ca73d9022d94129039b9eacfeb (patch) | |
tree | 5dc08f43f7f5b06857c835506d63c41dee024350 | |
parent | 2ef4b38461dfb554ed2226d9de8958703bc00b98 (diff) | |
download | zsh-493fe2b4440679ca73d9022d94129039b9eacfeb.tar.gz zsh-493fe2b4440679ca73d9022d94129039b9eacfeb.tar.xz zsh-493fe2b4440679ca73d9022d94129039b9eacfeb.zip |
unposted: rewrite Nularg math handling to be like other cases
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/math.c | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index e2d561105..0d4521453 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-04-15 Peter Stephenson <p.stephenson@samsung.com> + * unposted: Src/math.c: rewrite last commit to look more + like other uses of Nularg. + * 34892 (slightly tweaked): Src/math.c, Test/C01arith.ztst: fix math evaluation with empty expression resulting from substitution. diff --git a/Src/math.c b/Src/math.c index 2105180c8..97a97b32b 100644 --- a/Src/math.c +++ b/Src/math.c @@ -1398,7 +1398,9 @@ matheval(char *s) if (!mlevel) outputradix = outputunderscore = 0; - if (!*s || *s == Nularg) { + if (*s == Nularg) + s++; + if (!*s) { x.type = MN_INTEGER; x.u.l = 0; return x; @@ -1435,7 +1437,9 @@ mathevalarg(char *s, char **ss) * * To avoid a more opaque error further in, bail out here. */ - if (!*s || *s == Nularg) { + if (*s == Nularg) + s++; + if (!*s) { zerr("bad math expression: empty string"); return (zlong)0; } |