From f9c146399dabefb8cd13c9c467a9e710af15ea70 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 11 Feb 2018 10:35:59 +0100 Subject: qapi/common: Fix guardname() for funny filenames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit guardname() fails to return a valid C identifier for arguments containing anything but [A-Za-z0-9_.-']. Fix that. Don't bother protecting ticklish identifiers; header guards are all-caps, and no ticklish identifiers are. Signed-off-by: Markus Armbruster Reviewed-by: Marc-André Lureau Reviewed-by: Eric Blake Message-Id: <20180211093607.27351-22-armbru@redhat.com> Reviewed-by: Michael Roth Signed-off-by: Eric Blake --- scripts/qapi/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 547656c8b2..069ec3715d 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1867,7 +1867,7 @@ def mcgen(code, **kwds): def guardname(filename): - return c_name(filename, protect=False).upper() + return re.sub(r'[^A-Za-z0-9_]', '_', filename).upper() def guardstart(name): -- cgit v1.2.1