mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
unsigned number parsing
This commit is contained in:
parent
68a0959795
commit
19c7cadad2
1 changed files with 15 additions and 1 deletions
|
@ -387,7 +387,7 @@ static inline
|
||||||
PsycParseListRC psyc_parse_list (PsycParseListState *state, PsycString *elem);
|
PsycParseListRC psyc_parse_list (PsycParseListState *state, PsycString *elem);
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
PsycBool psyc_parse_number (const char *value, size_t len, ssize_t *n)
|
PsycBool psyc_parse_number (const char *value, size_t len, int64_t *n)
|
||||||
{
|
{
|
||||||
size_t c = 0;
|
size_t c = 0;
|
||||||
uint8_t neg = 0;
|
uint8_t neg = 0;
|
||||||
|
@ -411,6 +411,20 @@ PsycBool psyc_parse_number (const char *value, size_t len, ssize_t *n)
|
||||||
return PSYC_TRUE;
|
return PSYC_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
PsycBool psyc_parse_number_unsigned (const char *value, size_t len, uint64_t *n)
|
||||||
|
{
|
||||||
|
size_t c = 0;
|
||||||
|
if (!value)
|
||||||
|
return PSYC_FALSE;
|
||||||
|
|
||||||
|
*n = 0;
|
||||||
|
while (c < len && value[c] >= '0' && value[c] <= '9')
|
||||||
|
*n = 10 * *n + (value[c++] - '0');
|
||||||
|
|
||||||
|
return c == len ? PSYC_TRUE : PSYC_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
PsycBool psyc_parse_time (const char *value, size_t len, time_t *t)
|
PsycBool psyc_parse_time (const char *value, size_t len, time_t *t)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue