lib: json: Fix warning when building with newlib
If we use newlib the isdigit (and other similar functions) return an error as char can possibly be viewed as signed: usr/include/ctype.h:57:54: error: array subscript has type ‘char’ [-Werror=char-subscripts] #define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)]) Explicity cast to unsigned char so we deal with both this warning and possible warning when -Wpointer-sign is enabled. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
8317e366a8
commit
9aebe8b466
1 changed files with 6 additions and 6 deletions
|
@ -77,7 +77,7 @@ static void emit(struct lexer *lexer, enum json_tokens token)
|
|||
lexer->start = lexer->pos;
|
||||
}
|
||||
|
||||
static char next(struct lexer *lexer)
|
||||
static int next(struct lexer *lexer)
|
||||
{
|
||||
if (lexer->pos >= lexer->end) {
|
||||
lexer->pos = lexer->end + 1;
|
||||
|
@ -98,9 +98,9 @@ static void backup(struct lexer *lexer)
|
|||
lexer->pos--;
|
||||
}
|
||||
|
||||
static char peek(struct lexer *lexer)
|
||||
static int peek(struct lexer *lexer)
|
||||
{
|
||||
char chr = next(lexer);
|
||||
int chr = next(lexer);
|
||||
|
||||
backup(lexer);
|
||||
|
||||
|
@ -112,7 +112,7 @@ static void *lexer_string(struct lexer *lexer)
|
|||
ignore(lexer);
|
||||
|
||||
while (true) {
|
||||
char chr = next(lexer);
|
||||
int chr = next(lexer);
|
||||
|
||||
if (chr == '\0') {
|
||||
emit(lexer, JSON_TOK_ERROR);
|
||||
|
@ -217,7 +217,7 @@ static void *lexer_null(struct lexer *lexer)
|
|||
static void *lexer_number(struct lexer *lexer)
|
||||
{
|
||||
while (true) {
|
||||
char chr = next(lexer);
|
||||
int chr = next(lexer);
|
||||
|
||||
if (isdigit(chr) || chr == '.') {
|
||||
continue;
|
||||
|
@ -233,7 +233,7 @@ static void *lexer_number(struct lexer *lexer)
|
|||
static void *lexer_json(struct lexer *lexer)
|
||||
{
|
||||
while (true) {
|
||||
char chr = next(lexer);
|
||||
int chr = next(lexer);
|
||||
|
||||
switch (chr) {
|
||||
case '\0':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue