From 15c6cd755557de5bb91c14668f9f0c2cbcbe988e Mon Sep 17 00:00:00 2001 From: aiju Date: Tue, 8 Dec 2015 20:26:17 +0100 Subject: [PATCH] mp: strtomp support for bases 2,4,8 --- sys/src/libmp/port/strtomp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/src/libmp/port/strtomp.c b/sys/src/libmp/port/strtomp.c index 0a9959692..59c7dd76b 100644 --- a/sys/src/libmp/port/strtomp.c +++ b/sys/src/libmp/port/strtomp.c @@ -44,21 +44,23 @@ init(void) } static char* -from16(char *a, mpint *b) +frompow2(char *a, mpint *b, int s) { char *p, *next; int i; mpdigit x; + int sn; + sn = 1<= sn) break; mpbits(b, (p-a)*4); b->top = 0; next = p; while(p > a){ x = 0; - for(i = 0; i < Dbits; i += 4){ + for(i = 0; i < Dbits; i += s){ if(p <= a) break; x |= tab.t16[*(uchar*)--p]<