summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/double-conversion/double-conversion/strtod.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/double-conversion/double-conversion/strtod.h')
-rw-r--r--src/3rdparty/double-conversion/double-conversion/strtod.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/3rdparty/double-conversion/double-conversion/strtod.h b/src/3rdparty/double-conversion/double-conversion/strtod.h
index ff0ee47092..77221fb9d5 100644
--- a/src/3rdparty/double-conversion/double-conversion/strtod.h
+++ b/src/3rdparty/double-conversion/double-conversion/strtod.h
@@ -40,11 +40,25 @@ double Strtod(Vector<const char> buffer, int exponent);
// contain a dot or a sign. It must not start with '0', and must not be empty.
float Strtof(Vector<const char> buffer, int exponent);
-// For special use cases, the heart of the Strtod() function is also available
-// separately, it assumes that 'trimmed' is as produced by TrimAndCut(), i.e.
-// no leading or trailing zeros, also no lone zero, and not 'too many' digits.
+// Same as Strtod, but assumes that 'trimmed' is already trimmed, as if run
+// through TrimAndCut. That is, 'trimmed' must have no leading or trailing
+// zeros, must not be a lone zero, and must not have 'too many' digits.
double StrtodTrimmed(Vector<const char> trimmed, int exponent);
+// Same as Strtof, but assumes that 'trimmed' is already trimmed, as if run
+// through TrimAndCut. That is, 'trimmed' must have no leading or trailing
+// zeros, must not be a lone zero, and must not have 'too many' digits.
+float StrtofTrimmed(Vector<const char> trimmed, int exponent);
+
+inline Vector<const char> TrimTrailingZeros(Vector<const char> buffer) {
+ for (int i = buffer.length() - 1; i >= 0; --i) {
+ if (buffer[i] != '0') {
+ return buffer.SubVector(0, i + 1);
+ }
+ }
+ return Vector<const char>(buffer.start(), 0);
+}
+
} // namespace double_conversion
#endif // DOUBLE_CONVERSION_STRTOD_H_