|
|
9ae3a8 |
From 3cf8ec8ff0ad3920ce23166b2576655bcd886c5a Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 27 Jul 2016 07:35:05 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 07/16] qjson: Inline token_is_keyword() and simplify
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1469604913-12442-9-git-send-email-armbru@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 71483
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 07/15] qjson: Inline token_is_keyword() and simplify
|
|
|
9ae3a8 |
Bugzilla: 1276036
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-Id: <1448486613-17634-7-git-send-email-armbru@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 50e2a467f5315fa36c547fb6330659ba45f6bb83)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qobject/json-parser.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Straighforward conflict because lacking commit fc48ffc "qobject: Use
|
|
|
9ae3a8 |
'bool' for qbool", we still use qbool_from_int(), and we lack commit
|
|
|
9ae3a8 |
e549e71 "json-parser: Accept 'null' in QMP".
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qobject/json-parser.c | 18 ++++++------------
|
|
|
9ae3a8 |
1 file changed, 6 insertions(+), 12 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
|
|
|
9ae3a8 |
index 50bf30c..e3690de 100644
|
|
|
9ae3a8 |
--- a/qobject/json-parser.c
|
|
|
9ae3a8 |
+++ b/qobject/json-parser.c
|
|
|
9ae3a8 |
@@ -64,15 +64,6 @@ static JSONTokenType token_get_type(QObject *obj)
|
|
|
9ae3a8 |
return qdict_get_int(qobject_to_qdict(obj), "type");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int token_is_keyword(QObject *obj, const char *value)
|
|
|
9ae3a8 |
-{
|
|
|
9ae3a8 |
- if (token_get_type(obj) != JSON_KEYWORD) {
|
|
|
9ae3a8 |
- return 0;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- return strcmp(token_get_value(obj), value) == 0;
|
|
|
9ae3a8 |
-}
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
static int token_is_escape(QObject *obj, const char *value)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
if (token_get_type(obj) != JSON_ESCAPE) {
|
|
|
9ae3a8 |
@@ -534,6 +525,7 @@ static QObject *parse_keyword(JSONParserContext *ctxt)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
QObject *token, *ret;
|
|
|
9ae3a8 |
JSONParserContext saved_ctxt = parser_context_save(ctxt);
|
|
|
9ae3a8 |
+ const char *val;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
token = parser_context_pop_token(ctxt);
|
|
|
9ae3a8 |
if (token == NULL) {
|
|
|
9ae3a8 |
@@ -544,12 +536,14 @@ static QObject *parse_keyword(JSONParserContext *ctxt)
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (token_is_keyword(token, "true")) {
|
|
|
9ae3a8 |
+ val = token_get_value(token);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (!strcmp(val, "true")) {
|
|
|
9ae3a8 |
ret = QOBJECT(qbool_from_int(true));
|
|
|
9ae3a8 |
- } else if (token_is_keyword(token, "false")) {
|
|
|
9ae3a8 |
+ } else if (!strcmp(val, "false")) {
|
|
|
9ae3a8 |
ret = QOBJECT(qbool_from_int(false));
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
- parse_error(ctxt, token, "invalid keyword `%s'", token_get_value(token));
|
|
|
9ae3a8 |
+ parse_error(ctxt, token, "invalid keyword '%s'", val);
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|