bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: gnulib-tool.py: Fix parsing of gl_LGPL in gnulib-cache.m4
Date: Fri, 12 Apr 2024 17:19:49 +0200	[thread overview]
Message-ID: <13773395.bQGkOPY9GO@nimes> (raw)

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  <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.

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 ])





                 reply	other threads:[~2024-04-12 15:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13773395.bQGkOPY9GO@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).