diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-08-31 09:58:40 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-09-24 18:08:07 +0200 |
commit | 2ce4ee64c4fe0463c53a99955a3acdaa8a451136 (patch) | |
tree | 388a1c565c000192b6ab4b07ff521a69acc4103e /qobject/json-lexer.c | |
parent | 0f07a5d5f1f484c9c334d52193617e89442da7c9 (diff) | |
download | qemu-2ce4ee64c4fe0463c53a99955a3acdaa8a451136.zip qemu-2ce4ee64c4fe0463c53a99955a3acdaa8a451136.tar.gz qemu-2ce4ee64c4fe0463c53a99955a3acdaa8a451136.tar.bz2 |
json: Eliminate lexer state IN_ERROR
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180831075841.13363-6-armbru@redhat.com>
Diffstat (limited to 'qobject/json-lexer.c')
-rw-r--r-- | qobject/json-lexer.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index 39c7ce7..2a5561c 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -100,8 +100,7 @@ */ enum json_lexer_state { - IN_ERROR = 0, /* must really be 0, see json_lexer[] */ - IN_RECOVERY, + IN_RECOVERY = 1, IN_DQ_STRING_ESCAPE, IN_DQ_STRING, IN_SQ_STRING_ESCAPE, @@ -121,6 +120,8 @@ enum json_lexer_state { IN_START_INTERP, /* must be IN_START + 1 */ }; +QEMU_BUILD_BUG_ON(JSON_ERROR != 0); +QEMU_BUILD_BUG_ON(IN_RECOVERY != JSON_ERROR + 1); QEMU_BUILD_BUG_ON((int)JSON_MIN <= (int)IN_START_INTERP); QEMU_BUILD_BUG_ON(JSON_MAX >= 0x80); QEMU_BUILD_BUG_ON(IN_START_INTERP != IN_START + 1); @@ -176,7 +177,7 @@ static const uint8_t json_lexer[][256] = { /* Zero */ [IN_ZERO] = { TERMINAL(JSON_INTEGER), - ['0' ... '9'] = IN_ERROR, + ['0' ... '9'] = JSON_ERROR, ['.'] = IN_MANTISSA, }, @@ -328,7 +329,7 @@ static void json_lexer_feed_char(JSONLexer *lexer, char ch, bool flush) case IN_START: new_state = lexer->start_state; break; - case IN_ERROR: + case JSON_ERROR: json_message_process_token(lexer, lexer->token, JSON_ERROR, lexer->x, lexer->y); new_state = IN_RECOVERY; |