|
@@ -310,14 +310,6 @@ String String::operator+(const String &p_str) const {
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
-String String::operator+(CharType p_chr) const {
|
|
|
|
-
|
|
|
|
- String res=*this;
|
|
|
|
- res+=p_chr;
|
|
|
|
- return res;
|
|
|
|
-}
|
|
|
|
-*/
|
|
|
|
String &String::operator+=(const String &p_str) {
|
|
String &String::operator+=(const String &p_str) {
|
|
if (empty()) {
|
|
if (empty()) {
|
|
*this = p_str;
|
|
*this = p_str;
|
|
@@ -1675,14 +1667,6 @@ CharString String::utf8() const {
|
|
return utf8s;
|
|
return utf8s;
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
-String::String(CharType p_char) {
|
|
|
|
-
|
|
|
|
- shared=NULL;
|
|
|
|
- copy_from(p_char);
|
|
|
|
-}
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
String::String(const char *p_str) {
|
|
String::String(const char *p_str) {
|
|
copy_from(p_str);
|
|
copy_from(p_str);
|
|
}
|
|
}
|
|
@@ -1937,28 +1921,33 @@ bool String::is_numeric() const {
|
|
};
|
|
};
|
|
|
|
|
|
template <class C>
|
|
template <class C>
|
|
-static double built_in_strtod(const C *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). */
|
|
|
|
- C **endPtr = nullptr) /* If non-NULL, store terminating Cacter's
|
|
|
|
- * address here. */
|
|
|
|
-{
|
|
|
|
- static const int maxExponent = 511; /* Largest possible base 10 exponent. Any
|
|
|
|
- * exponent larger than this will already
|
|
|
|
- * produce underflow or overflow, so there's
|
|
|
|
- * no need to worry about additional digits.
|
|
|
|
- */
|
|
|
|
- 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. */
|
|
|
|
|
|
+static double built_in_strtod(
|
|
|
|
+ /* 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). */
|
|
|
|
+ const C *string,
|
|
|
|
+ /* If non-nullptr, store terminating Cacter's
|
|
|
|
+ * address here. */
|
|
|
|
+ C **endPtr = nullptr) {
|
|
|
|
+ /* Largest possible base 10 exponent. Any
|
|
|
|
+ * exponent larger than this will already
|
|
|
|
+ * produce underflow or overflow, so there's
|
|
|
|
+ * no need to worry about additional digits. */
|
|
|
|
+ static const int maxExponent = 511;
|
|
|
|
+ /* Table giving binary powers of 10. Entry
|
|
|
|
+ * is 10^2^i. Used to convert decimal
|
|
|
|
+ * exponents into floating-point numbers. */
|
|
|
|
+ static const double powersOf10[] = {
|
|
|
|
+ 10.,
|
|
|
|
+ 100.,
|
|
1.0e4,
|
|
1.0e4,
|
|
1.0e8,
|
|
1.0e8,
|
|
1.0e16,
|
|
1.0e16,
|
|
@@ -1973,25 +1962,28 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
|
|
const double *d;
|
|
const double *d;
|
|
const C *p;
|
|
const C *p;
|
|
int c;
|
|
int c;
|
|
- int exp = 0; /* Exponent read from "EX" field. */
|
|
|
|
- int fracExp = 0; /* Exponent that derives from the fractional
|
|
|
|
- * part. Under normal circumstances, 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 C *pExp; /* Temporarily holds location of exponent in
|
|
|
|
- * string. */
|
|
|
|
|
|
+ /* Exponent read from "EX" field. */
|
|
|
|
+ int exp = 0;
|
|
|
|
+ /* Exponent that derives from the fractional
|
|
|
|
+ * part. Under normal circumstances, 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 fracExp = 0;
|
|
|
|
+ /* Number of digits in mantissa. */
|
|
|
|
+ int mantSize;
|
|
|
|
+ /* Number of mantissa digits BEFORE decimal point. */
|
|
|
|
+ int decPt;
|
|
|
|
+ /* Temporarily holds location of exponent in string. */
|
|
|
|
+ const C *pExp;
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Strip off leading blanks and check for a sign.
|
|
|
|
- */
|
|
|
|
|
|
+ * Strip off leading blanks and check for a sign.
|
|
|
|
+ */
|
|
|
|
|
|
p = string;
|
|
p = string;
|
|
while (*p == ' ' || *p == '\t' || *p == '\n') {
|
|
while (*p == ' ' || *p == '\t' || *p == '\n') {
|
|
@@ -2008,9 +2000,9 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Count the number of digits in the mantissa (including the decimal
|
|
|
|
- * point), and also locate the decimal point.
|
|
|
|
- */
|
|
|
|
|
|
+ * Count the number of digits in the mantissa (including the decimal
|
|
|
|
+ * point), and also locate the decimal point.
|
|
|
|
+ */
|
|
|
|
|
|
decPt = -1;
|
|
decPt = -1;
|
|
for (mantSize = 0;; mantSize += 1) {
|
|
for (mantSize = 0;; mantSize += 1) {
|
|
@@ -2025,11 +2017,11 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * 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;
|
|
pExp = p;
|
|
p -= mantSize;
|
|
p -= mantSize;
|
|
@@ -2075,8 +2067,8 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Skim off the exponent.
|
|
|
|
- */
|
|
|
|
|
|
+ * Skim off the exponent.
|
|
|
|
+ */
|
|
|
|
|
|
p = pExp;
|
|
p = pExp;
|
|
if ((*p == 'E') || (*p == 'e')) {
|
|
if ((*p == 'E') || (*p == 'e')) {
|
|
@@ -2106,10 +2098,10 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * 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) {
|
|
if (exp < 0) {
|
|
expSign = true;
|
|
expSign = true;
|
|
@@ -2154,7 +2146,6 @@ done:
|
|
double String::to_double(const char *p_str) {
|
|
double String::to_double(const char *p_str) {
|
|
#ifndef NO_USE_STDLIB
|
|
#ifndef NO_USE_STDLIB
|
|
return built_in_strtod<char>(p_str);
|
|
return built_in_strtod<char>(p_str);
|
|
-//return atof(p_str); DOES NOT WORK ON ANDROID(??)
|
|
|
|
#else
|
|
#else
|
|
return built_in_strtod<char>(p_str);
|
|
return built_in_strtod<char>(p_str);
|
|
#endif
|
|
#endif
|