Blame SOURCES/bc-1.06-dc_ibase.patch

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