pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:18:      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>      #ifndef HUGE   #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      /* Experimental dynamic hash length */   #ifndef HASH_PREFIX   static unsigned int HASH_PREFIX=64;   static unsigned int need_more_hash_prefix=0;   #endif   
pike.git/src/stralloc.c:1837:   }      int pcharp_to_svalue_inumber(struct svalue *r,    PCHARP str,    PCHARP *ptr,    int base,    int maxlength)   {    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;       maxlength--; /* max_length <= 0 means no max length. */    str_start = str;       /* In case no number is formed. */    r->type = T_INT;    r->subtype = NUMBER_NUMBER;    r->u.integer = 0;
pike.git/src/stralloc.c:1875:    neg++;    /* Fall-through. */    case '+':    INC_PCHARP(str,1);    c = EXTRACT_PCHARP(str);    }    }       if(base == 0)    { +  implicit_base = 1; +     if(c != '0')    base = 10;    else if(INDEX_PCHARP(str,1) == 'x' || INDEX_PCHARP(str,1) == 'X')    base = 16;    else    base = 8;    }       /*    * For any base > 10, the digits incrementally following    * 9 are assumed to be "abc...z" or "ABC...Z".    */    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'))    {    /* Skip over leading "0x" or "0X". */    INC_PCHARP(str,2);    c=EXTRACT_PCHARP(str);    }       for(val = -DIGIT(c);
pike.git/src/stralloc.c:1923:    if(ptr != 0)    *ptr = str;       r->u.integer = (neg ? val : -val);      #ifdef AUTO_BIGNUM    if(is_bignum || (!neg && r->u.integer < 0))    {    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;    }   #endif /* AUTO_BIGNUM */       return 1;   }      int convert_stack_top_string_to_inumber(int base)   {