From: Jarkko Hietaniemi Date: Sat, 11 Mar 2000 19:03:32 +0000 (+0000) Subject: Use Atof() instead of bare strtod(); ditto for Atol()/Atoul() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55eb892c8d1c2d0317b54696f56f6afb30a62cd1;p=p5sagit%2Fp5-mst-13.2.git Use Atof() instead of bare strtod(); ditto for Atol()/Atoul() (introduce the latter) instead of bare strtoll()/strtoll(). p4raw-id: //depot/cfgperl@5661 --- diff --git a/perl.h b/perl.h index b0100e1..2ce9084 100644 --- a/perl.h +++ b/perl.h @@ -1173,7 +1173,7 @@ typedef NVTYPE NV; #endif #if !defined(Perl_atof) && defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) -# if !defined(Perl_atof) && defined(HAS_STRTOLD) +# if !defined(Perl_atof) && defined(HAS_STRTOLD) # define Perl_atof(s) strtold(s, (char**)NULL) # endif # if !defined(Perl_atof) && defined(HAS_ATOLF) @@ -3075,7 +3075,7 @@ typedef struct am_table_short AMTS; #endif /* !USE_LOCALE_NUMERIC */ -#if !defined(Atol) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG +#if !defined(Atol) && defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG # ifdef __hpux # define strtoll __strtoll /* secret handshake */ # endif @@ -3091,7 +3091,7 @@ typedef struct am_table_short AMTS; # define Atol atol /* we assume atol being available anywhere */ #endif -#if !defined(Strtoul) && defined(UV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG +#if !defined(Strtoul) && defined(USE_64_BIT_INT) && defined(UV_IS_QUAD) && QUADKIND == QUAD_IS_LONG_LONG # ifdef __hpux # define strtoull __strtoull /* secret handshake */ # endif @@ -3106,6 +3106,9 @@ typedef struct am_table_short AMTS; #if !defined(Strtoul) # define Strtoul strtoul /* we assume strtoul being available anywhere */ #endif +#ifndef Atoul +# define Atoul Strtoul +#endif #if !defined(PERLIO_IS_STDIO) && defined(HASATTRIBUTE) /* diff --git a/toke.c b/toke.c index 5740442..2e6120d 100644 --- a/toke.c +++ b/toke.c @@ -6978,22 +6978,14 @@ Perl_scan_num(pTHX_ char *start) */ if (!floatit) { - char *tp; IV iv; UV uv; errno = 0; -#ifdef USE_64_BIT_INT - if (*PL_tokenbuf == '-') - iv = strtoll(PL_tokenbuf,&tp,10); - else - uv = strtoull(PL_tokenbuf,&tp,10); -#else if (*PL_tokenbuf == '-') - iv = strtol(PL_tokenbuf,&tp,10); + iv = Atol(PL_tokenbuf); else - uv = strtoul(PL_tokenbuf,&tp,10); -#endif - if (*tp || errno) + uv = Atoul(PL_tokenbuf); + if (errno) floatit = TRUE; /* probably just too large */ else if (*PL_tokenbuf == '-') sv_setiv(sv, iv); @@ -7003,13 +6995,8 @@ Perl_scan_num(pTHX_ char *start) if (floatit) { char *tp; errno = 0; -/* For some reason VMS doesn't have strrold at the moment. Dunno why */ -#if defined(USE_LONG_DOUBLE) && (defined(HAS_STRTOLD) || !defined(VMS)) - value = strtold(PL_tokenbuf,&tp); -#else - value = strtod(PL_tokenbuf,&tp); -#endif - if (*tp || errno) + value = Atof(PL_tokenbuf); + if (errno) Perl_die(aTHX_ "unparseable float"); else sv_setnv(sv, value);