shithub: pc

Download patch

ref: c3690045d4e188ffb203fe59f08e26b681d275c8
parent: 5ff4a10c5438b8a994dcc79a89b42c765cf4a4b8
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri May 20 13:23:47 EDT 2022

allow base 4 for input and output, 32 and 64 for output

--- a/pc.1
+++ b/pc.1
@@ -61,7 +61,7 @@
 Display \fIn\fR in hexadecimal.
 .TP
 .I pb(n, b)
-Display \fIn\fR in base \fIb\fR (currently must be one of 0, 2, 8, 10, 16; 0 uses the defined output base).
+Display \fIn\fR in base \fIb\fR (currently must be one of 0, 2, 4, 8, 10, 16, 32, 64; 0 uses the defined output base).
 .TP
 .I abs(n)
 Absolute value of \fIn\fR.
--- a/pc.y
+++ b/pc.y
@@ -196,7 +196,7 @@
 			*--q = '_';
 			i = 0;
 		}
-		if(*p >= 'A')
+		if(*p >= 'A' && b <= 16)
 			*--q = *p + ('a' - 'A');
 		else
 			*--q = *p;
@@ -339,7 +339,7 @@
 		inbase = save;
 		if(!fail) 
 			inbase = mptoi($3);
-		if(inbase != 2 && inbase != 8 && inbase != 10 && inbase != 16){
+		if(inbase != 2 && inbase != 4 && inbase != 8 && inbase != 10 && inbase != 16){
 			error("no.");
 			inbase = save;
 		}
@@ -352,7 +352,7 @@
 		save = outbase;
 		if(!fail) 
 			outbase = mptoi($3);
-		if(outbase != 0 && outbase != 2 && outbase != 8 && outbase != 10 && outbase != 16){
+		if(outbase != 0 && outbase != 2 && outbase != 4 && outbase != 8 && outbase != 10 && outbase != 16 && outbase != 32 && outbase != 64){
 			error("no.");
 			outbase = save;
 		}
@@ -731,7 +731,7 @@
 		numdecref(a[1]);
 		return nil;
 	}
-	if(b != 0 && b != 2 && b != 8 && b != 10 && b != 16){
+	if(b != 0 && b != 2 && b != 4 && b != 8 && b != 10 && b != 16 && b != 32 && b != 64){
 		error("unsupported base");
 		goto out;
 	}