mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-19 11:31:26 +01:00
34892 (slightly tweaked): math evaluation fix
An empty expression resulting from substitution includes a Nularg, which needs handling the same as an empty string.
This commit is contained in:
parent
a2c579050f
commit
2ef4b38461
3 changed files with 9 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
|||
2015-04-15 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 34892 (slightly tweaked): Src/math.c, Test/C01arith.ztst: fix
|
||||
math evaluation with empty expression resulting from substitution.
|
||||
|
||||
* 34887: Src/exec, Test/E01options.ztst: assignments before
|
||||
"command special-builtin/func" in POSIX_BUILTINS mode behave as
|
||||
normal command. Tidy up case handling in code and add test.
|
||||
|
|
|
@ -1398,7 +1398,7 @@ matheval(char *s)
|
|||
if (!mlevel)
|
||||
outputradix = outputunderscore = 0;
|
||||
|
||||
if (!*s) {
|
||||
if (!*s || *s == Nularg) {
|
||||
x.type = MN_INTEGER;
|
||||
x.u.l = 0;
|
||||
return x;
|
||||
|
@ -1435,7 +1435,7 @@ mathevalarg(char *s, char **ss)
|
|||
*
|
||||
* To avoid a more opaque error further in, bail out here.
|
||||
*/
|
||||
if (!*s) {
|
||||
if (!*s || *s == Nularg) {
|
||||
zerr("bad math expression: empty string");
|
||||
return (zlong)0;
|
||||
}
|
||||
|
|
|
@ -383,4 +383,7 @@
|
|||
print ${$(( $1 * 100 ))%%.[0-9]#})
|
||||
0:Arithmetic substitution nested in parameter substitution
|
||||
>3246
|
||||
|
||||
|
||||
print $((`:`))
|
||||
0:Null string in arithmetic evaluation after command substitution
|
||||
>0
|
||||
|
|
Loading…
Reference in a new issue