From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpTgk-0008GG-TT for qemu-devel@nongnu.org; Tue, 14 Aug 2018 03:24:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpTgg-0005UO-Sa for qemu-devel@nongnu.org; Tue, 14 Aug 2018 03:24:22 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57148 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fpTgg-0005UA-Nz for qemu-devel@nongnu.org; Tue, 14 Aug 2018 03:24:18 -0400 From: Markus Armbruster References: <20180808120334.10970-1-armbru@redhat.com> <20180808120334.10970-41-armbru@redhat.com> <87a5ca96-5f44-5e18-a8a0-91c76f66f054@redhat.com> Date: Tue, 14 Aug 2018 09:24:15 +0200 In-Reply-To: <87a5ca96-5f44-5e18-a8a0-91c76f66f054@redhat.com> (Eric Blake's message of "Mon, 13 Aug 2018 11:18:48 -0500") Message-ID: <87d0ul2yxs.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 40/56] json: Replace %I64d, %I64u by %PRId64, %PRIu64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Eric Blake 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 >> --- >> qobject/json-parser.c | 10 ++++++---- >> tests/check-qjson.c | 10 ++++++++++ >> 2 files changed, 16 insertions(+), 4 deletions(-) >> > > Reviewed-by: Eric Blake > >> 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!