about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-05-03 22:34:23 +0200
committerMikael Magnusson <mikachu@gmail.com>2015-05-04 04:26:11 +0200
commit1e6fb1a4f0586e62996bb19c9c07bc3c8d24659c (patch)
tree553e5a227523be6e202a6e9c17e48e88e6309032 /Src/builtin.c
parent5b00bfecac854a90ca2b66dd763848eed88d01ec (diff)
downloadzsh-1e6fb1a4f0586e62996bb19c9c07bc3c8d24659c.tar.gz
zsh-1e6fb1a4f0586e62996bb19c9c07bc3c8d24659c.tar.xz
zsh-1e6fb1a4f0586e62996bb19c9c07bc3c8d24659c.zip
Fix two bugs in typeset_setbase
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 0a57489ea..ffde5c916 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1868,7 +1868,7 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always)
 
     if (arg) {
 	char *eptr;
-	pm->base = (int)zstrtol(arg, &eptr, 10);
+	int base = (int)zstrtol(arg, &eptr, 10);
 	if (*eptr) {
 	    if (on & PM_INTEGER)
 		zwarnnam(name, "bad base value: %s", arg);
@@ -1876,11 +1876,12 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always)
 		zwarnnam(name, "bad precision value: %s", arg);
 	    return 1;
 	}
-	if (pm->base < 2 || pm->base > 36) {
+	if ((on & PM_INTEGER) && (base < 2 || base > 36)) {
 	    zwarnnam(name, "invalid base (must be 2 to 36 inclusive): %d",
-		     pm->base);
+		     base);
 	    return 1;
 	}
+	pm->base = base;
     } else if (always)
 	pm->base = 0;