From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAOWq-0003Md-Nv for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAOWk-0005xw-Od for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAOWk-0005xa-K2 for qemu-devel@nongnu.org; Wed, 01 Jul 2015 16:22:38 -0400 From: Markus Armbruster Date: Wed, 1 Jul 2015 22:21:51 +0200 Message-Id: <1435782155-31412-4-git-send-email-armbru@redhat.com> In-Reply-To: <1435782155-31412-1-git-send-email-armbru@redhat.com> References: <1435782155-31412-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC v2 03/47] qapi: Simplify guardname() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com The guards around built-in declarations lose their _H. It never made much sense anyway. Signed-off-by: Markus Armbruster --- scripts/qapi.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 20383ef..2bbc8ff 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -958,14 +958,9 @@ def mcgen(code, **kwds): code = code[1:] return cgen(code, **kwds) -def basename(filename): - return filename.split("/")[-1] def guardname(filename): - guard = basename(filename).rsplit(".", 1)[0] - for substr in [".", " ", "-"]: - guard = guard.replace(substr, "_") - return guard.upper() + '_H' + return c_name(filename, protect=False).upper() def guardstart(name): return mcgen(''' @@ -1035,6 +1030,7 @@ def parse_command_line(extra_options = "", extra_long_options = []): def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, c_comment, h_comment): + guard = guardname(prefix + h_file) c_file = output_dir + prefix + c_file h_file = output_dir + prefix + h_file @@ -1067,7 +1063,7 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, #define %(guard)s ''', - comment = h_comment, guard = guardname(h_file))) + comment = h_comment, guard = guard)) return (fdef, fdecl) -- 1.9.3