diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-08-10 07:59:49 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-08-10 07:59:49 +0900 |
| commit | 9e0c48ddc63a959ecd83493773a6466bab7cac93 (patch) | |
| tree | a2b928be7c8dd7103aded1df6ce547ad18aef54e /src | |
| parent | 24c345fe5c68a3f0cd4d16e84c8bf6ed93cedce8 (diff) | |
| parent | 2fadddcd20a16afe0e710d07288e106993a43a07 (diff) | |
| download | mruby-9e0c48ddc63a959ecd83493773a6466bab7cac93.tar.gz mruby-9e0c48ddc63a959ecd83493773a6466bab7cac93.zip | |
Merge pull request #3770 from christopheraue/tabs_to_spaces
Replaced tabs with spaces
Diffstat (limited to 'src')
| -rw-r--r-- | src/string.c | 230 | ||||
| -rw-r--r-- | src/vm.c | 8 |
2 files changed, 119 insertions, 119 deletions
diff --git a/src/string.c b/src/string.c index 6fdb7fe72..5abc5c4cf 100644 --- a/src/string.c +++ b/src/string.c @@ -2786,7 +2786,7 @@ mrb_init_string(mrb_state *mrb) } /* - * Source code for the "strtod" library procedure. + * Source code for the "strtod" library procedure. * * Copyright (c) 1988-1993 The Regents of the University of California. * Copyright (c) 1994 Sun Microsystems, Inc. @@ -2812,7 +2812,7 @@ static const int maxExponent = 511; /* Largest possible base 10 exponent. Any */ static const double powersOf10[] = {/* Table giving binary powers of 10. Entry */ 10., /* is 10^2^i. Used to convert decimal */ - 100., /* exponents into floating-point numbers. */ + 100., /* exponents into floating-point numbers. */ 1.0e4, 1.0e8, 1.0e16, @@ -2824,41 +2824,41 @@ static const double powersOf10[] = {/* Table giving binary powers of 10. Entry MRB_API double mrb_float_read(const char *string, char **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 - * address here. */ +/* 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; double fraction, dblExp; const double *d; register const char *p; 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 - * 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 - * 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. */ + int exp = 0; /* Exponent read from "EX" field. */ + int fracExp = 0; /* Exponent that derives from the fractional + * 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 + * 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. */ /* * Strip off leading blanks and check for a sign. @@ -2866,17 +2866,17 @@ mrb_float_read(const char *string, char **endPtr) p = string; while (isspace(*p)) { - p += 1; + p += 1; } if (*p == '-') { - sign = TRUE; - p += 1; + sign = TRUE; + p += 1; } else { - if (*p == '+') { - p += 1; - } - sign = FALSE; + if (*p == '+') { + p += 1; + } + sign = FALSE; } /* @@ -2887,14 +2887,14 @@ mrb_float_read(const char *string, char **endPtr) decPt = -1; for (mantSize = 0; ; mantSize += 1) { - c = *p; - if (!isdigit(c)) { - if ((c != '.') || (decPt >= 0)) { - break; - } - decPt = mantSize; - } - p += 1; + c = *p; + if (!isdigit(c)) { + if ((c != '.') || (decPt >= 0)) { + break; + } + decPt = mantSize; + } + p += 1; } /* @@ -2907,53 +2907,53 @@ mrb_float_read(const char *string, char **endPtr) pExp = p; p -= mantSize; if (decPt < 0) { - decPt = mantSize; + decPt = mantSize; } else { - mantSize -= 1; /* One of the digits was the point. */ + mantSize -= 1; /* One of the digits was the point. */ } if (mantSize > 18) { - if (decPt - 18 > 29999) { - fracExp = 29999; - } - else { - fracExp = decPt - 18; - } - mantSize = 18; + if (decPt - 18 > 29999) { + fracExp = 29999; + } + else { + fracExp = decPt - 18; + } + mantSize = 18; } else { - fracExp = decPt - mantSize; + fracExp = decPt - mantSize; } if (mantSize == 0) { - fraction = 0.0; - p = string; - goto done; + fraction = 0.0; + p = string; + goto done; } else { - int frac1, frac2; - frac1 = 0; - for ( ; mantSize > 9; mantSize -= 1) - { - c = *p; - p += 1; - if (c == '.') { - c = *p; - p += 1; - } - frac1 = 10*frac1 + (c - '0'); - } - frac2 = 0; - for (; mantSize > 0; mantSize -= 1) - { - c = *p; - p += 1; - if (c == '.') { - c = *p; - p += 1; - } - frac2 = 10*frac2 + (c - '0'); - } - fraction = (1.0e9 * frac1) + frac2; + int frac1, frac2; + frac1 = 0; + for ( ; mantSize > 9; mantSize -= 1) + { + c = *p; + p += 1; + if (c == '.') { + c = *p; + p += 1; + } + frac1 = 10*frac1 + (c - '0'); + } + frac2 = 0; + for (; mantSize > 0; mantSize -= 1) + { + c = *p; + p += 1; + if (c == '.') { + c = *p; + p += 1; + } + frac2 = 10*frac2 + (c - '0'); + } + fraction = (1.0e9 * frac1) + frac2; } /* @@ -2962,30 +2962,30 @@ mrb_float_read(const char *string, char **endPtr) p = pExp; if ((*p == 'E') || (*p == 'e')) { - p += 1; - if (*p == '-') { - expSign = TRUE; - p += 1; - } - else { - if (*p == '+') { - p += 1; - } - expSign = FALSE; - } - while (isdigit(*p)) { - exp = exp * 10 + (*p - '0'); - if (exp > 19999) { - exp = 19999; - } - p += 1; - } + p += 1; + if (*p == '-') { + expSign = TRUE; + p += 1; + } + else { + if (*p == '+') { + p += 1; + } + expSign = FALSE; + } + while (isdigit(*p)) { + exp = exp * 10 + (*p - '0'); + if (exp > 19999) { + exp = 19999; + } + p += 1; + } } if (expSign) { - exp = fracExp - exp; + exp = fracExp - exp; } else { - exp = fracExp + exp; + exp = fracExp + exp; } /* @@ -2996,36 +2996,36 @@ mrb_float_read(const char *string, char **endPtr) */ if (exp < 0) { - expSign = TRUE; - exp = -exp; + expSign = TRUE; + exp = -exp; } else { - expSign = FALSE; + expSign = FALSE; } if (exp > maxExponent) { - exp = maxExponent; - errno = ERANGE; + exp = maxExponent; + errno = ERANGE; } dblExp = 1.0; for (d = powersOf10; exp != 0; exp >>= 1, d += 1) { - if (exp & 01) { - dblExp *= *d; - } + if (exp & 01) { + dblExp *= *d; + } } if (expSign) { - fraction /= dblExp; + fraction /= dblExp; } else { - fraction *= dblExp; + fraction *= dblExp; } done: if (endPtr != NULL) { - *endPtr = (char *) p; + *endPtr = (char *) p; } if (sign) { - return -fraction; + return -fraction; } return fraction; } @@ -1934,13 +1934,13 @@ RETRY_TRY_BLOCK: } /* call ensure only when we skip this callinfo */ if (ci[0].ridx == ci[-1].ridx) { - mrb_value *org_stbase = mrb->c->stbase; + mrb_value *org_stbase = mrb->c->stbase; while (mrb->c->eidx > ci->epos) { ecall(mrb, --mrb->c->eidx); ci = mrb->c->ci; - if (org_stbase != mrb->c->stbase) { - stk = mrb->c->stack; - } + if (org_stbase != mrb->c->stbase) { + stk = mrb->c->stack; + } } } } |
