From c0a126e201dd4f8f148835724dd2b2651e6f9d18 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 11 Mar 2024 00:42:57 -0700 Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 54. Follow gnulib-tool change 2021-12-24 Paul Eggert maint: avoid empty lines in recipes * pygnulib/GLEmiter.py (_eliminate_NMD_from_line): Eliminate occurrences of @!NMD@ too. Document parameters in docstring. (_eliminate_NMD): Update docstring to reflect changes. Document parameters. --- ChangeLog | 11 +++++++++++ gnulib-tool.py.TODO | 38 -------------------------------------- pygnulib/GLEmiter.py | 32 ++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1210f53511..83979be9f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2024-03-11 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 54. + Follow gnulib-tool change + 2021-12-24 Paul Eggert + maint: avoid empty lines in recipes + * pygnulib/GLEmiter.py (_eliminate_NMD_from_line): Eliminate occurrences + of @!NMD@ too. Document parameters in docstring. + (_eliminate_NMD): Update docstring to reflect changes. Document + parameters. + 2024-03-11 Bruno Haible gnulib-tool.py: Tweak last commit. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index c3d5d65f5c..69d3cf7d72 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -169,44 +169,6 @@ Date: Sat Dec 25 12:19:13 2021 +0100 -------------------------------------------------------------------------------- -commit b4c57b4240992832fa89a02dc620c4fa5ac36973 -Author: Paul Eggert -Date: Fri Dec 24 17:22:00 2021 -0800 - - maint: avoid empty lines in recipes - - AIX 7.2 ‘make’ complains about recipe lines that are empty after - macro expansion, and I suppose there’s a good chance some - non-POSIX ‘make’ would prohibit them. Rework macros so - that we can avoid them. - * gnulib-tool (func_emit_lib_Makefile_am) - (func_emit_lib_Makefile_am): Support @!NMD@ too. - * modules/gen-header (@gl_V_at): New macro. - * modules/alloca-opt, modules/argz, modules/assert-h: - * modules/byteswap, modules/configmake, modules/ctype: - * modules/dirent, modules/errno, modules/execinfo, modules/fcntl-h: - * modules/float, modules/fnmatch-h, modules/getopt-posix: - * modules/glob-h, modules/iconv-h, modules/ieee754-h: - * modules/inttypes-incomplete, modules/langinfo: - * modules/libtextstyle-optional, modules/limits-h, modules/locale: - * modules/malloc-h, modules/math, modules/monetary, modules/netdb: - * modules/openmp-init, modules/poll-h, modules/posix-shell: - * modules/pthread-h, modules/pty, modules/sched, modules/search: - * modules/signal-h, modules/sigsegv, modules/snippet/link-warning: - * modules/spawn, modules/stdalign, modules/stdarg, modules/stdbool: - * modules/stddef, modules/stdint, modules/stdio, modules/stdlib: - * modules/stdnoreturn, modules/string, modules/strings: - * modules/sysexits, modules/termios, modules/threads-h: - * modules/time, modules/uchar, modules/unicase/base: - * modules/uniconv/base, modules/unictype/base, modules/unigbrk/base: - * modules/unilbrk/base, modules/uniname/base, modules/uninorm/base: - * modules/unistd, modules/unistdio/base, modules/unistr/base: - * modules/unitypes, modules/uniwbrk/base, modules/uniwidth/base: - * modules/utime-h, modules/wchar, modules/wctype-h: - Use it. - --------------------------------------------------------------------------------- - commit 4bdc327dbda59dcdbfa0f983a4f35c4a4ec3578c Author: Bruno Haible Date: Sun Dec 19 12:49:16 2021 +0100 diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 11f1a2c9fc..bfb7d51c01 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -71,18 +71,34 @@ def _convert_to_gnu_make(snippet: str) -> str: def _eliminate_NMD_from_line(line: str, automake_subdir: bool) -> str | None: - '''Eliminate occurrences of @NMD@ from the given line. The modified - line is returned or None if the line should be removed.''' - if line.startswith('@NMD@'): - if automake_subdir: - line = line.replace('@NMD@', '') - else: - line = None + '''Eliminate occurrences of @NMD@ and @!NMD@ from the given line. The + modified line is returned or None if the line should be removed. + + line is the current line in the snippet being operated on. + automake_subdir is a bool that is True if --automake-subdir is in use, + else False.''' + if automake_subdir: + clean = '@NMD@' + eliminate = '@!NMD@' + else: + clean = '@!NMD@' + eliminate = '@NMD@' + # Check if we should eliminate the line from the output. + if line.startswith(eliminate): + return None + # Check if we should clean the mark but keep the line. + if line.startswith(clean): + return line.replace(clean, '') return line def _eliminate_NMD(snippet: str, automake_subdir: bool) -> str: - '''Return the Automake snippet with occurrences of @NMD@ removed.''' + '''Return the Automake snippet with occurrences of @NMD@ and @!NMD@ + removed. + + snippet is the Automake snippet being operated on. + automake_subdir is a bool that is True if --automake-subdir is in use, + else False.''' result = [] for line in snippet.splitlines(): line = _eliminate_NMD_from_line(line, automake_subdir) -- 2.39.5