From patchwork Thu Jun 30 13:42:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 642542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rgLPM4LpRz9s48 for ; Thu, 30 Jun 2016 23:44:23 +1000 (AEST) Received: from localhost ([::1]:49500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcGT-0001JM-G5 for incoming@patchwork.ozlabs.org; Thu, 30 Jun 2016 09:44:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcF6-00009W-26 for qemu-devel@nongnu.org; Thu, 30 Jun 2016 09:42:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIcF3-00037p-Oy for qemu-devel@nongnu.org; Thu, 30 Jun 2016 09:42:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcF3-00037W-JT for qemu-devel@nongnu.org; Thu, 30 Jun 2016 09:42:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 335F7C049D67 for ; Thu, 30 Jun 2016 13:42:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5UDgpxW032238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 30 Jun 2016 09:42:52 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 10B371133013; Thu, 30 Jun 2016 15:42:51 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 30 Jun 2016 15:42:46 +0200 Message-Id: <1467294171-31518-3-git-send-email-armbru@redhat.com> In-Reply-To: <1467294171-31518-1-git-send-email-armbru@redhat.com> References: <1467294171-31518-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 30 Jun 2016 13:42:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 2/7] qobject: Correct JSON lexer grammar comments X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Fix the regex comments describing what we parse as JSON. No change to the lexer itself, just to the comments: - The "" and '' string construction was missing alternation between different escape sequences - The construction for numbers forgot to handle optional leading '-' - The construction for numbers was grouped incorrectly so that it didn't permit '0.1' - The construction for numbers forgot to mark the exponent as optional - No mention that our '' string and "\'" are JSON extensions - No mention of our %d and related extensions when constructing JSON Signed-off-by: Eric Blake Message-Id: <1465526889-8339-2-git-send-email-eblake@redhat.com> Reviewed-by: Markus Armbruster [Eric's regexp simplification squashed in] Signed-off-by: Markus Armbruster --- qobject/json-lexer.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index 496374d..af4a75e 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -18,11 +18,20 @@ #define MAX_TOKEN_SIZE (64ULL << 20) /* - * \"([^\\\"]|(\\\"\\'\\\\\\/\\b\\f\\n\\r\\t\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*\" - * '([^\\']|(\\\"\\'\\\\\\/\\b\\f\\n\\r\\t\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))*' - * 0|([1-9][0-9]*(.[0-9]+)?([eE]([-+])?[0-9]+)) + * Required by JSON (RFC 7159): + * + * \"([^\\\"]|\\[\"'\\/bfnrt]|\\u[0-9a-fA-F]{4})*\" + * -?(0|[1-9][0-9]*)(.[0-9]+)?([eE][-+]?[0-9]+)? * [{}\[\],:] - * [a-z]+ + * [a-z]+ # covers null, true, false + * + * Extension of '' strings: + * + * '([^\\']|\\[\"'\\/bfnrt]|\\u[0-9a-fA-F]{4})*' + * + * Extension for vararg handling in JSON construction: + * + * %((l|ll|I64)?d|[ipsf]) * */ @@ -213,7 +222,7 @@ static const uint8_t json_lexer[][256] = { ['\t'] = IN_WHITESPACE, ['\r'] = IN_WHITESPACE, ['\n'] = IN_WHITESPACE, - }, + }, /* escape */ [IN_ESCAPE_LL] = {