When working on the one of the TODO entries I noticed that
the gnulib-comp.m4 output was incorrect. The indentation was slightly
off and the output also had "if True;" conditionals. Here is a diff
from Emacs merge-gnulib to show the difference:
@@ -784,8 +785,12 @@ AC_DEFUN
if $gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9; then :; else
AC_PROG_MKDIR_P
gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9=true
- func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866
- func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4
+ if True; then
+ func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866
+ fi
+ if True; then
+ func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4
+ fi
fi
}
This seems to be caused by GLModuleTable.addConditional [1] allowing
string values or boolean True values. When outputting the
conditionals in GLEmiter.autoconfSnippets, the condition is printed as
long as the return value is not None [2]. Therefore, when True is
returned it is printed. The shell script does not print the
conditional in these cases.
I've opted to use "type(condition) is str" and not "condition != True"
to avoid any problems comparing a string to a bool. I doubt it would
cause problems, but the type check in addConditional would ensure it
isn't anything else weird.
[1]
https://git.savannah.gnu.org/cgit/gnulib.git/tree/pygnulib/GLModuleSystem.py#n769
[2] https://git.savannah.gnu.org/cgit/gnulib.git/tree/pygnulib/GLEmiter.py#n181
Collin
From ae593ef0dc43ed0260523b611eb0675dabaefe00 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 2 Mar 2024 18:43:26 -0800
Subject: [PATCH] gnulib-tool.py: Fix output of gnulib-comp.m4.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Fix indentation.
Don't print nonstring values into gnulib-comp.m4.
---
ChangeLog | 6 ++++++
pygnulib/GLEmiter.py | 12 ++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3ba80e7c39..19b308e552 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-02 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Fix output of gnulib-comp.m4.
+ * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Fix indentation.
+ Don't print nonstring values into gnulib-comp.m4.
+
2024-03-02 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Make output of test Makefile.am match gnulib-tool.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 7115dfe115..7f850b8dec 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -297,12 +297,12 @@ class GLEmiter(object):
if moduletable.isConditional(depmodule):
shellfunc = depmodule.getShellFunc()
condition = moduletable.getCondition(module, depmodule)
- if condition != None:
- emit += ' if %s; then\n' % condition
- emit += ' %s\n' % shellfunc
- emit += ' fi\n'
+ if condition != None and type(condition) is str:
+ emit += ' if %s; then\n' % condition
+ emit += ' %s\n' % shellfunc
+ emit += ' fi\n'
else: # if condition == None
- emit += ' %s\n' % shellfunc
+ emit += ' %s\n' % shellfunc
# if not moduletable.isConditional(depmodule)
else:
# The autoconf code for $dep has already been emitted above and
@@ -329,7 +329,7 @@ class GLEmiter(object):
if moduletable.isConditional(depmodule):
shellfunc = depmodule.getShellFunc()
condition = moduletable.getCondition(module, depmodule)
- if condition != None:
+ if condition != None and type(condition) is str:
emit += ' if %s; then\n' % condition
emit += ' %s\n' % shellfunc
emit += ' fi\n'
--
2.44.0