Blame SOURCES/bc-1.06-dc_ibase.patch

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