Hi Bruno,
On 3/19/24 3:00 AM, Bruno Haible wrote:
> ... which tests whether the combination of the two snippets contains some
> character that is not newline, not space, and not tab.
I think I found the reason that these lines are printed. Apparently
str.isspace() will return False for empty strings:
print('\t'.isspace())
True
print('\n'.isspace())
True
print(''.isspace())
False
With these lines added before the check:
+ if (amsnippet1 + amsnippet2) == '':
+ print('EMPTY:')
+ print(str(module))
And running the Emacs script again:
$ env GNULIB_TOOL_IMPL=py ./admin/merge-gnulib | grep -A2 EMPTY:
EMPTY:
manywarnings
EMPTY:
warnings
Which matches the added lines in the diff. I've changed those
conditions to the following:
if (amsnippet1 + amsnippet2).strip() != '':
Collin
From 71d0dca244a2e45ae50d95ea60f8fa8946888f8a Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Wed, 20 Mar 2024 00:57:50 -0700
Subject: [PATCH] gnulib-tool.py: Don't print empty Automake snippets.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am)
(GLEmiter.tests_Makefile_am): Handle empty strings when checking if the
snippet should be printed.
---
ChangeLog | 7 +++++++
pygnulib/GLEmiter.py | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5a48bd1474..fc095fd92c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-20 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Don't print empty Automake snippets.
+ * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am)
+ (GLEmiter.tests_Makefile_am): Handle empty strings when checking if the
+ snippet should be printed.
+
2024-03-19 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Follow gnulib-tool changes, part 68.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 6b61111374..8c2e3b5540 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -846,7 +846,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
amsnippet2 = amsnippet2.replace('$(GNULIB_',
'$(' + module_indicator_prefix + '_GNULIB_')
# Skip the contents if it's entirely empty.
- if not (amsnippet1 + amsnippet2).isspace():
+ if (amsnippet1 + amsnippet2).strip() != '':
allsnippets += '## begin gnulib module %s\n' % str(module)
if gnu_make:
allsnippets += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
@@ -1160,7 +1160,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
amsnippet2 = amsnippet2.replace('$(GNULIB_',
'$(' + module_indicator_prefix + '_GNULIB_')
# Skip the contents if it's entirely empty.
- if not (amsnippet1 + amsnippet2).isspace():
+ if (amsnippet1 + amsnippet2).strip() != '':
snippet = '## begin gnulib module %s\n' % str(module)
if gnu_make:
snippet += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
--
2.44.0