* [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed)
@ 2010-02-04 2:30 Roy Tam
2010-02-04 2:34 ` Roy Tam
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Roy Tam @ 2010-02-04 2:30 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
2010/2/4 Roy Tam <roytam@gmail.com>:
> 2010/2/3 Luiz Capitulino <lcapitulino@redhat.com>:
OK we are fooled by the json lexer and parser. As we use %I64d to
print 'long long' variables in Win32, but lexer and parser only deal
with %lld but not %I64d, this patch add support for %I64d and solve
'info pci', 'powser_reset' and 'power_powerdown' assert failure in
Win32.
P.S.: an assert(state.result != NULL) statement in
qobject_from_jsonv() will be good for asserting failure of parsing
JSON strings.
diff --git a/json-lexer.c b/json-lexer.c
index 53697c5..9d64920 100644
--- a/json-lexer.c
+++ b/json-lexer.c
@@ -54,6 +54,9 @@ enum json_lexer_state {
IN_ESCAPE,
IN_ESCAPE_L,
IN_ESCAPE_LL,
+ IN_ESCAPE_I,
+ IN_ESCAPE_I6,
+ IN_ESCAPE_I64,
IN_ESCAPE_DONE,
IN_WHITESPACE,
IN_OPERATOR_DONE,
@@ -223,6 +226,18 @@ static const uint8_t json_lexer[][256] = {
['l'] = IN_ESCAPE_LL,
},
+ [IN_ESCAPE_I64] = {
+ ['d'] = IN_ESCAPE_DONE,
+ },
+
+ [IN_ESCAPE_I6] = {
+ ['4'] = IN_ESCAPE_I64,
+ },
+
+ [IN_ESCAPE_I] = {
+ ['6'] = IN_ESCAPE_I6,
+ },
+
[IN_ESCAPE] = {
['d'] = IN_ESCAPE_DONE,
['i'] = IN_ESCAPE_DONE,
@@ -230,6 +245,7 @@ static const uint8_t json_lexer[][256] = {
['s'] = IN_ESCAPE_DONE,
['f'] = IN_ESCAPE_DONE,
['l'] = IN_ESCAPE_L,
+ ['I'] = IN_ESCAPE_I,
},
/* top level rule */
diff --git a/json-parser.c b/json-parser.c
index e04932f..40a5d15 100644
--- a/json-parser.c
+++ b/json-parser.c
@@ -474,7 +474,7 @@ static QObject *parse_escape(JSONParserContext
*ctxt, QList **tokens, va_list *a
obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%ld")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
- } else if (token_is_escape(token, "%lld")) {
+ } else if (token_is_escape(token, "%lld") ||
token_is_escape(token, "%I64d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
} else if (token_is_escape(token, "%s")) {
obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed)
2010-02-04 2:30 [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed) Roy Tam
@ 2010-02-04 2:34 ` Roy Tam
2010-02-04 14:24 ` Luiz Capitulino
2010-02-10 19:28 ` Anthony Liguori
2 siblings, 0 replies; 6+ messages in thread
From: Roy Tam @ 2010-02-04 2:34 UTC (permalink / raw)
To: Luiz Capitulino, Anthony Liguori; +Cc: qemu-devel
2010/2/4 Roy Tam <roytam@gmail.com>:
> 2010/2/4 Roy Tam <roytam@gmail.com>:
>> 2010/2/3 Luiz Capitulino <lcapitulino@redhat.com>:
>
> OK we are fooled by the json lexer and parser. As we use %I64d to
> print 'long long' variables in Win32, but lexer and parser only deal
> with %lld but not %I64d, this patch add support for %I64d and solve
> 'info pci', 'powser_reset' and 'power_powerdown' assert failure in
> Win32.
>
> P.S.: an assert(state.result != NULL) statement in
> qobject_from_jsonv() will be good for asserting failure of parsing
> JSON strings.
Signed-off-by: Roy Tam <roytam@gmail.com>
diff --git a/json-lexer.c b/json-lexer.c
index 53697c5..9d64920 100644
--- a/json-lexer.c
+++ b/json-lexer.c
@@ -54,6 +54,9 @@ enum json_lexer_state {
IN_ESCAPE,
IN_ESCAPE_L,
IN_ESCAPE_LL,
+ IN_ESCAPE_I,
+ IN_ESCAPE_I6,
+ IN_ESCAPE_I64,
IN_ESCAPE_DONE,
IN_WHITESPACE,
IN_OPERATOR_DONE,
@@ -223,6 +226,18 @@ static const uint8_t json_lexer[][256] = {
['l'] = IN_ESCAPE_LL,
},
+ [IN_ESCAPE_I64] = {
+ ['d'] = IN_ESCAPE_DONE,
+ },
+
+ [IN_ESCAPE_I6] = {
+ ['4'] = IN_ESCAPE_I64,
+ },
+
+ [IN_ESCAPE_I] = {
+ ['6'] = IN_ESCAPE_I6,
+ },
+
[IN_ESCAPE] = {
['d'] = IN_ESCAPE_DONE,
['i'] = IN_ESCAPE_DONE,
@@ -230,6 +245,7 @@ static const uint8_t json_lexer[][256] = {
['s'] = IN_ESCAPE_DONE,
['f'] = IN_ESCAPE_DONE,
['l'] = IN_ESCAPE_L,
+ ['I'] = IN_ESCAPE_I,
},
/* top level rule */
diff --git a/json-parser.c b/json-parser.c
index e04932f..40a5d15 100644
--- a/json-parser.c
+++ b/json-parser.c
@@ -474,7 +474,7 @@ static QObject *parse_escape(JSONParserContext
*ctxt, QList **tokens, va_list *a
obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%ld")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
- } else if (token_is_escape(token, "%lld")) {
+ } else if (token_is_escape(token, "%lld") ||
token_is_escape(token, "%I64d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
} else if (token_is_escape(token, "%s")) {
obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed)
2010-02-04 2:30 [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed) Roy Tam
2010-02-04 2:34 ` Roy Tam
@ 2010-02-04 14:24 ` Luiz Capitulino
2010-02-04 16:59 ` Roy Tam
2010-02-10 19:28 ` Anthony Liguori
2 siblings, 1 reply; 6+ messages in thread
From: Luiz Capitulino @ 2010-02-04 14:24 UTC (permalink / raw)
To: Roy Tam; +Cc: aliguori, qemu-devel
On Thu, 4 Feb 2010 10:30:30 +0800
Roy Tam <roytam@gmail.com> wrote:
> 2010/2/4 Roy Tam <roytam@gmail.com>:
> > 2010/2/3 Luiz Capitulino <lcapitulino@redhat.com>:
>
> OK we are fooled by the json lexer and parser. As we use %I64d to
> print 'long long' variables in Win32, but lexer and parser only deal
> with %lld but not %I64d, this patch add support for %I64d and solve
> 'info pci', 'powser_reset' and 'power_powerdown' assert failure in
> Win32.
Hm, I guess this has been suggested before... Anthony?
> P.S.: an assert(state.result != NULL) statement in
> qobject_from_jsonv() will be good for asserting failure of parsing
> JSON strings.
Yes, this change is already in a series I plan to send shortly.
Thanks a lot for tracking this down.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed)
2010-02-04 14:24 ` Luiz Capitulino
@ 2010-02-04 16:59 ` Roy Tam
2010-02-08 16:21 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Roy Tam @ 2010-02-04 16:59 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: aliguori, qemu-devel
2010/2/4 Luiz Capitulino <lcapitulino@redhat.com>:
> On Thu, 4 Feb 2010 10:30:30 +0800
> Roy Tam <roytam@gmail.com> wrote:
>
>> 2010/2/4 Roy Tam <roytam@gmail.com>:
>> > 2010/2/3 Luiz Capitulino <lcapitulino@redhat.com>:
>>
>> OK we are fooled by the json lexer and parser. As we use %I64d to
>> print 'long long' variables in Win32, but lexer and parser only deal
>> with %lld but not %I64d, this patch add support for %I64d and solve
>> 'info pci', 'powser_reset' and 'power_powerdown' assert failure in
>> Win32.
>
> Hm, I guess this has been suggested before... Anthony?
>
OK I just missed this. And the wheel was reinvented. :-S
http://www.mail-archive.com/qemu-devel@nongnu.org/msg23983.html
>> P.S.: an assert(state.result != NULL) statement in
>> qobject_from_jsonv() will be good for asserting failure of parsing
>> JSON strings.
>
> Yes, this change is already in a series I plan to send shortly.
>
> Thanks a lot for tracking this down.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed)
2010-02-04 16:59 ` Roy Tam
@ 2010-02-08 16:21 ` Anthony Liguori
0 siblings, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2010-02-08 16:21 UTC (permalink / raw)
To: Roy Tam; +Cc: qemu-devel, Luiz Capitulino
On 02/04/2010 10:59 AM, Roy Tam wrote:
> 2010/2/4 Luiz Capitulino<lcapitulino@redhat.com>:
>
>> On Thu, 4 Feb 2010 10:30:30 +0800
>> Roy Tam<roytam@gmail.com> wrote:
>>
>>
>>> 2010/2/4 Roy Tam<roytam@gmail.com>:
>>>
>>>> 2010/2/3 Luiz Capitulino<lcapitulino@redhat.com>:
>>>>
>>> OK we are fooled by the json lexer and parser. As we use %I64d to
>>> print 'long long' variables in Win32, but lexer and parser only deal
>>> with %lld but not %I64d, this patch add support for %I64d and solve
>>> 'info pci', 'powser_reset' and 'power_powerdown' assert failure in
>>> Win32.
>>>
>> Hm, I guess this has been suggested before... Anthony?
>>
>>
> OK I just missed this. And the wheel was reinvented. :-S
> http://www.mail-archive.com/qemu-devel@nongnu.org/msg23983.html
>
I asked for the json parser changes to be split from the PRId64
changes. It was never resubmitted. I'll apply your patch.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed)
2010-02-04 2:30 [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed) Roy Tam
2010-02-04 2:34 ` Roy Tam
2010-02-04 14:24 ` Luiz Capitulino
@ 2010-02-10 19:28 ` Anthony Liguori
2 siblings, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2010-02-10 19:28 UTC (permalink / raw)
To: Roy Tam; +Cc: qemu-devel, Luiz Capitulino
On 02/03/2010 08:30 PM, Roy Tam wrote:
> 2010/2/4 Roy Tam<roytam@gmail.com>:
>
>> 2010/2/3 Luiz Capitulino<lcapitulino@redhat.com>:
>>
> OK we are fooled by the json lexer and parser. As we use %I64d to
> print 'long long' variables in Win32, but lexer and parser only deal
> with %lld but not %I64d, this patch add support for %I64d and solve
> 'info pci', 'powser_reset' and 'power_powerdown' assert failure in
> Win32.
>
> P.S.: an assert(state.result != NULL) statement in
> qobject_from_jsonv() will be good for asserting failure of parsing
> JSON strings.
>
Applied. Thanks.
Regards,
Anthony Liguori
> diff --git a/json-lexer.c b/json-lexer.c
> index 53697c5..9d64920 100644
> --- a/json-lexer.c
> +++ b/json-lexer.c
> @@ -54,6 +54,9 @@ enum json_lexer_state {
> IN_ESCAPE,
> IN_ESCAPE_L,
> IN_ESCAPE_LL,
> + IN_ESCAPE_I,
> + IN_ESCAPE_I6,
> + IN_ESCAPE_I64,
> IN_ESCAPE_DONE,
> IN_WHITESPACE,
> IN_OPERATOR_DONE,
> @@ -223,6 +226,18 @@ static const uint8_t json_lexer[][256] = {
> ['l'] = IN_ESCAPE_LL,
> },
>
> + [IN_ESCAPE_I64] = {
> + ['d'] = IN_ESCAPE_DONE,
> + },
> +
> + [IN_ESCAPE_I6] = {
> + ['4'] = IN_ESCAPE_I64,
> + },
> +
> + [IN_ESCAPE_I] = {
> + ['6'] = IN_ESCAPE_I6,
> + },
> +
> [IN_ESCAPE] = {
> ['d'] = IN_ESCAPE_DONE,
> ['i'] = IN_ESCAPE_DONE,
> @@ -230,6 +245,7 @@ static const uint8_t json_lexer[][256] = {
> ['s'] = IN_ESCAPE_DONE,
> ['f'] = IN_ESCAPE_DONE,
> ['l'] = IN_ESCAPE_L,
> + ['I'] = IN_ESCAPE_I,
> },
>
> /* top level rule */
> diff --git a/json-parser.c b/json-parser.c
> index e04932f..40a5d15 100644
> --- a/json-parser.c
> +++ b/json-parser.c
> @@ -474,7 +474,7 @@ static QObject *parse_escape(JSONParserContext
> *ctxt, QList **tokens, va_list *a
> obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
> } else if (token_is_escape(token, "%ld")) {
> obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
> - } else if (token_is_escape(token, "%lld")) {
> + } else if (token_is_escape(token, "%lld") ||
> token_is_escape(token, "%I64d")) {
> obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
> } else if (token_is_escape(token, "%s")) {
> obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-02-10 19:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-04 2:30 [PATCH] JSON: add %I64d support (Was: Re: [Qemu-devel] system_reset command cause assert failed) Roy Tam
2010-02-04 2:34 ` Roy Tam
2010-02-04 14:24 ` Luiz Capitulino
2010-02-04 16:59 ` Roy Tam
2010-02-08 16:21 ` Anthony Liguori
2010-02-10 19:28 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).