gnulib-tool.py: Prefer 'list.append(item)' over 'list += [item]'.
* pygnulib/*.py: Change occurrences '+= [item]' to use '.append(item)'
where item is a single element added to the list.
See discussion here:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00091.html>
* pygnulib/GLModuleSystem.py (GLModuleTable.getCondition): Add None to
the return type hint. This is the return value when the module is not a
conditional dependency.
gnulib-tool.py: Remove an unused and incorrect function.
* pygnulib/GLFileSystem.py (GLFileAssistant.removeFile): Remove this
unused function. The correct method of removing an element from a list
is to use the remove() function, not pop() which takes an index.
gnulib-tool.py: Omit some unnecessary list() calls around sorted().
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Remove the list()
call in the argument to sorted. The sorted() function works on any
iterable and always returns a list.
* pygnulib/GLImport.py (GLImport.rewrite_old_files)
(GLImport.rewrite_new_files): Likewise.
* pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure)
(GLModuleTable.transitive_closure_separately): Likewise.
* pygnulib/GLTestDir.py (GLTestDir.rewrite_files): Likewise.
Reported by Collin Funk in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00036.html>.
* m4/pthread_h.m4 (gl_PTHREAD_H_PART1): New macro, extracted from
gl_PTHREAD_H.
(gl_PTHREAD_H): Require it. Define using AC_DEFUN.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Require gl_PTHREAD_H_PART1,
not only gl_PTHREAD_H_DEFAULTS.
gnulib-tool.py: Don't allow path normalization to delete a variable.
* pygnulib/GLModuleSystem.py
(GLModule.getAutomakeSnippet_Unconditional): Use os.path.join() on the
Makefile variable so it isn't deleted by a following '..' from
os.path.norm().
gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR.
* pygnulib/GLImport.py (GLImport.__init__): Don't modify the path given
by AC_CONFIG_AUX_DIR by prefixing it with destdir. Use a more strict
regular expression instead of cleaner().
gnulib-tool.py: Locate configure.ac correctly when --dir is given.
* pygnulib/GLConfig.py (GLConfig.setAutoconfFile): Don't combine the
given file name argument with destdir.
* pygnulib/main.py (main): Use os.path.join() instead of joinpath() when
constructing the path to the configure.ac file. The latter normalizes
paths which causes the test suite to fail when printed in files.
Bruno Haible [Sat, 6 Apr 2024 10:01:59 +0000 (12:01 +0200)]
expm1l: Work around a NetBSD 10.0/i386 bug.
* m4/expm1l.m4 (gl_FUNC_EXPM1L): Test the value of
expm1l(2^LDBL_MIN_EXP).
* doc/posix-functions/expm1l.texi: Mention the NetBSD 10.0/i386 bug.
* tests/test-expm1.h (test_function): Allow more deviation on
NetBSD/i386.
Bruno Haible [Fri, 5 Apr 2024 14:04:59 +0000 (16:04 +0200)]
roundl: Fix a link error on Linux/powerpc64le.
* m4/check-math-lib.m4 (gl_CHECK_MATH_LIB): Accept an additional TYPE
argument.
* m4/isfinite.m4 (gl_ISFINITE): Use the type 'double'.
* m4/isinf.m4 (gl_ISINF): Likewise.
* m4/round.m4 (gl_FUNC_ROUND): Likewise.
* m4/roundf.m4 (gl_FUNC_ROUNDF): Use the type 'float'.
* m4/roundl.m4 (gl_FUNC_ROUNDL): Use the type 'long double'.
gnulib-tool.py: Use 'Any' instead of type unions in GLConfig.
* pygnulib/GLConfig.py (GLConfig.__getitem__, GLConfig.dictionary)
(GLConfig.default, GLConfig.isdefault, GLConfig.values): Use 'Any' from
the typing module instead of large type unions. This silences unhelpful
warnings from type checkers.
* pygnulib/GLImport.py (GLImport.prepare): Create a set directly instead
of creating a list and passing it to a call of set().
(GLImport.__init__): Likewise. Use max() instead of getting the last
element of a sorted list.
* pygnulib/GLModuleSystem.py (GLModuleSystem.list): Use run() instead of
Popen() from the subprocess module. This function handles cleanup
internally instead of as a context manager via the 'with' statement.
posix-modules, all-modules: Fix --version output using git options.
* all-modules (func_version): Pass --format and --date options to git
so the output does not depend on the user's configuration. Pass
'-n 1' to speed up the operation, since we only need the first entry.
* posix-modules (func_version): Likewise.
Bruno Haible [Fri, 5 Apr 2024 02:11:22 +0000 (04:11 +0200)]
posix-modules: Sync auxiliary functions from gnulib-tool.sh.
* posix-modules (func_exit, func_fatal_error, func_readlink,
func_gnulib_dir): Move before func_usage and func_version. Incorporate
improvements from gnulib-tool.sh.
* pygnulib/.pylintrc: Don't emit warning messages suggesting that
'dict()' be converted to '{}'. This literal can be mistaken for sets,
see discussion here:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00054.html>
* pygnulib/main.py: Document this convention in coding style section.
* pygnulib/GLFileSystem.py (GLFileAssistant.__init__): Convert an
occurrence of '{}' to 'dict()'.
* pygnulib/*.py: Use explicit exception chaining so that stack trace
messages do not seem like bugs. See examples in:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00056.html>
quotearg: fix shell-escape quoting with single quotes
With shell-escape quoting, we misquoted strings
where the first and last characters required escaping,
while the string also contained single quotes.
* lib/quotearg.c (quotearg_buffer_restyled): Ensure that
pending_shell_escape_end is reset to the initial state
when reprocessing input due to single quotes.
* tests/test-quotearg-simple.c: Add a minimal test case.
* tests/test-quotearg.c: Likewise.
* tests/test-quotearg.h: Likewise.
Reported by Grisha Levit
* lib/renameatu.c(): Fall back to renameat() when
renameatx_np(RENAME_EXCL) returns "Function not implemented".
This issue was seen with macFUSE.
Reported at https://github.com/coreutils/coreutils/issues/79
gnulib-tool.py: Accept valid make syntax for escaped newlines.
* pygnulib/GLModuleSystem.py (GLModuleTable.add_dummy): Use
combine_lines instead of remove remove_backslash_newline so spaces are
added between each combined line.
* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
* pygnulib/constants.py (remove_backslash_newline): Remove unused
function.
gnulib-tool.py: Don't default to 'build-aux' for --auxdir.
* pygnulib/GLConfig.py (GLConfig.__getitem__): Don't map '' to
'build-aux' for the 'auxdir' key.
* pygnulib/GLImport.py (GLImport.__init__): Change conditional to use an
empty string instead of None since this is returned when --auxdir is not
used.
Bruno Haible [Mon, 1 Apr 2024 19:50:51 +0000 (21:50 +0200)]
gnulib-tool.py: Use a standard Python program directory structure.
* pygnulib/main.py (main_with_exception_handling): New function for
existing code.
* .gnulib-tool.py: New file.
* pygnulib/constants.py: Update the computation of APP['root'].
* gnulib-tool.py: Don't set PYTHONPATH.
Bruno Haible [Sun, 31 Mar 2024 12:00:48 +0000 (14:00 +0200)]
gnulib-tool.py: Make a module's name immediately accessible.
* pygnulib/GLModuleSystem.py (GLModuleSystem.find): Pass the module name
to the GLModule constructor.
(GLModule.__init__): Accept the module's name as argument and store it.
(GLModule.getName): Simplify.
Collin Funk [Sat, 30 Mar 2024 10:23:46 +0000 (03:23 -0700)]
gnulib-tool.py: Don't discard the 'dummy' module.
* pygnulib/GLImport.py (GLImport.prepare): Don't set modules stored in
the GLModuleTable until after the 'dummy' module is added.
* pygnulib/GLModuleSystem.py (GLImport.setBaseModules)
(GLImport.setFinalModules, GLImport.setMainModules)
(GLImport.setTestsModules): Don't sort modules since the 'dummy' module
should be placed last in the Makefiles.
Paul Eggert [Fri, 29 Mar 2024 22:56:45 +0000 (15:56 -0700)]
intprops: pacify GCC < 10 -Wsign-compare
Problem reported by Martin Dorey in:
https://savannah.gnu.org/bugs/index.php?65537
* lib/intprops-internal.h (_GL_INT_MULTIPLY_WRAPV):
When working around GCC bug 91450, pacify -Wsign-compare by
casting 0 to the result type.
Bruno Haible [Fri, 29 Mar 2024 21:48:37 +0000 (22:48 +0100)]
gnulib-tool: Use bold output on Linux, NetBSD, OpenBSD, OmniOS consoles.
Reported by Pádraig Brady in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-03/msg00399.html>.
* gnulib-tool.sh (func_show_module_list): Use 'tput' to determine the
"bold" capability of terminal types other than xterm*.
* pygnulib/constants.py (get_terminfo_string, bold_escapes): New
functions.
* pygnulib/GLTestDir.py (GLTestDir.execute): Invoke
constants.bold_escapes.
* pygnulib/GLImport.py (GLImport.prepare): Likewise.
Bruno Haible [Fri, 29 Mar 2024 11:14:21 +0000 (12:14 +0100)]
gnulib-tool.py: Don't print Makefile.am edits that are already done.
* pygnulib/GLMakefileTable.py (GLMakefileTable): Improve comments.
(GLMakefileTable.__getitem__): Do not clone the result.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am, tests_Makefile_am):
Avoid a KeyError when testing for 'var'.
Use 'del' to remove a dictionary entry.
* pygnulib/GLImport.py (GLImport.execute): Avoid a KeyError when
testing for 'var'. Simplify loop over makefiletable.
Collin Funk [Thu, 28 Mar 2024 00:39:58 +0000 (17:39 -0700)]
gnulib-tool.py: Inline 'sed' invocations used on library files.
* pygnulib/GLFileSystem.py (GLFileAssistant.__init__): Update type hints
and docstrings to reflect changes necessary for using re.sub() instead
of 'sed'.
(GLFileAssistant.add_or_update): Use re.sub() instead of invoking 'sed'.
* pygnulib/GLImport.py (GLImport.prepare): Update transformation
variables to reflect changes to GLFileAssistant.
Collin Funk [Tue, 26 Mar 2024 22:43:21 +0000 (15:43 -0700)]
gnulib-tool.py: Allow the use of both configure.ac and configure.in.
* pygnulib/GLImport.py (GLImport.__init__): Remove redundant checks for
configure.ac and configure.in.
* pygnulib/main.py (main): Check for configure.ac and configure.in
before reading it. Pass it to GLImport using the GLConfig object.
Collin Funk [Mon, 25 Mar 2024 08:56:24 +0000 (01:56 -0700)]
gnulib-tool.py: Fix output of #include directive advice.
* pygnulib/GLImport.py (GLImport.execute): Copy comment from
gnulib-tool.sh with modified variable names. Search the 'Include:' as a
whole instead of each individual line.
Bruno Haible [Sun, 24 Mar 2024 18:23:47 +0000 (19:23 +0100)]
nstrtime, c-nstrftime: Fix %c directive's result on glibc ≤ 2.30.
* lib/strftime.c (__strftime_internal): On glibc ≤ 2.30, like on NetBSD
and Solaris, remove the last word of the %c directive's result if it
looks like a time zone.
* doc/posix-functions/strftime.texi: Update platforms list.
Bruno Haible [Sun, 24 Mar 2024 11:06:50 +0000 (12:06 +0100)]
gnulib-tool.py: Fix output of notices.
* pygnulib/GLTestDir.py (GLTestDir.execute): Don't print notices if the
verbosity is < -1. Strip newlines from each notice.
* pygnulib/GLImport.py (GLImport.prepare): Don't print notices if the
verbosity is < -1. Strip only newlines, not spaces.