diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-04-16 13:36:33 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-04-16 13:36:33 (GMT) |
commit | 3b2f0df2b4603b0565ad30e1e15ae9f0bfe3cb5f (patch) | |
tree | 88437ef1c667959b00a3b86ee638cc3a94300aab /compat/strtod.c | |
parent | b443cf5d2f6f6c75dc77a88987ed558a2fca9ba5 (diff) | |
download | tcl-3b2f0df2b4603b0565ad30e1e15ae9f0bfe3cb5f.zip tcl-3b2f0df2b4603b0565ad30e1e15ae9f0bfe3cb5f.tar.gz tcl-3b2f0df2b4603b0565ad30e1e15ae9f0bfe3cb5f.tar.bz2 |
Complete the purge of K&R function definitions from manually-written code.
Diffstat (limited to 'compat/strtod.c')
-rw-r--r-- | compat/strtod.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/compat/strtod.c b/compat/strtod.c index b75d72e..9e494b1 100644 --- a/compat/strtod.c +++ b/compat/strtod.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: strtod.c,v 1.7 2004/04/06 22:25:48 dgp Exp $ + * RCS: @(#) $Id: strtod.c,v 1.8 2007/04/16 13:36:34 dkf Exp $ */ #include "tclInt.h" @@ -62,20 +62,19 @@ static double powersOf10[] = { /* Table giving binary powers of 10. Entry */ */ double -strtod(string, endPtr) - CONST char *string; /* A decimal ASCII floating-point number, - * optionally preceded by white space. - * Must have form "-I.FE-X", where I is the - * integer part of the mantissa, F is the - * fractional part of the mantissa, and X - * is the exponent. Either of the signs - * may be "+", "-", or omitted. Either I - * or F may be omitted, or both. The decimal - * point isn't necessary unless F is present. - * The "E" may actually be an "e". E and X - * may both be omitted (but not just one). - */ - char **endPtr; /* If non-NULL, store terminating character's +strtod( + CONST char *string, /* A decimal ASCII floating-point number, + * optionally preceded by white space. Must + * have form "-I.FE-X", where I is the integer + * part of the mantissa, F is the fractional + * part of the mantissa, and X is the + * exponent. Either of the signs may be "+", + * "-", or omitted. Either I or F may be + * omitted, or both. The decimal point isn't + * necessary unless F is present. The "E" may + * actually be an "e". E and X may both be + * omitted (but not just one). */ + char **endPtr) /* If non-NULL, store terminating character's * address here. */ { int sign, expSign = FALSE; @@ -84,19 +83,19 @@ strtod(string, endPtr) register int c; int exp = 0; /* Exponent read from "EX" field. */ int fracExp = 0; /* Exponent that derives from the fractional - * part. Under normal circumstatnces, it is + * part. Under normal circumstatnces, it is * the negative of the number of digits in F. * However, if I is very long, the last digits * of I get dropped (otherwise a long I with a * large negative exponent could cause an - * unnecessary overflow on I alone). In this + * unnecessary overflow on I alone). In this * case, fracExp is incremented one for each * dropped digit. */ int mantSize; /* Number of digits in mantissa. */ int decPt; /* Number of mantissa digits BEFORE decimal * point. */ - CONST char *pExp; /* Temporarily holds location of exponent - * in string. */ + CONST char *pExp; /* Temporarily holds location of exponent in + * string. */ /* * Strip off leading blanks and check for a sign. @@ -135,10 +134,10 @@ strtod(string, endPtr) } /* - * Now suck up the digits in the mantissa. Use two integers to - * collect 9 digits each (this is faster than using floating-point). - * If the mantissa has more than 18 digits, ignore the extras, since - * they can't affect the value anyway. + * Now suck up the digits in the mantissa. Use two integers to collect 9 + * digits each (this is faster than using floating-point). If the mantissa + * has more than 18 digits, ignore the extras, since they can't affect the + * value anyway. */ pExp = p; @@ -146,7 +145,7 @@ strtod(string, endPtr) if (decPt < 0) { decPt = mantSize; } else { - mantSize -= 1; /* One of the digits was the point. */ + mantSize -= 1; /* One of the digits was the point. */ } if (mantSize > 18) { fracExp = decPt - 18; @@ -160,9 +159,9 @@ strtod(string, endPtr) goto done; } else { int frac1, frac2; + frac1 = 0; - for ( ; mantSize > 9; mantSize -= 1) - { + for ( ; mantSize > 9; mantSize -= 1) { c = *p; p += 1; if (c == '.') { @@ -172,8 +171,7 @@ strtod(string, endPtr) frac1 = 10*frac1 + (c - '0'); } frac2 = 0; - for (; mantSize > 0; mantSize -= 1) - { + for (; mantSize > 0; mantSize -= 1) { c = *p; p += 1; if (c == '.') { @@ -217,10 +215,9 @@ strtod(string, endPtr) } /* - * Generate a floating-point number that represents the exponent. - * Do this by processing the exponent one bit at a time to combine - * many powers of 2 of 10. Then combine the exponent with the - * fraction. + * Generate a floating-point number that represents the exponent. Do this + * by processing the exponent one bit at a time to combine many powers of + * 2 of 10. Then combine the exponent with the fraction. */ if (exp < 0) { @@ -245,7 +242,7 @@ strtod(string, endPtr) fraction *= dblExp; } -done: + done: if (endPtr != NULL) { *endPtr = (char *) p; } |