From patchwork Thu May 8 01:14:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 346865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6273614017E for ; Thu, 8 May 2014 11:17:24 +1000 (EST) Received: from localhost ([::1]:44246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiCxe-0005Xc-1H for incoming@patchwork.ozlabs.org; Wed, 07 May 2014 21:17:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiCvo-0003qO-Rm for qemu-devel@nongnu.org; Wed, 07 May 2014 21:15:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiCvh-0008Bp-RO for qemu-devel@nongnu.org; Wed, 07 May 2014 21:15:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiCvh-0008Bb-J5 for qemu-devel@nongnu.org; Wed, 07 May 2014 21:15:21 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s481FJx1025921 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 May 2014 21:15:19 -0400 Received: from amosk.info.com (vpn1-115-97.nay.redhat.com [10.66.115.97]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s481EsWi012547; Wed, 7 May 2014 21:15:15 -0400 From: Amos Kong To: lcapitulino@redhat.com, qemu-devel@nongnu.org Date: Thu, 8 May 2014 09:14:40 +0800 Message-Id: <1399511680-12811-4-git-send-email-akong@redhat.com> In-Reply-To: <1399511680-12811-1-git-send-email-akong@redhat.com> References: <1399511680-12811-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, armbru@redhat.com, mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v4 3/3] qapi: Suppress unwanted space between type and identifier X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+incoming=patchwork.ozlabs.org@nongnu.org We always generate a space between type and identifier in parameter and variable declarations, even when idiomatic C style doesn't have a space there. Suppress it. Signed-off-by: Amos Kong Reviewed-by: Eric Blake --- scripts/qapi.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 1bc2bd9..912787a 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -462,11 +462,14 @@ def find_enum(name): def is_enum(name): return find_enum(name) != None +eatspace = '\033EATSPACE.' + def c_type(name, is_param=False): if name == 'str': if is_param: - return 'const char *' - return 'char *' + return 'const char *' + eatspace + return 'char *' + eatspace + elif name == 'int': return 'int64_t' elif (name == 'int8' or name == 'int16' or name == 'int32' or @@ -480,15 +483,15 @@ def c_type(name, is_param=False): elif name == 'number': return 'double' elif type(name) == list: - return '%s *' % c_list_type(name[0]) + return '%s *%s' % (c_list_type(name[0]), eatspace) elif is_enum(name): return name elif name == None or len(name) == 0: return 'void' elif name == name.upper(): - return '%sEvent *' % camel_case(name) + return '%sEvent *%s' % (camel_case(name), eatspace) else: - return '%s *' % name + return '%s *%s' % (name, eatspace) def genindent(count): ret = "" @@ -513,7 +516,8 @@ def cgen(code, **kwds): return '\n'.join(lines) % kwds + '\n' def mcgen(code, **kwds): - return cgen('\n'.join(code.split('\n')[1:-1]), **kwds) + raw = cgen('\n'.join(code.split('\n')[1:-1]), **kwds) + return re.sub(re.escape(eatspace) + ' *', '', raw) def basename(filename): return filename.split("/")[-1]