[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 40/56] json: Replace %I64d, %I64u by %PRId64, %P
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 40/56] json: Replace %I64d, %I64u by %PRId64, %PRIu64 |
Date: |
Tue, 14 Aug 2018 09:24:15 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 08/08/2018 07:03 AM, Markus Armbruster wrote:
>> Support for %I64d got addded in commit 2c0d4b36e7f "json: fix PRId64
>
> s/addded/added/
Fixing...
>> on Win32". We had to hard-code I64d because we used the lexer's
>> finite state machine to check interpolations. No more, so clean this
>> up.
>>
>> Additional conversion specifications would be easy enough to implement
>> when needed.
>>
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> qobject/json-parser.c | 10 ++++++----
>> tests/check-qjson.c | 10 ++++++++++
>> 2 files changed, 16 insertions(+), 4 deletions(-)
>>
>
> Reviewed-by: Eric Blake <address@hidden>
>
>> return QOBJECT(qnum_from_int(va_arg(*ap, long)));
>> - } else if (!strcmp(token->str, "%lld") ||
>> - !strcmp(token->str, "%I64d")) {
>> + } else if (!strcmp(token->str, "%lld")) {
>> return QOBJECT(qnum_from_int(va_arg(*ap, long long)));
>> + } else if (!strcmp(token->str, "%" PRId64)) {
>> + return QOBJECT(qnum_from_int(va_arg(*ap, int64_t)));
>
> I had a double-take to make sure this still works on mingw. The trick
> used to be that the lexer had to parse the union of all forms
> understood by any libc (making Linux understand %I64d even though only
> mingw would generate it) then the parser had to accept all forms
> allowed through by the lexer. Now the lexer accepts all forms with no
> effort (because it is no longer validates), and the parser is made
> stricter (%I64d no longer works on Linux, where we have two redundant
> 'if' clauses; but mingw has two distinct 'if' clauses and works as
> desired).
Exactly. Thanks for checking!
- [Qemu-devel] [PATCH 55/56] json: Clean up headers, (continued)
- [Qemu-devel] [PATCH 55/56] json: Clean up headers, Markus Armbruster, 2018/08/08
- [Qemu-devel] [PATCH 47/56] qjson: Have qobject_from_json() & friends reject empty and blank, Markus Armbruster, 2018/08/08
- [Qemu-devel] [PATCH 33/56] json: Redesign the callback to consume JSON values, Markus Armbruster, 2018/08/08
- [Qemu-devel] [PATCH 34/56] json: Don't pass null @tokens to json_parser_parse(), Markus Armbruster, 2018/08/08
- [Qemu-devel] [PATCH 40/56] json: Replace %I64d, %I64u by %PRId64, %PRIu64, Markus Armbruster, 2018/08/08
- [Qemu-devel] [PATCH 29/56] check-qjson: Fix and enable utf8_string()'s disabled part, Markus Armbruster, 2018/08/08
- [Qemu-devel] [PATCH 21/56] json: Reject invalid UTF-8 sequences, Markus Armbruster, 2018/08/08
[Qemu-devel] [PATCH 38/56] json: Pass lexical errors and limit violations to callback, Markus Armbruster, 2018/08/08
[Qemu-devel] [PATCH 37/56] json: Treat unwanted interpolation as lexical error, Markus Armbruster, 2018/08/08