summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl21
1 files changed, 9 insertions, 12 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl
index 8445fa22a13..c6c4a3bab88 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-number-parser.rl
@@ -28,8 +28,6 @@
#include "hb.hh"
-#include <float.h>
-
%%{
machine double_parser;
@@ -71,7 +69,7 @@ main := (
/* Works only for n < 512 */
static inline double
-_pow10 (unsigned int exponent)
+_pow10 (unsigned exponent)
{
static const double _powers_of_10[] =
{
@@ -85,27 +83,26 @@ _pow10 (unsigned int exponent)
100.,
10.
};
- unsigned int mask = 1 << (ARRAY_LENGTH (_powers_of_10) - 1);
+ unsigned mask = 1 << (ARRAY_LENGTH (_powers_of_10) - 1);
double result = 1;
for (const double *power = _powers_of_10; mask; ++power, mask >>= 1)
if (exponent & mask) result *= *power;
return result;
}
+/* a variant of strtod that also gets end of buffer in its second argument */
static inline double
-strtod_rl (const char *buf, char **end_ptr)
+strtod_rl (const char *p, const char **end_ptr /* IN/OUT */)
{
- const char *p, *pe;
double value = 0;
double frac = 0;
double frac_count = 0;
- unsigned int exp = 0;
+ unsigned exp = 0;
bool neg = false, exp_neg = false, exp_overflow = false;
- const unsigned long long MAX_FRACT = 0xFFFFFFFFFFFFFull; /* 1^52-1 */
- const unsigned int MAX_EXP = 0x7FFu; /* 1^11-1 */
- p = buf;
- pe = p + strlen (p);
+ const unsigned long long MAX_FRACT = 0xFFFFFFFFFFFFFull; /* 2^52-1 */
+ const unsigned MAX_EXP = 0x7FFu; /* 2^11-1 */
+ const char *pe = *end_ptr;
while (p < pe && ISSPACE (*p))
p++;
@@ -115,7 +112,7 @@ strtod_rl (const char *buf, char **end_ptr)
write exec;
}%%
- *end_ptr = (char *) p;
+ *end_ptr = p;
if (frac_count) value += frac / _pow10 (frac_count);
if (neg) value *= -1.;