1999-10-24
1999-10-24 01:08:42 by Fredrik Noring <noring@nocrew.org>
-
6ee24ae7bd2998ac4d59df5865998f4271a91f21
(21 lines)
(+15/-6)
[
Show
| Annotate
]
Branch: 7.9
Fixed parsing of explicit base 16 and 0x.
Rev: src/modules/Gmp/mpz_glue.c:1.52
Rev: src/opcodes.c:1.49
Rev: src/stralloc.c:1.71
Rev: src/testsuite.in:1.205
25:
#define HUGE HUGE_VAL
#endif /*!HUGE*/
- RCSID("$Id: stralloc.c,v 1.70 1999/10/23 06:51:32 hubbe Exp $");
+ RCSID("$Id: stralloc.c,v 1.71 1999/10/24 01:08:39 noring Exp $");
#define BEGIN_HASH_SIZE 997
#define MAX_AVG_LINK_LENGTH 3
1844:
{
PCHARP str_start;
- INT_TYPE xx, neg = 0, is_bignum = 0;
+ INT_TYPE xx, neg = 0, is_bignum = 0, implicit_base = 0;
INT_TYPE val;
INT_TYPE c;
1882:
if(base == 0)
{
+ implicit_base = 1;
+
if(c != '0')
base = 10;
else if(INDEX_PCHARP(str,1) == 'x' || INDEX_PCHARP(str,1) == 'X')
1897:
if(!isalnum(c) || (xx = DIGIT(c)) >= base)
return 0; /* No number formed. */
- if(base == 16 && c == '0' &&
+ if(implicit_base && base == 16 && c == '0' &&
INDEX_PCHARP(str,2) < 256 && /* Don't trust isxdigit... */
isxdigit(INDEX_PCHARP(str,2)) &&
(INDEX_PCHARP(str,1) == 'x' || INDEX_PCHARP(str,1) == 'X'))
1930: Inside #if defined(AUTO_BIGNUM)
{
push_string(make_shared_binary_pcharp(str_start,
SUBTRACT_PCHARP(str,str_start)));
- push_int(base);
-
+
/* Note that this can concievably throw errors()
* in some situations that might not be desirable...
* take care.
* /Hubbe
*/
-
+ if(implicit_base)
+ {
+ convert_stack_top_to_bignum();
+ }
+ else
+ {
+ push_int(base);
convert_stack_top_with_base_to_bignum();
-
+ }
*r = *--sp;
}