[number] Turn hb_parse_float into hb_parse_double
This commit is contained in:
parent
65690b5a4b
commit
57f88e11d4
|
@ -991,7 +991,11 @@ static bool
|
|||
parse_variation_value (const char **pp, const char *end, hb_variation_t *variation)
|
||||
{
|
||||
parse_char (pp, end, '='); /* Optional. */
|
||||
return hb_parse_float (pp, end, &variation->value);
|
||||
double v;
|
||||
if (unlikely (!hb_parse_double (pp, end, &v))) return false;
|
||||
|
||||
variation->value = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -131,16 +131,16 @@ get_C_locale ()
|
|||
#endif /* USE_XLOCALE */
|
||||
|
||||
bool
|
||||
hb_parse_float (const char **pp, const char *end, float *pv,
|
||||
bool whole_buffer)
|
||||
hb_parse_double (const char **pp, const char *end, double *pv,
|
||||
bool whole_buffer)
|
||||
{
|
||||
return _parse_number<float> (pp, end, pv, whole_buffer,
|
||||
[] (const char *p, char **end)
|
||||
{
|
||||
return _parse_number<double> (pp, end, pv, whole_buffer,
|
||||
[] (const char *p, char **end)
|
||||
{
|
||||
#ifdef USE_XLOCALE
|
||||
return strtod_l (p, end, get_C_locale ());
|
||||
return strtod_l (p, end, get_C_locale ());
|
||||
#else
|
||||
return strtod (p, end);
|
||||
return strtod (p, end);
|
||||
#endif
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ hb_parse_uint (const char **pp, const char *end, unsigned int *pv,
|
|||
bool whole_buffer = false, int base = 10);
|
||||
|
||||
HB_INTERNAL bool
|
||||
hb_parse_float (const char **pp, const char *end, float *pv,
|
||||
bool whole_buffer = false);
|
||||
hb_parse_double (const char **pp, const char *end, double *pv,
|
||||
bool whole_buffer = false);
|
||||
|
||||
#endif /* HB_NUMBER_HH */
|
||||
|
|
|
@ -140,9 +140,9 @@ main (int argc, char **argv)
|
|||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str);
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == 123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == 123);
|
||||
assert (pp - str == 4);
|
||||
assert (end - pp == 1);
|
||||
}
|
||||
|
@ -152,9 +152,9 @@ main (int argc, char **argv)
|
|||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == 123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == 123);
|
||||
assert (pp - str == 5);
|
||||
assert (end - pp == 0);
|
||||
}
|
||||
|
@ -164,9 +164,9 @@ main (int argc, char **argv)
|
|||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == 123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == 123);
|
||||
assert (pp - str == 7);
|
||||
assert (end - pp == 0);
|
||||
}
|
||||
|
@ -176,9 +176,9 @@ main (int argc, char **argv)
|
|||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == 123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == 123);
|
||||
assert (pp - str == 6);
|
||||
assert (end - pp == 0);
|
||||
}
|
||||
|
@ -188,9 +188,9 @@ main (int argc, char **argv)
|
|||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == 123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == 123);
|
||||
assert (pp - str == 10);
|
||||
assert (end - pp == 0);
|
||||
}
|
||||
|
@ -200,21 +200,21 @@ main (int argc, char **argv)
|
|||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == -123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == -123);
|
||||
assert (pp - str == 13);
|
||||
assert (end - pp == 0);
|
||||
}
|
||||
|
||||
{
|
||||
const char str[] = "-1.23e-1";
|
||||
const char str[] = "-1.23E-1";
|
||||
const char *pp = str;
|
||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||
|
||||
float pv;
|
||||
assert (hb_parse_float (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.f) == -123);
|
||||
double pv;
|
||||
assert (hb_parse_double (&pp, end, &pv));
|
||||
assert ((int) (pv * 1000.) == -123);
|
||||
assert (pp - str == 8);
|
||||
assert (end - pp == 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue