diff options
Diffstat (limited to 'generic/tclStrToD.c')
-rw-r--r-- | generic/tclStrToD.c | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index c7fdc5a..539a92c 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -482,7 +482,7 @@ TclParseNumber( { enum State { INITIAL, SIGNUM, ZERO, ZERO_X, - ZERO_O, ZERO_B, BINARY, + ZERO_O, ZERO_B, ZERO_D, BINARY, HEXADECIMAL, OCTAL, BAD_OCTAL, DECIMAL, LEADING_RADIX_POINT, FRACTION, EXPONENT_START, EXPONENT_SIGNUM, EXPONENT, @@ -664,6 +664,10 @@ TclParseNumber( state = ZERO_O; break; } + if (c == 'd' || c == 'D') { + state = ZERO_D; + break; + } #ifdef TCL_NO_DEPRECATED goto decimal; #endif @@ -880,6 +884,16 @@ TclParseNumber( state = BINARY; break; + case ZERO_D: + if (c == '0') { + numTrailZeros++; + } else if ( ! isdigit(UCHAR(c))) { + goto endgame; + } + state = DECIMAL; + flags |= TCL_PARSE_INTEGER_ONLY; + /* FALLTHROUGH */ + case DECIMAL: /* * Scanned an optional + or - followed by a string of decimal @@ -1176,6 +1190,7 @@ TclParseNumber( case ZERO_X: case ZERO_O: case ZERO_B: + case ZERO_D: case LEADING_RADIX_POINT: case EXPONENT_START: case EXPONENT_SIGNUM: @@ -1190,9 +1205,9 @@ TclParseNumber( case sNA: case sNANPAREN: case sNANHEX: +#endif Tcl_Panic("TclParseNumber: bad acceptState %d parsing '%s'", acceptState, bytes); -#endif case BINARY: shift = numTrailZeros; if (!significandOverflow && significandWide != 0 && @@ -1980,7 +1995,7 @@ RefineApproximation( *---------------------------------------------------------------------- */ -inline static void +static inline void MulPow5( mp_int *base, /* Number to multiply. */ unsigned n, /* Power of 5 to multiply by. */ @@ -2025,7 +2040,7 @@ MulPow5( *---------------------------------------------------------------------- */ -inline static int +static inline int NormalizeRightward( Tcl_WideUInt *wPtr) /* INOUT: Number to shift. */ { @@ -2116,7 +2131,7 @@ RequiredPrecision( *---------------------------------------------------------------------- */ -inline static void +static inline void DoubleToExpAndSig( double dv, /* Number to convert. */ Tcl_WideUInt *significand, /* OUTPUT: Significand of the number. */ @@ -2164,7 +2179,7 @@ DoubleToExpAndSig( *---------------------------------------------------------------------- */ -inline static void +static inline void TakeAbsoluteValue( Double *d, /* Number to replace with absolute value. */ int *sign) /* Place to put the signum. */ @@ -2195,7 +2210,7 @@ TakeAbsoluteValue( *---------------------------------------------------------------------- */ -inline static char * +static inline char * FormatInfAndNaN( Double *d, /* Exceptional number to format. */ int *decpt, /* Decimal point to set to a bogus value. */ @@ -2237,7 +2252,7 @@ FormatInfAndNaN( *---------------------------------------------------------------------- */ -inline static char * +static inline char * FormatZero( int *decpt, /* Location of the decimal point. */ char **endPtr) /* Pointer to the end of the formatted data */ @@ -2267,7 +2282,7 @@ FormatZero( *---------------------------------------------------------------------- */ -inline static int +static inline int ApproximateLog10( Tcl_WideUInt bw, /* Integer significand of the number. */ int be, /* Power of two to scale bw. */ @@ -2315,7 +2330,7 @@ ApproximateLog10( *---------------------------------------------------------------------- */ -inline static int +static inline int BetterLog10( double d, /* Original number to format. */ int k, /* Characteristic(Log base 10) of the @@ -2358,7 +2373,7 @@ BetterLog10( *---------------------------------------------------------------------- */ -inline static void +static inline void ComputeScale( int be, /* Exponent part of number: d = bw * 2**be. */ int k, /* Characteristic of log10(number). */ @@ -2421,7 +2436,7 @@ ComputeScale( *---------------------------------------------------------------------- */ -inline static void +static inline void SetPrecisionLimits( int convType, /* Type of conversion: TCL_DD_SHORTEST, * TCL_DD_STEELE0, TCL_DD_E_FMT, @@ -2482,7 +2497,7 @@ SetPrecisionLimits( *---------------------------------------------------------------------- */ -inline static char * +static inline char * BumpUp( char *s, /* Cursor pointing one past the end of the * string. */ @@ -2516,7 +2531,7 @@ BumpUp( *---------------------------------------------------------------------- */ -inline static int +static inline int AdjustRange( double *dPtr, /* INOUT: Number to adjust. */ int k) /* IN: floor(log10(d)) */ @@ -2589,7 +2604,7 @@ AdjustRange( *---------------------------------------------------------------------- */ -inline static char * +static inline char * ShorteningQuickFormat( double d, /* Number to convert. */ int k, /* floor(log10(d)) */ @@ -2664,7 +2679,7 @@ ShorteningQuickFormat( *---------------------------------------------------------------------- */ -inline static char * +static inline char * StrictQuickFormat( double d, /* Number to convert. */ int k, /* floor(log10(d)) */ @@ -2738,7 +2753,7 @@ StrictQuickFormat( *---------------------------------------------------------------------- */ -inline static char * +static inline char * QuickConversion( double e, /* Number to format. */ int k, /* floor(log10(d)), approximately. */ @@ -2843,7 +2858,7 @@ QuickConversion( *---------------------------------------------------------------------- */ -inline static void +static inline void CastOutPowersOf2( int *b2, /* Power of 2 to multiply the significand. */ int *m2, /* Power of 2 to multiply 1/2 ulp. */ @@ -2887,7 +2902,7 @@ CastOutPowersOf2( *---------------------------------------------------------------------- */ -inline static char * +static inline char * ShorteningInt64Conversion( Double *dPtr, /* Original number to convert. */ int convType, /* Type of conversion (shortest, Steele, @@ -3056,7 +3071,7 @@ ShorteningInt64Conversion( *---------------------------------------------------------------------- */ -inline static char * +static inline char * StrictInt64Conversion( Double *dPtr, /* Original number to convert. */ int convType, /* Type of conversion (shortest, Steele, @@ -3162,7 +3177,7 @@ StrictInt64Conversion( *---------------------------------------------------------------------- */ -inline static int +static inline int ShouldBankerRoundUpPowD( mp_int *b, /* Numerator of the fraction. */ int sd, /* Denominator is 2**(sd*DIGIT_BIT). */ @@ -3200,7 +3215,7 @@ ShouldBankerRoundUpPowD( *---------------------------------------------------------------------- */ -inline static int +static inline int ShouldBankerRoundUpToNextPowD( mp_int *b, /* Numerator of the fraction. */ mp_int *m, /* Numerator of the rounding tolerance. */ @@ -3263,7 +3278,7 @@ ShouldBankerRoundUpToNextPowD( *---------------------------------------------------------------------- */ -inline static char * +static inline char * ShorteningBignumConversionPowD( Double *dPtr, /* Original number to convert. */ int convType, /* Type of conversion (shortest, Steele, @@ -3456,7 +3471,7 @@ ShorteningBignumConversionPowD( *---------------------------------------------------------------------- */ -inline static char * +static inline char * StrictBignumConversionPowD( Double *dPtr, /* Original number to convert. */ int convType, /* Type of conversion (shortest, Steele, @@ -3572,7 +3587,7 @@ StrictBignumConversionPowD( *---------------------------------------------------------------------- */ -inline static int +static inline int ShouldBankerRoundUp( mp_int *twor, /* 2x the remainder from thd division that * produced the last digit. */ @@ -3607,7 +3622,7 @@ ShouldBankerRoundUp( *---------------------------------------------------------------------- */ -inline static int +static inline int ShouldBankerRoundUpToNext( mp_int *b, /* Remainder from the division that produced * the last digit. */ @@ -3661,7 +3676,7 @@ ShouldBankerRoundUpToNext( *---------------------------------------------------------------------- */ -inline static char * +static inline char * ShorteningBignumConversion( Double *dPtr, /* Original number being converted. */ int convType, /* Conversion type. */ @@ -3877,7 +3892,7 @@ ShorteningBignumConversion( *---------------------------------------------------------------------- */ -inline static char * +static inline char * StrictBignumConversion( Double *dPtr, /* Original number being converted. */ int convType, /* Conversion type. */ |