[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 07/49] qapi: mcgen() shouldn't indent # lines
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v3 07/49] qapi: mcgen() shouldn't indent # lines |
Date: |
Wed, 20 Jun 2018 17:14:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> Skip preprocessor lines when adding indentation, since that would
> likely result in invalid code.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> scripts/qapi/common.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index bc4ecd6c76..47efe79758 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -1931,8 +1931,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)
Reviewed-by: Markus Armbruster <address@hidden>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH v3 07/49] qapi: mcgen() shouldn't indent # lines,
Markus Armbruster <=