pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:3266:   {    switch(ptr.shift)    {    case 0: return MKPCHARP(memchr(ptr.ptr,chr,len),0);    case 1: return MKPCHARP(MEMCHR1((p_wchar1 *)ptr.ptr,chr,len),1);    case 2: return MKPCHARP(MEMCHR2((p_wchar2 *)ptr.ptr,chr,len),2);    }    UNREACHABLE(MKPCHARP(0,0));   }    - #define DIGIT(x) hexdecode[x] + #define DIGIT(x) ( (x)<256 ? hexdecode[x] : 16 )   #define MBASE ('z' - 'a' + 1 + 10)      PMOD_EXPORT long STRTOL_PCHARP(PCHARP str, PCHARP *ptr, int base)   { -  /* Note: Code duplication in strtol and pcharp_to_svalue_inumber. */ +  /* Note: Code duplication in pcharp_to_svalue_inumber. */       unsigned long val, mul_limit;    int c;    int xx, neg = 0, add_limit, overflow = 0;       if (ptr) *ptr = str;    if (base < 0 || base > MBASE) return 0;    if (!WIDE_ISALNUM(c = EXTRACT_PCHARP(str)))    {    while (wide_isspace(c))
pike.git/src/stralloc.c:3307:    if (!base)    {    if (c != '0')    base = 10;    else if (INDEX_PCHARP(str,1) == 'x' || INDEX_PCHARP(str,1) == 'X')    base = 16;    else    base = 8;    }    -  if (!WIDE_ISALNUM(c) || (xx = DIGIT(c)) >= base) +  if (DIGIT(c) >= base)    return 0; /* no number formed */ -  if (base == 16 && c == '0' && isxdigit(INDEX_PCHARP(str,2)) && +  if (base == 16 && c == '0' && DIGIT(INDEX_PCHARP(str,2))<16 &&    (INDEX_PCHARP(str,1) == 'x' || INDEX_PCHARP(str,1) == 'X'))    {    INC_PCHARP(str,2);    c = EXTRACT_PCHARP(str); /* skip over leading "0x" or "0X" */    }       mul_limit = ((unsigned long)LONG_MAX)/base;    add_limit = (int) (LONG_MAX % base);    if (neg) {    if (++add_limit == base) {    add_limit = 0;    mul_limit++;    }    }       val=DIGIT(c);    while(1)    {    INC_PCHARP(str,1);    c=EXTRACT_PCHARP(str); -  if(!(WIDE_ISALNUM(c) && (xx=DIGIT(c)) < base)) break; +  if( (xx=DIGIT(c)) >= base ) break;    if (val > mul_limit || (val == mul_limit && xx > add_limit)) {    overflow = 1;    } else    val = base * val + xx;    }       if (ptr) *ptr = str;    if (overflow) {    errno = ERANGE;    return neg ? LONG_MIN : LONG_MAX;
pike.git/src/stralloc.c:3405:    if(ptr) *(p_wchar0 **)ptr=tmp.ptr;    return ret;   }      PMOD_EXPORT int pcharp_to_svalue_inumber(struct svalue *r,    PCHARP str,    PCHARP *ptr,    int base,    ptrdiff_t maxlength)   { -  /* Note: Code duplication in strtol and STRTOL_PCHARP. */ +  /* Note: Code duplication in STRTOL_PCHARP. */       PCHARP str_start;       unsigned INT_TYPE val, mul_limit;    int c;    int xx, neg = 0, add_limit, overflow = 0;       maxlength--; /* max_length <= 0 means no max length. */    str_start = str;   
pike.git/src/stralloc.c:3459:    else if(INDEX_PCHARP(str,1) == 'b' || INDEX_PCHARP(str,1) == 'B')    base = 2;    else    base = 8;    }       /*    * For any base > 10, the digits incrementally following    * 9 are assumed to be "abc...z" or "ABC...Z".    */ -  if(!WIDE_ISALNUM(c) || (xx = DIGIT(c)) >= base) +  if(DIGIT(c) >= base)    return 0; /* No number formed. */       if(c == '0' &&    ((base==16 && (INDEX_PCHARP(str,1)=='x' || INDEX_PCHARP(str,1)=='X')) ||    (base==2 && (INDEX_PCHARP(str,1)=='b' || INDEX_PCHARP(str,1)=='B'))) && -  INDEX_PCHARP(str,2) < 256 && /* Don't trust isxdigit... */ -  isxdigit(INDEX_PCHARP(str,2))) +  DIGIT(INDEX_PCHARP(str,2))<16 )    {    /* Skip over leading "0x", "0X", "0b" or "0B". */    INC_PCHARP(str,2);    c=EXTRACT_PCHARP(str);    }    str_start=str;       if (neg) {    mul_limit = (unsigned INT_TYPE) MIN_INT_TYPE / base;    add_limit = (int) ((unsigned INT_TYPE) MIN_INT_TYPE % base);
pike.git/src/stralloc.c:3582:    sign = EXTRACT_PCHARP(s) == '-' ? -1 : 1;    if (EXTRACT_PCHARP(s) == '-' || EXTRACT_PCHARP(s) == '+')    INC_PCHARP(s,1);       num = 0.0;    got_dot = 0;    got_digit = 0;    exponent = 0;    for (;; INC_PCHARP(s,1))    { -  if (EXTRACT_PCHARP(s)<256 && WIDE_ISDIGIT (EXTRACT_PCHARP(s))) +  if (WIDE_ISDIGIT (EXTRACT_PCHARP(s)))    {    got_digit = 1;       /* Make sure that multiplication by 10 will not overflow. */    if (num > DBL_MAX * 0.1)    /* The value of the digit doesn't matter, since we have already    gotten as many digits as can be represented in a `double'.    This doesn't necessarily mean the result will overflow.    The exponent may reduce it to within range.