mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-08-07 01:30:59 +02:00
43261: Fix unary minus with base.
Apply unary minus to a complete lexical constant rather than the first component that comes along.
This commit is contained in:
parent
bf8b611820
commit
225b35c907
3 changed files with 22 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2018-08-08 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* 43261: Src/math.c, Test/C01arith.ztst: Apply unary minus to
|
||||||
|
entire lexical constant, so base doesn't get treated as negative.
|
||||||
|
|
||||||
2018-08-07 Peter Stephenson <p.stephenson@samsung.com>
|
2018-08-07 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
* Anton Shestakov: 43254: Completion/Unix/Command/_hg: Remove hg
|
* Anton Shestakov: 43254: Completion/Unix/Command/_hg: Remove hg
|
||||||
|
|
15
Src/math.c
15
Src/math.c
|
@ -640,8 +640,19 @@ zzlex(void)
|
||||||
}
|
}
|
||||||
if (unary) {
|
if (unary) {
|
||||||
if (idigit(*ptr) || *ptr == '.') {
|
if (idigit(*ptr) || *ptr == '.') {
|
||||||
ptr--;
|
int ctype = lexconstant();
|
||||||
return lexconstant();
|
if (ctype == NUM)
|
||||||
|
{
|
||||||
|
if (yyval.type == MN_FLOAT)
|
||||||
|
{
|
||||||
|
yyval.u.d = -yyval.u.d;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yyval.u.l = -yyval.u.l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ctype;
|
||||||
} else
|
} else
|
||||||
return UMINUS;
|
return UMINUS;
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -467,3 +467,7 @@
|
||||||
>6
|
>6
|
||||||
>4
|
>4
|
||||||
?(eval):6: bad math expression: lvalue required
|
?(eval):6: bad math expression: lvalue required
|
||||||
|
|
||||||
|
print $(( -2#101-16#f ))
|
||||||
|
0: Unary minus doesn't apply to base but to number as a whole.
|
||||||
|
>-20
|
||||||
|
|
Loading…
Reference in a new issue