qapi: mcgen() shouldn't indent # lines
Skip preprocessor lines when adding indentation, since that would likely result in invalid code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20180703155648.11933-6-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
fbf09a2fa4
commit
485d948ce8
@ -1941,8 +1941,8 @@ def cgen(code, **kwds):
|
|||||||
if indent_level:
|
if indent_level:
|
||||||
indent = genindent(indent_level)
|
indent = genindent(indent_level)
|
||||||
# re.subn() lacks flags support before Python 2.7, use re.compile()
|
# re.subn() lacks flags support before Python 2.7, use re.compile()
|
||||||
raw = re.subn(re.compile(r'^.', re.MULTILINE),
|
raw = re.subn(re.compile(r'^(?!(#|$))', re.MULTILINE),
|
||||||
indent + r'\g<0>', raw)
|
indent, raw)
|
||||||
raw = raw[0]
|
raw = raw[0]
|
||||||
return re.sub(re.escape(eatspace) + r' *', '', raw)
|
return re.sub(re.escape(eatspace) + r' *', '', raw)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user