[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_variation_value (const char **pp, const char *end, hb_variation_t *variation)
|
||||||
{
|
{
|
||||||
parse_char (pp, end, '='); /* Optional. */
|
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
|
static bool
|
||||||
|
|
|
@ -131,10 +131,10 @@ get_C_locale ()
|
||||||
#endif /* USE_XLOCALE */
|
#endif /* USE_XLOCALE */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
hb_parse_float (const char **pp, const char *end, float *pv,
|
hb_parse_double (const char **pp, const char *end, double *pv,
|
||||||
bool whole_buffer)
|
bool whole_buffer)
|
||||||
{
|
{
|
||||||
return _parse_number<float> (pp, end, pv, whole_buffer,
|
return _parse_number<double> (pp, end, pv, whole_buffer,
|
||||||
[] (const char *p, char **end)
|
[] (const char *p, char **end)
|
||||||
{
|
{
|
||||||
#ifdef USE_XLOCALE
|
#ifdef USE_XLOCALE
|
||||||
|
|
|
@ -35,7 +35,7 @@ hb_parse_uint (const char **pp, const char *end, unsigned int *pv,
|
||||||
bool whole_buffer = false, int base = 10);
|
bool whole_buffer = false, int base = 10);
|
||||||
|
|
||||||
HB_INTERNAL bool
|
HB_INTERNAL bool
|
||||||
hb_parse_float (const char **pp, const char *end, float *pv,
|
hb_parse_double (const char **pp, const char *end, double *pv,
|
||||||
bool whole_buffer = false);
|
bool whole_buffer = false);
|
||||||
|
|
||||||
#endif /* HB_NUMBER_HH */
|
#endif /* HB_NUMBER_HH */
|
||||||
|
|
|
@ -140,9 +140,9 @@ main (int argc, char **argv)
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str);
|
const char *end = str + ARRAY_LENGTH (str);
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == 123);
|
assert ((int) (pv * 1000.) == 123);
|
||||||
assert (pp - str == 4);
|
assert (pp - str == 4);
|
||||||
assert (end - pp == 1);
|
assert (end - pp == 1);
|
||||||
}
|
}
|
||||||
|
@ -152,9 +152,9 @@ main (int argc, char **argv)
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == 123);
|
assert ((int) (pv * 1000.) == 123);
|
||||||
assert (pp - str == 5);
|
assert (pp - str == 5);
|
||||||
assert (end - pp == 0);
|
assert (end - pp == 0);
|
||||||
}
|
}
|
||||||
|
@ -164,9 +164,9 @@ main (int argc, char **argv)
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == 123);
|
assert ((int) (pv * 1000.) == 123);
|
||||||
assert (pp - str == 7);
|
assert (pp - str == 7);
|
||||||
assert (end - pp == 0);
|
assert (end - pp == 0);
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,9 @@ main (int argc, char **argv)
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == 123);
|
assert ((int) (pv * 1000.) == 123);
|
||||||
assert (pp - str == 6);
|
assert (pp - str == 6);
|
||||||
assert (end - pp == 0);
|
assert (end - pp == 0);
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,9 @@ main (int argc, char **argv)
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == 123);
|
assert ((int) (pv * 1000.) == 123);
|
||||||
assert (pp - str == 10);
|
assert (pp - str == 10);
|
||||||
assert (end - pp == 0);
|
assert (end - pp == 0);
|
||||||
}
|
}
|
||||||
|
@ -200,21 +200,21 @@ main (int argc, char **argv)
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == -123);
|
assert ((int) (pv * 1000.) == -123);
|
||||||
assert (pp - str == 13);
|
assert (pp - str == 13);
|
||||||
assert (end - pp == 0);
|
assert (end - pp == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char str[] = "-1.23e-1";
|
const char str[] = "-1.23E-1";
|
||||||
const char *pp = str;
|
const char *pp = str;
|
||||||
const char *end = str + ARRAY_LENGTH (str) - 1;
|
const char *end = str + ARRAY_LENGTH (str) - 1;
|
||||||
|
|
||||||
float pv;
|
double pv;
|
||||||
assert (hb_parse_float (&pp, end, &pv));
|
assert (hb_parse_double (&pp, end, &pv));
|
||||||
assert ((int) (pv * 1000.f) == -123);
|
assert ((int) (pv * 1000.) == -123);
|
||||||
assert (pp - str == 8);
|
assert (pp - str == 8);
|
||||||
assert (end - pp == 0);
|
assert (end - pp == 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue