diff --git a/src/configure.in b/src/configure.in index 0fcf1ee080693badd49ddac446c1de03780f0d42..e2e456588237da157cfeb07d6b11bfc75bdf6349 100644 --- a/src/configure.in +++ b/src/configure.in @@ -4582,7 +4582,6 @@ AC_CHECK_FUNCS( \ strcspn \ strerror \ strtod \ - strtol \ times \ tzset \ vsprintf \ diff --git a/src/lexer.h b/src/lexer.h index 6b33e4376ef4a99b09930172a5eb37256593f022..d0cda53791846c2375a24da72c05b28592d18a23 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -53,7 +53,7 @@ #define yylex yylex0 #define low_yylex low_yylex0 #define lex_atoi atoi -#define lex_strtol STRTOL +#define lex_strtol strtol #define lex_strtod my_strtod #define lex_isidchar isidchar diff --git a/src/main.c b/src/main.c index 94935fb3d613a236d111a7e480522566a971fb6b..71fba29af356269ee9b0858a30f1f8434fc91b17 100644 --- a/src/main.c +++ b/src/main.c @@ -434,13 +434,13 @@ int main(int argc, char **argv) p++; } #ifdef _REENTRANT - thread_stack_size=STRTOL(p,&p,0); + thread_stack_size=strtol(p,&p,0); #endif p+=strlen(p); break; } } - Pike_stack_size=STRTOL(p,&p,0); + Pike_stack_size=strtol(p,&p,0); p+=strlen(p); if(Pike_stack_size < 256) @@ -463,7 +463,7 @@ int main(int argc, char **argv) }else{ p++; } - set_pike_evaluator_limit(STRTOL(p, &p, 0)); + set_pike_evaluator_limit(strtol(p, &p, 0)); p+=strlen(p); break; @@ -473,7 +473,7 @@ int main(int argc, char **argv) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - d_flag+=STRTOL(p+1,&p,10); + d_flag+=strtol(p+1,&p,10); break; case 'c': @@ -543,7 +543,7 @@ int main(int argc, char **argv) case 'a': if(p[1]>='0' && p[1]<='9') - a_flag+=STRTOL(p+1,&p,10); + a_flag+=strtol(p+1,&p,10); else a_flag++,p++; break; @@ -553,7 +553,7 @@ int main(int argc, char **argv) switch (p[1]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - Pike_interpreter.trace_level+=STRTOL(p+1,&p,10); + Pike_interpreter.trace_level+=strtol(p+1,&p,10); break; case 'g': @@ -576,7 +576,7 @@ int main(int argc, char **argv) p+=strlen(p); }else{ if(p[1]>='0' && p[1]<='9') - p_flag+=STRTOL(p+1,&p,10); + p_flag+=strtol(p+1,&p,10); else p_flag++,p++; } @@ -584,7 +584,7 @@ int main(int argc, char **argv) case 'l': if(p[1]>='0' && p[1]<='9') - l_flag+=STRTOL(p+1,&p,10); + l_flag+=strtol(p+1,&p,10); else l_flag++,p++; break; diff --git a/src/modules/Mysql/result.c b/src/modules/Mysql/result.c index c63970f256a550bd580b90076c701b3549b9c165..0bf24c3b817c867b6bfd75df01d47d6250efeefa 100644 --- a/src/modules/Mysql/result.c +++ b/src/modules/Mysql/result.c @@ -615,7 +615,7 @@ static void f_fetch_row(INT32 args) case FIELD_TYPE_SHORT: case FIELD_TYPE_LONG: case FIELD_TYPE_INT24: - push_int(STRTOL(row[i], 0, 10)); + push_int(strtol(row[i], 0, 10)); break; #if defined (HAVE_MYSQL_FETCH_LENGTHS) @@ -661,7 +661,7 @@ static void f_fetch_row(INT32 args) convert_stack_top_string_to_inumber(10); break; } - push_int(STRTOL(row[i], 0, 10)); + push_int(strtol(row[i], 0, 10)); break; } diff --git a/src/operators.c b/src/operators.c index de71968978fa817763d3a16277572c79ff640bfb..aa3842e9f36eab7ddd39ed833a85a72de705dd55 100644 --- a/src/operators.c +++ b/src/operators.c @@ -301,7 +301,7 @@ PMOD_EXPORT void o_cast_to_int(void) convert_stack_top_string_to_inumber(10); else { - INT_TYPE i = STRTOL(sp[-1].u.string->str, 0, 10); + INT_TYPE i = strtol(sp[-1].u.string->str, 0, 10); free_string(sp[-1].u.string); SET_SVAL(sp[-1], T_INT, NUMBER_NUMBER, integer, i); } diff --git a/src/pike_memory.c b/src/pike_memory.c index 23fb1e1604c2cf9a1de5eb806fb9b4361b49e627..0655702950fedec7b40df3ae8bbb4481a7811219 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -2364,7 +2364,7 @@ static void parse_location (struct memloc *l, struct parsed_location *pl) if (p && p < pl->extra) { const char *pp; while ((pp = STRCHR (p + 1, ':')) && pp < pl->extra) p = pp; - pl->line = STRTOL (p + 1, NULL, 10); + pl->line = strtol (p + 1, NULL, 10); pl->file_len = p - pl->file; } else { @@ -2927,7 +2927,7 @@ static LOCATION low_dynamic_location(char type, const char *file, !strncmp(str->str+1, file, len) && str->str[len+1]==':' && LOCATION_TYPE (str->str) == type && - STRTOL(str->str+len+2, NULL, 10) == line) + strtol(str->str+len+2, NULL, 10) == line) { if (name) { diff --git a/src/pike_types.c b/src/pike_types.c index b7f2bc639759e1f9f281f9b208dfde01cdaed315..42927ff2e2081506970781496ee56fe12fb99c86 100644 --- a/src/pike_types.c +++ b/src/pike_types.c @@ -1460,7 +1460,7 @@ static void internal_parse_typeA(const char **_s) ++*s; while(isspace(**s)) ++*s; if (**s != '.') { - min=STRTOL((const char *)*s,(char **)s,0); + min=strtol((const char *)*s,(char **)s,0); while(isspace(**s)) ++*s; } else { min = MIN_INT32; @@ -1473,7 +1473,7 @@ static void internal_parse_typeA(const char **_s) while(isspace(**s)) ++*s; if (**s != ')') { - max=STRTOL((const char *)*s,(char **)s,0); + max=strtol((const char *)*s,(char **)s,0); while(isspace(**s)) ++*s; } else { max = MAX_INT32; @@ -1620,7 +1620,7 @@ static void internal_parse_typeA(const char **_s) ++*s; while(isspace(**s)) ++*s; if (**s != '.') { - min=STRTOL((const char *)*s,(char **)s,0); + min=strtol((const char *)*s,(char **)s,0); while(isspace(**s)) ++*s; } else { min = MIN_INT32; @@ -1633,7 +1633,7 @@ static void internal_parse_typeA(const char **_s) while(isspace(**s)) ++*s; if (**s != ')') { - max=STRTOL((const char *)*s,(char **)s,0); + max=strtol((const char *)*s,(char **)s,0); while(isspace(**s)) ++*s; } else { max = MAX_INT32; diff --git a/src/port.c b/src/port.c index e51c9bb2f2ab8e196aaa2b589daf083deb978bbf..ebe1c97e017837e8f177e1c0a12419937763f173 100644 --- a/src/port.c +++ b/src/port.c @@ -244,87 +244,6 @@ PMOD_EXPORT /*@null@*/ void *pike_realloc(void *ptr, size_t sz) #endif /* !CONFIGURE_TEST */ -#define DIGIT(x) (isdigit(x) ? (x) - '0' : \ - islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') -#define MBASE ('z' - 'a' + 1 + 10) - -#ifndef HAVE_STRTOL -PMOD_EXPORT long STRTOL(const char *str, char **ptr, int base) -{ - /* Note: Code duplication in STRTOL_PCHARP and pcharp_to_svalue_inumber. */ - - unsigned long val, mul_limit; - int c; - int xx, neg = 0, add_limit, overflow = 0; - - if (ptr != (char **)NULL) - *ptr = (char *)str; /* in case no number is formed */ - if (base < 0 || base > MBASE) - return 0; /* base is invalid -- should be a fatal error */ - if (!isalnum(c = *str & 0xff)) { - while (isspace(c)) - c = *++str & 0xff; - switch (c) { - case '-': - neg++; - /*@fallthrough@*/ - case '+': - c = *++str & 0xff; - } - } - - if (base == 0) { - if (c != '0') - base = 10; - else if (str[1] == 'x' || 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' && isxdigit(str[2] & 0xff) && - (str[1] == 'x' || str[1] == 'X')) - c = *(str += 2) & 0xff; /* skip over leading "0x" or "0X" */ - - mul_limit = LONG_MAX / base; - add_limit = (int) (LONG_MAX % base); - - if (neg) { - if (++add_limit == base) { - mul_limit++; - add_limit = 0; - } - } - - for (val = (unsigned long)DIGIT(c); - isalnum(c = *++str & 0xff) && (xx = DIGIT(c)) < base; ) { - if (val > mul_limit || (val == mul_limit && xx > add_limit)) - overflow = 1; - else - val = base * val + xx; - } - - if (ptr != (char **)NULL) - *ptr = (char *)str; - if (overflow) { - errno = ERANGE; - return neg ? LONG_MIN : LONG_MAX; - } - else { - if (neg) - return (long)(~val + 1); - else - return (long) val; - } -} -#endif - #ifndef HAVE_STRCASECMP PMOD_EXPORT int STRCASECMP(const char *a,const char *b) { @@ -505,13 +424,13 @@ PMOD_EXPORT double STRTOD(const char * nptr, char **endptr) errno = 0; ++s; - exp = STRTOL((const char *)s, &end, 10); + exp = strtol((const char *)s, &end, 10); if (errno == ERANGE) { /* The exponent overflowed a `long int'. It is probably a safe assumption that an exponent that cannot be represented by a `long int' exceeds the limits of a `double'. */ - /* NOTE: Don't trust the value returned from STRTOL. + /* NOTE: Don't trust the value returned from strtol. * We need to find the sign of the exponent by hand. */ while(isspace(*s)) { diff --git a/src/port.h b/src/port.h index 5eb69ba333d90cc90c73abbddbd2edf45538e9e7..caf58a7f51928d1e89aaf0b343ea501dfd71d659 100644 --- a/src/port.h +++ b/src/port.h @@ -149,11 +149,9 @@ void GETTIMEOFDAY(struct timeval *t); #define RINT rint #define RINTL rintl -#ifndef HAVE_STRTOL -PMOD_EXPORT long STRTOL(const char *str,char **ptr,int base); -#else -# define STRTOL strtol -#endif +#define HAVE_STRTOL 1 +#define STRTOL strtol + #ifndef HAVE_STRTOD PMOD_EXPORT double STRTOD(const char * nptr, char **endptr); #else diff --git a/src/stralloc.c b/src/stralloc.c index 7cd709ca9ee23464b9fd271cbe6472231832c7ef..bb872c80461f3cb690a2849cbc90efde3d9dd17d 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -3253,7 +3253,7 @@ PMOD_EXPORT PCHARP MEMCHR_PCHARP(PCHARP ptr, int chr, ptrdiff_t len) 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 strtol and pcharp_to_svalue_inumber. */ unsigned long val, mul_limit; int c; @@ -3405,7 +3405,7 @@ PMOD_EXPORT int pcharp_to_svalue_inumber(struct svalue *r, int base, ptrdiff_t maxlength) { - /* Note: Code duplication in STRTOL and STRTOL_PCHARP. */ + /* Note: Code duplication in strtol and STRTOL_PCHARP. */ PCHARP str_start; @@ -3630,7 +3630,7 @@ PMOD_EXPORT double STRTOD_PCHARP(PCHARP nptr, PCHARP *endptr) /* The exponent overflowed a `long int'. It is probably a safe assumption that an exponent that cannot be represented by a `long int' exceeds the limits of a `double'. */ - /* NOTE: Don't trust the value returned from STRTOL. + /* NOTE: Don't trust the value returned from strtol. * We need to find the sign of the exponent by hand. */ p_wchar2 c;