>From 9d722ddced2e46a06255be8eb24a54015f611af7 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Aug 2022 13:40:07 +0200 Subject: [PATCH 07/19] gnulib-tool.py: Make regex uses more straightforward. * pygnulib/constants.py: Don't use the "minimal matching" *? construct when it makes no difference (because we're matching a single line only and flag re.M is not specified). * pygnulib/GLModuleSystem.py: Likewise. --- ChangeLog | 6 ++++++ pygnulib/GLModuleSystem.py | 2 +- pygnulib/constants.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e162e8d0a..f50e756d60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2022-08-07 Bruno Haible + gnulib-tool.py: Make regex uses more straightforward. + * pygnulib/constants.py: Don't use the "minimal matching" *? construct + when it makes no difference (because we're matching a single line only + and flag re.M is not specified). + * pygnulib/GLModuleSystem.py: Likewise. + gnulib-tool.py: Make regex uses more straightforward. * pygnulib/GLModuleSystem.py: Don't use flag re.S on regular expressions that are meant to match a single line only, and remove the use of the diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index afc7a472cf..e1b62ec56c 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -280,7 +280,7 @@ Include:|Link:|License:|Maintainer:)' '''GLModule.getName() -> str Return the name of the module.''' - pattern = re.compile(joinpath('modules', '(.*?)$')) + pattern = re.compile(joinpath('modules', '(.*)$')) result = pattern.findall(self.module)[0] return result diff --git a/pygnulib/constants.py b/pygnulib/constants.py index 46c0cbc152..ba0ebc9942 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -412,7 +412,7 @@ def filter_filelist(separator, filelist, listing = list() for filename in filelist: if filename.startswith(prefix) and filename.endswith(suffix): - pattern = re.compile('^%s(.*?)%s$' + pattern = re.compile('^%s(.*)%s$' % (removed_prefix, removed_suffix)) result = pattern.sub('%s\\1%s' % (added_prefix, added_suffix), filename) -- 2.34.1