qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 09/51] qapi: mcgen() shouldn't indent # lines


From: Marc-André Lureau
Subject: [Qemu-devel] [PATCH v4 09/51] qapi: mcgen() shouldn't indent # lines
Date: Thu, 11 Jan 2018 22:32:08 +0100

Skip preprocessor lines when adding indentation, since that would
likely result in invalid code.

Signed-off-by: Marc-André Lureau <address@hidden>
---
 scripts/qapi.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index ffb4fb58e0..3d33ed7d76 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1876,8 +1876,8 @@ def cgen(code, **kwds):
     if indent_level:
         indent = genindent(indent_level)
         # re.subn() lacks flags support before Python 2.7, use re.compile()
-        raw = re.subn(re.compile(r'^.', re.MULTILINE),
-                      indent + r'\g<0>', raw)
+        raw = re.subn(re.compile(r'^(?!(#|$))', re.MULTILINE),
+                      indent, raw)
         raw = raw[0]
     return re.sub(re.escape(eatspace) + r' *', '', raw)
 
-- 
2.16.0.rc1.1.gef27df75a1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]