Blame SOURCES/bc-1.06-dc_ibase.patch

747aaa
--- bc-1.06/dc/numeric.c.dc_ibase	2007-08-22 08:37:57.000000000 +0200
747aaa
+++ bc-1.06/dc/numeric.c	2007-08-22 08:37:40.000000000 +0200
747aaa
@@ -285,6 +285,8 @@ dc_getnum DC_DECLARG((input, ibase, read
747aaa
 	int		digit;
747aaa
 	int		decimal;
747aaa
 	int		c;
747aaa
+	int		c_buff = 0;
747aaa
+	int		multi = 0;
747aaa
 
747aaa
 	bc_init_num(&tmp);
747aaa
 	bc_init_num(&build);
747aaa
@@ -302,6 +304,9 @@ dc_getnum DC_DECLARG((input, ibase, read
747aaa
 	}
747aaa
 	while (isspace(c))
747aaa
 		c = (*input)();
747aaa
+	c_buff = (*input)();	
747aaa
+	if (isdigit(c_buff) || ('A' <= c_buff && c_buff <= 'F') || c_buff == '.')
747aaa
+			multi = 1;		
747aaa
 	for (;;){
747aaa
 		if (isdigit(c))
747aaa
 			digit = c - '0';
747aaa
@@ -309,10 +314,15 @@ dc_getnum DC_DECLARG((input, ibase, read
747aaa
 			digit = 10 + c - 'A';
747aaa
 		else
747aaa
 			break;
747aaa
-		c = (*input)();
747aaa
+		digit = multi ? (digit >= ibase ? ibase -1 : digit) : digit;
747aaa
 		bc_int2num(&tmp, digit);
747aaa
 		bc_multiply(result, base, &result, 0);
747aaa
 		bc_add(result, tmp, &result, 0);
747aaa
+		if (c_buff) {
747aaa
+			c = c_buff;
747aaa
+			c_buff = 0;
747aaa
+		} else
747aaa
+			c = (*input)();
747aaa
 	}
747aaa
 	if (c == '.'){
747aaa
 		bc_free_num(&build);
747aaa
@@ -321,13 +331,18 @@ dc_getnum DC_DECLARG((input, ibase, read
747aaa
 		build = bc_copy_num(_zero_);
747aaa
 		decimal = 0;
747aaa
 		for (;;){
747aaa
-			c = (*input)();
747aaa
+			if (c_buff) {
747aaa
+				c = c_buff;
747aaa
+				c_buff = 0;
747aaa
+			} else
747aaa
+				c = (*input)();
747aaa
 			if (isdigit(c))
747aaa
 				digit = c - '0';
747aaa
 			else if ('A' <= c && c <= 'F')
747aaa
 				digit = 10 + c - 'A';
747aaa
 			else
747aaa
 				break;
747aaa
+			digit = digit >= ibase ? ibase -1 : digit;
747aaa
 			bc_int2num(&tmp, digit);
747aaa
 			bc_multiply(build, base, &build, 0);
747aaa
 			bc_add(build, tmp, &build, 0);