From 1e2b8041b028a7e8b36a217799d08324d6b0fd40 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 2 Apr 2024 04:41:22 -0700 Subject: [PATCH] gnulib-tool.py: Make regular expression more strict. * pygnulib/GLModuleSystem.py (GLModuleSystem.add_dummy): Only match the 'lib_SOURCES' variable. --- ChangeLog | 6 ++++++ pygnulib/GLModuleSystem.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4159305009..8817e8cdcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-04-02 Collin Funk + + gnulib-tool.py: Make regular expression more strict. + * pygnulib/GLModuleSystem.py (GLModuleSystem.add_dummy): Only match the + 'lib_SOURCES' variable. + 2024-04-02 Collin Funk gnulib-tool.py: Accept valid make syntax for escaped newlines. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index fac29883f9..14192754e5 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -1036,9 +1036,9 @@ class GLModuleTable(object): # Extract the value of unconditional "lib_SOURCES += ..." augmentations. snippet = combine_lines(snippet) snippet = self.remove_if_blocks(snippet) - pattern = re.compile(r'^lib_SOURCES[\t ]*\+=([^#]*).*$', re.M) - for matching_rhs in pattern.findall(snippet): - files = matching_rhs.split(' ') + pattern = re.compile(r'^lib_SOURCES[\t ]*\+=[\t ]*([^#]+?)$', re.MULTILINE) + for matching_rhs in re.finditer(pattern, snippet): + files = matching_rhs.group(1).split() for file in files: # Ignore .h files since they are not compiled. if not file.endswith('.h'): -- 2.44.0