sim-card
/
qemu
Archived
10
0
Fork 0

qapi: fix guardname generation

Fix a bug in handling dotted paths, and exclude directory prefixes
from generated guardnames to avoid odd/pseudo-random guardnames in
generated headers.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Michael Roth 2011-11-29 16:47:48 -06:00 committed by Anthony Liguori
parent 85e83264b2
commit d8e1f214a0
1 changed files with 4 additions and 3 deletions

View File

@ -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'