bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gnulib-tool.py: Don't emit empty Automake snippets.


From: Collin Funk
Subject: [PATCH] gnulib-tool.py: Don't emit empty Automake snippets.
Date: Mon, 18 Mar 2024 23:05:13 -0700
User-agent: Mozilla Thunderbird

I finally figured out why these lines are printed in Emacs
gnulib.mk.in:

+## begin gnulib module manywarnings
+ifeq (,$(OMIT_GNULIB_MODULE_manywarnings))
+
+endif
+## end   gnulib module manywarnings
+

The same thing happens for the 'warnings' module as well. This patch
fixes these added lines from gnulib-tool.py.

The shell script checks if an Automake snippet is non-empty by doing this:

if grep '[^      ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then

But the Python script checks that the entire snippet is space
characters. I've simply added this function:

def _is_nonempty_snippet(snippet: str) -> bool:
    '''Returns True if an Automake snippet is not empty, else False.'''
    for line in snippet.splitlines():
        if line != '' and not (line.startswith(' ') or line.startswith('\t')):
            return True
    return False

This is pretty similar to what the grep command is doing. The
line != '' is needed since .splitlines() removes the newline in
empty lines.

After this change the Emacs gnulib.mk.in is *almost* correct.
Hopefully these lines won't be too hard to track down. I am guessing
the issue is somewhere around
'GLModule.getAutomakeSnippet_Unconditional()' but that is just a
guess...

diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 6df7f6d9b00..49ca3229728 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -3296,7 +3296,9 @@ ifneq (,$(GL_COND_OBJ_STDIO_WRITE_CONDITION))
 libgnu_a_SOURCES += stdio-write.c
 endif
 
-EXTRA_DIST += stdio.in.h
+EXTRA_DIST += stdio-read.c stdio.in.h
+
+EXTRA_libgnu_a_SOURCES += stdio-read.c
 
 endif
 ## end   gnulib module stdio

Collin

Attachment: 0005-gnulib-tool.py-Don-t-emit-empty-Automake-snippets.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]