about summary refs log tree commit diff
path: root/Src/math.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-02-12 16:43:40 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-02-12 16:43:40 +0000
commit2c92d005d7c0b828dc9bec3f220543b716dad6ee (patch)
tree24cb70e449c9a16627d5e61658e1b3f428794efb /Src/math.c
parent9ed500a1cd6d31522675b313d52fc5ba624095c7 (diff)
downloadzsh-2c92d005d7c0b828dc9bec3f220543b716dad6ee.tar.gz
zsh-2c92d005d7c0b828dc9bec3f220543b716dad6ee.tar.xz
zsh-2c92d005d7c0b828dc9bec3f220543b716dad6ee.zip
23165: fix problems with bases: error if over 36 and don't interpret octal
Diffstat (limited to 'Src/math.c')
-rw-r--r--Src/math.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/Src/math.c b/Src/math.c
index 809999f9c..66d57fd53 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -216,17 +216,33 @@ lexconstant(void)
 	    lastbase = 16;
 	    return NUM;
 	}
-	else if (isset(OCTALZEROES) &&
-		 (memchr(nptr, '.', strlen(nptr)) == NULL) &&
-		 idigit(*nptr)) {
-	    yyval.u.l = zstrtol(ptr, &ptr, 0);
-	    lastbase = 8;
-	    return NUM;
+	else if (isset(OCTALZEROES))
+	{
+	    char *ptr2;
+
+	    /*
+	     * Make sure this is a real octal constant;
+	     * it can't be a base indication (always decimal)
+	     * or a floating point number.
+	     */
+	    for (ptr2 = nptr; idigit(*ptr2); ptr2++)
+		;
+
+	    if (ptr2 > nptr && *ptr2 != '.' && *ptr2 != 'e' &&
+		*ptr2 != 'E' && *ptr2 != '#')
+	    {
+		yyval.u.l = zstrtol(ptr, &ptr, 0);
+		lastbase = 8;
+		return NUM;
+	    }
+	    nptr = ptr2;
 	}
     }
-
-    while (idigit(*nptr))
-	nptr++;
+    else
+    {
+	while (idigit(*nptr))
+	    nptr++;
+    }
 
     if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
 	/* it's a float */