diff options
author | Peter Maydell | 2021-01-01 15:33:03 +0100 |
---|---|---|
committer | Peter Maydell | 2021-01-01 15:33:03 +0100 |
commit | 1f7c02797fa189ce4b34382020bbce63262a5758 (patch) | |
tree | 467ab5404de2084c44df0f9d97b8524fa210c789 /qobject/json-parser.c | |
parent | Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into sta... (diff) | |
parent | qobject: Make QString immutable (diff) | |
download | qemu-1f7c02797fa189ce4b34382020bbce63262a5758.tar.gz qemu-1f7c02797fa189ce4b34382020bbce63262a5758.tar.xz qemu-1f7c02797fa189ce4b34382020bbce63262a5758.zip |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-12-19' into staging
QAPI patches patches for 2020-12-19
# gpg: Signature made Sat 19 Dec 2020 09:40:05 GMT
# gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg: issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-qapi-2020-12-19: (33 commits)
qobject: Make QString immutable
block: Use GString instead of QString to build filenames
keyval: Use GString to accumulate value strings
json: Use GString instead of QString to accumulate strings
migration: Replace migration's JSON writer by the general one
qobject: Factor JSON writer out of qobject_to_json()
qobject: Factor quoted_str() out of to_json()
qobject: Drop qstring_get_try_str()
qobject: Drop qobject_get_try_str()
Revert "qobject: let object_property_get_str() use new API"
block: Avoid qobject_get_try_str()
qmp: Fix tracing of non-string command IDs
qobject: Move internals to qobject-internal.h
hw/rdma: Replace QList by GQueue
Revert "qstring: add qstring_free()"
qobject: Change qobject_to_json()'s value to GString
qobject: Use GString instead of QString to accumulate JSON
qobject: Make qobject_to_json_pretty() take a pretty argument
monitor: Use GString instead of QString for output buffer
hmp: Simplify how qmp_human_monitor_command() gets output
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qobject/json-parser.c')
-rw-r--r-- | qobject/json-parser.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/qobject/json-parser.c b/qobject/json-parser.c index c0f521b56b..d351039b10 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -130,7 +130,7 @@ static int cvt4hex(const char *s) static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) { const char *ptr = token->str; - QString *str; + GString *str; char quote; const char *beg; int cp, trailing; @@ -140,7 +140,7 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) assert(*ptr == '"' || *ptr == '\''); quote = *ptr++; - str = qstring_new(); + str = g_string_new(NULL); while (*ptr != quote) { assert(*ptr); @@ -149,31 +149,31 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) beg = ptr++; switch (*ptr++) { case '"': - qstring_append_chr(str, '"'); + g_string_append_c(str, '"'); break; case '\'': - qstring_append_chr(str, '\''); + g_string_append_c(str, '\''); break; case '\\': - qstring_append_chr(str, '\\'); + g_string_append_c(str, '\\'); break; case '/': - qstring_append_chr(str, '/'); + g_string_append_c(str, '/'); break; case 'b': - qstring_append_chr(str, '\b'); + g_string_append_c(str, '\b'); break; case 'f': - qstring_append_chr(str, '\f'); + g_string_append_c(str, '\f'); break; case 'n': - qstring_append_chr(str, '\n'); + g_string_append_c(str, '\n'); break; case 'r': - qstring_append_chr(str, '\r'); + g_string_append_c(str, '\r'); break; case 't': - qstring_append_chr(str, '\t'); + g_string_append_c(str, '\t'); break; case 'u': cp = cvt4hex(ptr); @@ -200,7 +200,7 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) (int)(ptr - beg), beg); goto out; } - qstring_append(str, utf8_buf); + g_string_append(str, utf8_buf); break; default: parse_error(ctxt, token, "invalid escape sequence in string"); @@ -225,14 +225,14 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) ptr = end; len = mod_utf8_encode(utf8_buf, sizeof(utf8_buf), cp); assert(len >= 0); - qstring_append(str, utf8_buf); + g_string_append(str, utf8_buf); } } - return str; + return qstring_from_gstring(str); out: - qobject_unref(str); + g_string_free(str, true); return NULL; } |