about summary refs log tree commit diff
path: root/Src/math.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2014-11-26 17:26:58 +0000
committerPeter Stephenson <pws@zsh.org>2014-11-26 17:26:58 +0000
commita8927bf27b57a1f49d525f628a97de9c1fce710b (patch)
tree909779151c4a6b93822e69fe0faff133ea66e7d9 /Src/math.c
parentc4110f7f4eac347fdbce71c286659a77beb138f7 (diff)
downloadzsh-a8927bf27b57a1f49d525f628a97de9c1fce710b.tar.gz
zsh-a8927bf27b57a1f49d525f628a97de9c1fce710b.tar.xz
zsh-a8927bf27b57a1f49d525f628a97de9c1fce710b.zip
33793: add 0b binary interpretation to integer constants
Diffstat (limited to 'Src/math.c')
-rw-r--r--Src/math.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/math.c b/Src/math.c
index 266569827..438a17089 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -449,12 +449,14 @@ lexconstant(void)
 	nptr++;
 
     if (*nptr == '0') {
+	int lowchar;
 	nptr++;
-	if (*nptr == 'x' || *nptr == 'X') {
+	lowchar = tolower(*nptr);
+	if (lowchar == 'x' || lowchar == 'b') {
 	    /* Let zstrtol parse number with base */
 	    yyval.u.l = zstrtol_underscore(ptr, &ptr, 0, 1);
 	    /* Should we set lastbase here? */
-	    lastbase = 16;
+	    lastbase = (lowchar == 'b') ? 2 : 16;
 	    if (isset(FORCEFLOAT))
 	    {
 		yyval.type = MN_FLOAT;