On 2/29/24 6:58 PM, Collin Funk wrote:
> The second fixes a problem I noticed when using the Emacs merge-gnulib
> script. I noticed that most of the Automake conditionals for header
> files weren't being converted to GNU Make syntax. The diff would have
> many lines like this:

I forgot to add the function name in the ChangeLog and commit message
for this patch... I've attached a fixed one.

Collin
From e83860933f4b82cfcadf5abb6f4d445e879e258b Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 29 Feb 2024 18:37:53 -0800
Subject: [PATCH 3/3] gnulib-tool.py: Fix GNU Make conversion regular
 expressions.

* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Reduce code
duplication. Use re.MULTILINE so '^' matches the start of each line
instead of only the start of a string.
---
 ChangeLog            |  7 +++++++
 pygnulib/GLEmiter.py | 12 +++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 87d8b84c06..b4c8e45081 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-02-29  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Fix GNU Make conversion regular expressions.
+	* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Reduce code
+	duplication. Use re.MULTILINE so '^' matches the start of each line
+	instead of only the start of a string.
+
 2024-02-29  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 37.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 64800792ae..2a28021938 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -640,6 +640,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
         ac_version = self.config['ac_version']
         destfile = os.path.normpath(destfile)
+        convert_to_gnu_make_1 = (re.compile(r'^if (.*)', re.MULTILINE), r'ifneq (,$(\1))')
         emit = ''
 
         # When using GNU make, or when creating an includable Makefile.am snippet,
@@ -712,9 +713,6 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                     allsnippets += '## begin gnulib module %s\n' % str(module)
                     if gnu_make:
                         allsnippets += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
-                        convert_to_gnu_make = True
-                    else:
-                        convert_to_gnu_make = False
                     allsnippets += '\n'
                     if conddeps:
                         if moduletable.isConditional(module):
@@ -723,15 +721,15 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                                 allsnippets += 'ifneq (,$(%s))\n' % name
                             else:
                                 allsnippets += 'if %s\n' % name
-                    if convert_to_gnu_make:
-                        allsnippets += re.sub(r'^if (.*)', r'ifneq (,$(\1))', amsnippet1)
+                    if gnu_make:
+                        allsnippets += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet1)
                     else:
                         allsnippets += amsnippet1
                     if conddeps:
                         if moduletable.isConditional(module):
                             allsnippets += 'endif\n'
-                    if convert_to_gnu_make:
-                        allsnippets += re.sub(r'^if (.*)', r'ifneq (,$(\1))', amsnippet2)
+                    if gnu_make:
+                        allsnippets += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet2)
                     else:
                         allsnippets += amsnippet2
                     if gnu_make:
-- 
2.39.2

Reply via email to