summary refs log tree commit diff
path: root/Src/params.c
diff options
context:
space:
mode:
authorAndrew Main <zefram@users.sourceforge.net>2000-09-02 17:09:28 +0000
committerAndrew Main <zefram@users.sourceforge.net>2000-09-02 17:09:28 +0000
commit960728aad2d745c3daaafb1bdce6bcababbc605f (patch)
tree5171efec0e590bc347d7af5d5ca23db3cd44922b /Src/params.c
parent0cea5554a84ac344a8efb1d091440c472e9f21be (diff)
downloadzsh-960728aad2d745c3daaafb1bdce6bcababbc605f.tar.gz
zsh-960728aad2d745c3daaafb1bdce6bcababbc605f.tar.xz
zsh-960728aad2d745c3daaafb1bdce6bcababbc605f.zip
12722: [##base] for output base selection without a base prefix
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Src/params.c b/Src/params.c
index 1439e9af8..2d38272a6 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3041,10 +3041,10 @@ convbase(char *s, zlong v, int base)
 
     if (v < 0)
 	*s++ = '-', v = -v;
-    if (base <= 1)
-	base = 10;
+    if (base >= -1 && base <= 1)
+	base = -10;
 
-    if (base != 10) {
+    if (base > 0) {
 	if (isset(CBASES) && base == 16)
 	    sprintf(s, "0x");
 	else if (isset(CBASES) && base == 8 && isset(OCTALZEROES))
@@ -3052,7 +3052,8 @@ convbase(char *s, zlong v, int base)
 	else
 	    sprintf(s, "%d#", base);
 	s += strlen(s);
-    }
+    } else
+	base = -base;
     for (x = v; x; digs++)
 	x /= base;
     if (!digs)