diff mbox

[1/2] qapi: fix guardname generation

Message ID 1322606869-25865-1-git-send-email-mdroth@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Roth Nov. 29, 2011, 10:47 p.m. UTC
Fix a bug in handling dotted paths, and exclude directory prefixes
from generated guardnames to avoid odd/pseudo-random guardnames in
generated headers.
---
 scripts/qapi.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Comments

Stefan Hajnoczi Nov. 30, 2011, 9:08 a.m. UTC | #1
On Tue, Nov 29, 2011 at 10:47 PM, Michael Roth
<mdroth@linux.vnet.ibm.com> wrote:
> Fix a bug in handling dotted paths, and exclude directory prefixes
> from generated guardnames to avoid odd/pseudo-random guardnames in
> generated headers.
> ---
>  scripts/qapi.py |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
diff mbox

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 5299976..6e05469 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -200,6 +200,7 @@  def basename(filename):
     return filename.split("/")[-1]
 
 def guardname(filename):
-    if filename.startswith('./'):
-        filename = filename[2:]
-    return filename.replace("/", "_").replace("-", "_").split(".")[0].upper() + '_H'
+    guard = basename(filename).rsplit(".", 1)[0]
+    for substr in [".", " ", "-"]:
+        guard = guard.replace(substr, "_")
+    return guard.upper() + '_H'