about summary refs log tree commit diff
path: root/Src/math.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2018-08-08 17:11:54 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2018-08-08 17:11:54 +0100
commit225b35c9070f94cf79c90c33ffcee84b281f894d (patch)
tree6b3d996d5c7ff8b9e7acb0fb9254da5e886e547e /Src/math.c
parentbf8b61182043ec5457bfcc97f4969949678e0385 (diff)
downloadzsh-225b35c9070f94cf79c90c33ffcee84b281f894d.tar.gz
zsh-225b35c9070f94cf79c90c33ffcee84b281f894d.tar.xz
zsh-225b35c9070f94cf79c90c33ffcee84b281f894d.zip
43261: Fix unary minus with base.
Apply unary minus to a complete lexical constant rather than the
first component that comes along.
Diffstat (limited to 'Src/math.c')
-rw-r--r--Src/math.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Src/math.c b/Src/math.c
index 4b7ecf0ab..b08e05cb4 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -640,8 +640,19 @@ zzlex(void)
 	    }
 	    if (unary) {
 		if (idigit(*ptr) || *ptr == '.') {
-		    ptr--;
-		    return lexconstant();
+		    int ctype = 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
 		    return UMINUS;
 	    } else