]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Fix parsing of gl_LGPL in gnulib-cache.m4.
authorBruno Haible <bruno@clisp.org>
Fri, 12 Apr 2024 15:17:12 +0000 (17:17 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 12 Apr 2024 15:17:12 +0000 (17:17 +0200)
* pygnulib/GLImport.py (GLImport.__init__): Search for gl_LGPL in
gnulib-cache.m4 more carefully.

ChangeLog
pygnulib/GLImport.py

index 013f7b9cc9bb7503d71a4b6448d32089f9d0814a..cdbb53ff8a931917f11b5e070f6ba154d53f4550 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-04-12  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool.py: Fix parsing of gl_LGPL in gnulib-cache.m4.
+       * pygnulib/GLImport.py (GLImport.__init__): Search for gl_LGPL in
+       gnulib-cache.m4 more carefully.
+
        gnulib-tool.py: Fix parsing of gnulib-cache.m4.
        * pygnulib/GLImport.py (GLImport.__init__): While parsing
        gnulib-cache.m4, stop parsing the identifier starting with 'gl_' when
index 38f17bb8b487f78b68f8040a45b9ef0786a68402..aa8acaa2e712bcca0310db0569801e10ca82d104 100644 (file)
@@ -118,20 +118,12 @@ class GLImport:
             with codecs.open(path, 'rb', 'UTF-8') as file:
                 data = file.read()
 
-            # Create regex object and keys.
-            pattern = re.compile(r'^(gl_[A-Z0-9_]*)\((.*?)\)$', re.S | re.M)
-            keys = \
-                [
-                    'gl_LOCAL_DIR', 'gl_MODULES', 'gl_AVOID', 'gl_SOURCE_BASE',
-                    'gl_M4_BASE', 'gl_PO_BASE', 'gl_DOC_BASE', 'gl_TESTS_BASE',
-                    'gl_MAKEFILE_NAME', 'gl_TESTS_MAKEFILE_NAME', 'gl_MACRO_PREFIX',
-                    'gl_PO_DOMAIN', 'gl_WITNESS_C_MACRO', 'gl_VC_FILES', 'gl_LIB',
-                ]
-
-            # Find bool values.
-            if 'gl_LGPL(' in data:
-                keys.append('gl_LGPL')
+            # gl_LGPL is special, because it can occur with or without
+            # an argument list.
+            pattern = re.compile(r'^gl_LGPL$', re.M)
+            if pattern.search(data):
                 self.cache.setLGPL(True)
+            # Find gl_* macros without an argument list.
             if 'gl_LIBTOOL' in data:
                 self.cache.setLibtool(True)
                 data = data.replace('gl_LIBTOOL', '')
@@ -162,7 +154,16 @@ class GLImport:
             if 'gl_AUTOMAKE_SUBDIR' in data:
                 self.cache.setAutomakeSubdir(True)
                 data = data.replace('gl_AUTOMAKE_SUBDIR', '')
-            # Find string values
+            # Find gl_* macros with an argument list.
+            pattern = re.compile(r'^(gl_[A-Z0-9_]*)\((.*?)\)$', re.S | re.M)
+            keys = \
+                [
+                    'gl_LOCAL_DIR', 'gl_MODULES', 'gl_AVOID', 'gl_SOURCE_BASE',
+                    'gl_M4_BASE', 'gl_PO_BASE', 'gl_DOC_BASE', 'gl_TESTS_BASE',
+                    'gl_LIB', 'gl_LGPL', 'gl_MAKEFILE_NAME', 'gl_TESTS_MAKEFILE_NAME',
+                    'gl_MACRO_PREFIX', 'gl_PO_DOMAIN', 'gl_WITNESS_C_MACRO',
+                    'gl_VC_FILES',
+                ]
             result = dict(pattern.findall(data))
             values = cleaner([ result.get(key, '')
                                for key in keys ])