This test failure: $ ./test-cache-2-1.sh Files ./test-cache-2-1.result/lib/Makefile.gnulib and tmp1918649-result/lib/Makefile.gnulib differ Files ./test-cache-2-1.result/m4/gnulib-cache.m4 and tmp1918649-result/m4/gnulib-cache.m4 differ FAIL: gnulib-tool's result has unexpected differences. $ diff -u ./test-cache-2-1.result/m4/gnulib-cache.m4 tmp1918649-result/m4/gnulib-cache.m4 --- ./test-cache-2-1.result/m4/gnulib-cache.m4 2024-04-12 13:26:49.809821302 +0200 +++ tmp1918649-result/m4/gnulib-cache.m4 2024-04-12 16:45:58.224903907 +0200 @@ -43,7 +43,6 @@ # --with-privileged-tests \ # --with-unportable-tests \ # --with-all-tests \ -# --lgpl \ # --makefile-name=Makefile.gnulib \ # --automake-subdir \ # --no-conditional-dependencies \ @@ -74,7 +73,6 @@ gl_TESTS_BASE([tests]) gl_WITH_TESTS gl_LIB([libgnu]) -gl_LGPL gl_MAKEFILE_NAME([Makefile.gnulib]) gl_AUTOMAKE_SUBDIR gl_LIBTOOL
is due to the gnulib-cache.m4 parsing code, which does not recognize an gl_LGPL invocation without arguments. This patch fixes it. 2024-04-12 Bruno Haible <br...@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. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 38f17bb8b4..aa8acaa2e7 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -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 ])