Received: from eggs.gnu.org ([2001:4830:134:3::10]:39487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faNfp-00024P-4e for qemu-devel@nongnu.org; Tue, 03 Jul 2018 11:57:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faNfo-0003TB-Cb for qemu-devel@nongnu.org; Tue, 03 Jul 2018 11:57:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39832 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 1faNfo-0003Sl-8R for qemu-devel@nongnu.org; Tue, 03 Jul 2018 11:57:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9960EB6F0 for ; Tue, 3 Jul 2018 15:56:59 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 3 Jul 2018 17:56:39 +0200 Message-Id: <20180703155648.11933-6-marcandre.lureau@redhat.com> In-Reply-To: <20180703155648.11933-1-marcandre.lureau@redhat.com> References: <20180703155648.11933-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v7 05/14] qapi: mcgen() shouldn't indent # lines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Skip preprocessor lines when adding indentation, since that would likely result in invalid code. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- scripts/qapi/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index feae646e09..1b56065a80 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1941,8 +1941,8 @@ def cgen(code, **kwds): if indent_level: indent =3D genindent(indent_level) # re.subn() lacks flags support before Python 2.7, use re.compil= e() - raw =3D re.subn(re.compile(r'^.', re.MULTILINE), - indent + r'\g<0>', raw) + raw =3D re.subn(re.compile(r'^(?!(#|$))', re.MULTILINE), + indent, raw) raw =3D raw[0] return re.sub(re.escape(eatspace) + r' *', '', raw) =20 --=20 2.18.0.rc1