>From 5c087011efa2817a7e857f69a1cdd22c21a5053d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Aug 2022 13:46:15 +0200 Subject: [PATCH 08/19] gnulib-tool.py: Fix some regex uses. * pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure): Match the regex against all lines of the snippet, not only the first line. * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet): Likewise. --- ChangeLog | 5 +++++ pygnulib/GLEmiter.py | 2 +- pygnulib/GLModuleSystem.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f50e756d60..a44504ae20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2022-08-07 Bruno Haible + gnulib-tool.py: Fix some regex uses. + * pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure): Match + the regex against all lines of the snippet, not only the first line. + * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet): Likewise. + 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 diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 02fa6654e7..9aa638d693 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -174,7 +174,7 @@ class GLEmiter(object): else: # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses # autopoint through at least GNU gettext version 0.18.2. - snippet = re.compile('^ *AM_GNU_GETTEXT_VERSION').sub('AM_GNU_GETTEXT_VERSION', snippet) + snippet = re.compile('^ *AM_GNU_GETTEXT_VERSION', re.M).sub('AM_GNU_GETTEXT_VERSION', snippet) emit += snippet if str(module) == 'alloca' and libtool and not disable_libtool: emit += 'changequote(,)dnl\n' diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index e1b62ec56c..75316515b8 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -1041,7 +1041,7 @@ class GLModuleTable(object): if self.config['conddeps']: automake_snippet = \ module.getAutomakeSnippet_Conditional() - pattern = re.compile('^if') + pattern = re.compile('^if', re.M) if not pattern.findall(automake_snippet): self.addUnconditional(module) conditional = self.isConditional(module) -- 2.34.1