shithub: drawterm

Download patch

ref: 17da0b9dd1e7dc8f6b43eaa55c291a6ecbb00d69
parent: bc73cbac76e2d3820db734afdb4e0775f844cfa3
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Aug 27 23:44:07 EDT 2016

strtomp: update the returned char* even if there were no characters parsed (from, fix mpbits() call in octal code

--- a/libmp/strtomp.c
+++ b/libmp/strtomp.c
@@ -82,7 +82,7 @@
 		if(tab.t10[*(uchar*)p] >= 8)
 			break;
 
-	mpbits(b, (a-p)*3);
+	mpbits(b, (p-a)*3);
 	b->top = 0;
 	next = p;
 
@@ -240,12 +240,12 @@
 		return nil;
 	}
 
+	if(pp != nil)
+		*pp = e;
+
 	// if no characters parsed, there wasn't a number to convert
 	if(e == a)
 		return nil;
-
-	if(pp != nil)
-		*pp = e;
 
 	b->sign = sign;
 	return mpnorm(b);