Re: [PATCH v2 05/53] qapi/gen: fix _module_basename for multi-dash 'what' parameters

Markus Armbruster <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
Marc-André Lureau <[email protected]> writes:

> The re.sub() call replaces every hyphen in 'what' with the system module
> infix. This produces broken filenames for multi-hyphen names (e.g.
> 'qapi-type-infos' becomes 'qapi-builtin-type-builtin-infos').
>
> Add count=1 so only the first hyphen is replaced.
>
> Signed-off-by: Marc-André Lureau <[email protected]>
> ---
>  scripts/qapi/gen.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
> index 0c9b8db3b02..690187d4280 100644
> --- a/scripts/qapi/gen.py
> +++ b/scripts/qapi/gen.py
> @@ -300,7 +300,7 @@ def _module_basename(self, what: str, name: str) -> str:
>                  ret += '-' + os.path.splitext(basename)[0]
>          else:
>              assert QAPISchemaModule.is_system_module(name)
> -            ret += re.sub(r'-', '-' + name[2:] + '-', what)
> +            ret += re.sub(r'-', '-' + name[2:] + '-', what, count=1)
>          return ret
>  
>      def _module_filename(self, what: str, name: str) -> str:

Reviewed-by: Markus Armbruster <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.