|
|
|
@ -32,6 +32,7 @@ |
|
|
|
|
#include "hb.hh" |
|
|
|
|
#include "hb-meta.hh" |
|
|
|
|
#include "hb-null.hh" |
|
|
|
|
#include "hb-number.hh" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Encodes three unsigned integers in one 64-bit number. If the inputs have more than 21 bits,
|
|
|
|
@ -896,17 +897,14 @@ hb_stable_sort (T *array, unsigned int len, int(*compar)(const T *, const T *)) |
|
|
|
|
static inline hb_bool_t |
|
|
|
|
hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *out) |
|
|
|
|
{ |
|
|
|
|
/* Pain because we don't know whether s is nul-terminated. */ |
|
|
|
|
char buf[64]; |
|
|
|
|
len = hb_min (ARRAY_LENGTH (buf) - 1, len); |
|
|
|
|
strncpy (buf, s, len); |
|
|
|
|
buf[len] = '\0'; |
|
|
|
|
|
|
|
|
|
char *end; |
|
|
|
|
errno = 0; |
|
|
|
|
unsigned long v = strtoul (buf, &end, base); |
|
|
|
|
if (errno) return false; |
|
|
|
|
if (*end) return false; |
|
|
|
|
unsigned int v; |
|
|
|
|
const char *p = s; |
|
|
|
|
const char *end = p + len; |
|
|
|
|
if (!hb_parse_uint (&p, p + len, &v, base)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (end != p && *p) return false; |
|
|
|
|
|
|
|
|
|
*out = v; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|