Paul Eggert [Sat, 12 Dec 2020 01:33:36 +0000 (17:33 -0800)]
stdint: port to Autoconf 2.70
* m4/stdint.m4 (gl_STDINT_H): Check for inttypes.h and sys/types.h
instead of assuming that AC_INCLUDES_DEFAULT does it.
The old code relied on AC_INCLUDES_DEFAULT being called
and setting ac_cv_header_inttypes_h and ac_cv_header_sys_types_h,
but this does not occur in Autoconf 2.70.
Paul Eggert [Fri, 11 Dec 2020 23:50:34 +0000 (15:50 -0800)]
AC_C_RESTRICT: update from Autoconf
* m4/gnulib-common.m4 (gl_PROG_CC_C99): Use Autoconf 2.70
as a prerequisite, not 2.69c, since 2.70 is now out.
(AC_C_RESTRICT): Define only for 2.70 or earlier.
Try __restrict__ before __restrict.
Paul Eggert [Fri, 11 Dec 2020 23:47:24 +0000 (15:47 -0800)]
extensions: update from Autoconf
* m4/extensions.m4 (AC_CHECK_INCLUDES_DEFAULT):
Provide a default implementation for Autoconf 2.69 or earlier.
(AC_USE_SYSTEM_EXTENSIONS): Copy from Autoconf git. Define only
if Autoconf 2.70 or earlier, since 2.70.1 or later should be OK.
Bruno Haible [Fri, 11 Dec 2020 10:47:30 +0000 (11:47 +0100)]
execute-tests: Fix compilation error on AIX in 32-bit mode.
* tests/test-execute-child.c: In order to get the original definition of
fstat, don't use '#undef fstat' and '#undef stat'. Instead, arrange to
include the system's <sys/stat.h> and use it before including other
header files.
Bruno Haible [Thu, 10 Dec 2020 22:43:20 +0000 (23:43 +0100)]
execute, spawn-pipe: Fix memory leak on native Windows.
* lib/windows-spawn.h (prepare_spawn): Add a second parameter.
* lib/windows-spawn.c: Don't include xalloc.h.
(quoted_arg_length, quoted_arg_string): New functions, extracted from
prepare_spawn.
(prepare_spawn): Use malloc instead of XNMALLOC. Allocate memory for all
elements of *new_argv together.
* modules/windows-spawn (Depends-on): Remove xalloc. Add malloc-posix.
* lib/os2-spawn.h (prepare_spawn): Add a second parameter.
* lib/os2-spawn.c: Don't include xalloc.h.
(prepare_spawn): Use malloc instead of XNMALLOC. Allocate memory for all
elements of *new_argv together.
* lib/execute.c: Include xalloc.h.
(execute): Check return value of prepare_spawn. Free the memory
allocated by prepare_spawn.
* modules/execute (Depends-on): Add xalloc-die.
* lib/spawn-pipe.c: Include xalloc.h.
(create_pipe): Check return value of prepare_spawn. Free the memory
allocated by prepare_spawn.
* modules/spawn-pipe (Depends-on): Add xalloc-die.
Bruno Haible [Wed, 9 Dec 2020 17:51:40 +0000 (18:51 +0100)]
threadlib: Fix test-fstrcmp failure on FreeBSD 11.
* m4/threadlib.m4 (gl_THREADLIB_BODY): When weak symbols are not present
on FreeBSD, define PTHREAD_IN_USE_DETECTION_HARD.
* lib/glthread/threadlib.c: Include <errno.h>.
(glthread_in_use): For FreeBSD, provide an alternative implementation
that uses pthread_key_create.
Bruno Haible [Tue, 8 Dec 2020 20:28:18 +0000 (21:28 +0100)]
argp: Avoid undefined behaviour when invoking qsort().
This fixes a test-argp-2.sh test failure on macOS and FreeBSD.
Reported by Jeffrey Walton <noloader@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00085.html>.
* lib/argp-help.c (group_cmp): Remove third argument.
(hol_sibling_cluster_cmp, hol_cousin_cluster_cmp): New functions, based
upon hol_cluster_cmp.
(hol_cluster_cmp): Use hol_cousin_cluster_cmp.
(hol_entry_cmp): Rewritten to implement a total order.
Bruno Haible [Mon, 7 Dec 2020 18:43:06 +0000 (19:43 +0100)]
get-rusage-data: Fix link error on FreeBSD 12.2/arm64.
* modules/get-rusage-data (configure.ac): Test whether sbrk exists.
* lib/get-rusage-data.c (get_rusage_data_via_setrlimit): Define
trivially of sbrk is not available.
* doc/glibc-functions/sbrk.texi: Mention that the function does not
exist in FreeBSD 12.2/arm64.
* doc/glibc-functions/brk.texi: Likewise.
Paul Eggert [Sun, 6 Dec 2020 18:17:39 +0000 (10:17 -0800)]
doc: fix flat address space discussion
* doc/gnulib-readme.texi (Other portability assumptions):
Move the all-bits-zero assumption outside the flat address space
section, since the two issues are independent.
Bruno Haible [Sun, 6 Dec 2020 14:51:41 +0000 (15:51 +0100)]
doc: Mention some missing function declarations.
* doc/glibc-functions/execvpe.texi: Mention the missing declaration on
AIX.
* doc/glibc-functions/fcloseall.texi: Mention the missing declaration on
FreeBSD.
* doc/pastposix-functions/ecvt.texi: Mention the missing declaration on
Cygwin.
* doc/pastposix-functions/fcvt.texi: Likewise.
* doc/pastposix-functions/gcvt.texi: Likewise.
Bruno Haible [Sun, 6 Dec 2020 11:31:11 +0000 (12:31 +0100)]
parse-datetime: Use idx_t for nonnegative ptrdiff_t variables.
* lib/parse-datetime.y: Include idx.h.
(textint): Mark digits as nonnegative.
(parser_control): Mark dates_seen, days_seen, local_zones_seen,
dsts_seen, times_seen, zones_seen as nonnegative.
(lookup_word): Mark wordlen as nonnegative.
(yylex): Mark count as nonnegative.
(parse_datetime2): Mark tzsize as nonnegative.
* modules/parse-datetime (Depends-on): Add idx.
Paul Eggert [Sun, 6 Dec 2020 01:33:29 +0000 (17:33 -0800)]
doc: fix curved quotes issue
* doc/gnulib.texi: Set txicodequoteundirected and
txicodequotebacktick so that ` and ' in examples do not generate
curved single quotes that do the wrong thing when cut and pasted.
Paul Eggert [Sat, 5 Dec 2020 23:54:22 +0000 (15:54 -0800)]
intprops: Add INT_ADD_OK etc.
* doc/intprops.texi (Checking Integer Overflow): New section.
* lib/intprops.h: From a suggestion by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-12/msg00051.html
(SAFE_INT_ADD, SAFE_INT_SUBTRACT, SAFE_INT_MULTIPLY): New macros.
Paul Eggert [Sat, 5 Dec 2020 21:10:28 +0000 (13:10 -0800)]
doc: move exotic platfroms to Target Platforms
* doc/gnulib-intro.texi (Supported Platforms)
(Formerly Supported Platforms, Unsupported Platforms):
New subsections, split off from Target Platforms.
(Unsupported Platforms): Move the exotic-platform stuff here ...
* doc/gnulib-readme.texi (Exotic platforms): ... from this removed
section.
Paul Eggert [Sat, 5 Dec 2020 19:27:13 +0000 (11:27 -0800)]
doc: mention intptr_t etc. and IBM i
* doc/gnulib-readme.texi (Other portability assumptions):
Mention intptr_t and uintptr_t, and that arithmetic on them
works in the usual way.
(Exotic platforms): New section, containing material from
the old 'Integer Portability' section. Also mention IBM i.
* doc/intprops.texi (Wraparound Arithmetic):
Say that the macros work on unsigned integers too.
(Integer Portability): Remove.
Paul Eggert [Fri, 4 Dec 2020 18:44:51 +0000 (10:44 -0800)]
intprops: update doc and mention Unisys
* doc/gnulib-readme.texi (Other portability assumptions):
Also mention ptrdiff_t when talking about widths and overflow.
* doc/intprops.texi (Integer Properties): Summarize new section.
(Arithmetic Type Properties): Document that EXPR_SIGNED no longer
evaluates its argument.
(Integer Bounds): Fix typo.
(Wraparound Arithmetic): Remove obsolete comment about efficiency.
Document that the _WRAPV macros now support pointers to unsigned
integers.
(Integer Range Overflow): Update SEI CERT citation.
(Integer Portability): New subsection, which mentions
the oddball Unisys platforms as non-Gnulib targets.
Bruno Haible [Thu, 3 Dec 2020 20:00:35 +0000 (21:00 +0100)]
fprintf-posix-tests: Avoid a test failure on macOS 10.13.
Reported by Martin Storsjö <martin@martin.st> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00003.html>.
* tests/test-fprintf-posix3.c: Skip the test on macOS.
(main): Return a different exit code at each point. Allow 100 KB extra
memory consumption.
* tests/test-fprintf-posix3.sh: Update. Remove the "get_rusage_as()
doesn't work" diagnostic.
Paul Eggert [Wed, 2 Dec 2020 22:25:43 +0000 (14:25 -0800)]
canonicalize: refactor can_mode flag
* lib/canonicalize.c (MULTIPLE_BITS_SET): Remove, replacing with ...
(multiple_bits_set): ... this new static function. Uses changed.
(canonicalize_filename_mode): Refactor for clarity to avoid
modifying the CAN_MODE argument.
Paul Eggert [Wed, 2 Dec 2020 22:25:43 +0000 (14:25 -0800)]
canonicalize: prefer signed integer types
* lib/canonicalize.c: Include stddef.h, for ptrdiff_t.
(seen_triple, canonicalize_filename_mode): Prefer signed to
unsigned types where either will do, as they avoid some glitches
in comparisons and can trap on overflow when debugging.
Paul Eggert [Wed, 2 Dec 2020 22:25:42 +0000 (14:25 -0800)]
canonicalize: fix most of another EOVERFLOW issue
* lib/canonicalize.c (canonicalize_filename_mode):
Do not call stat if fewer than 20 symlinks have been traversed.
This avoids EOVERFLOW failure in the common case where there
are not that many symlinks, while continuing to catch loops
(or fail due to EOVERFLOW) in the unusual case when there
are many symlinks to traverse.
Paul Eggert [Wed, 2 Dec 2020 22:25:42 +0000 (14:25 -0800)]
canonicalize: do not assume symlinks have st_ino
* lib/canonicalize.c (canonicalize_filename_mode):
When checking for loops, use st_dev and st_ino from the parent
directory not from the symlink, as pre-2017 POSIX says these
members are not reliable for symlinks. Couple this with START
(the remaining file name to be resolved), not NAME (the whole file
name with START as its suffix).
* modules/canonicalize (Depends-on): Depend on stat, not lstat.
Paul Eggert [Wed, 2 Dec 2020 22:25:41 +0000 (14:25 -0800)]
canonicalize: fix EOVERFLOW bug
* lib/canonicalize.c (canonicalize_filename_mode):
When testing whether a directory entry is a symbolic link, or a
directory or other, do not use lstat or stat or
areadlink_with_size. Just use areadlink, as this suffices and it
avoids the EOVERFLOW problem that lstat and stat have.
* modules/canonicalize (Depends-on): Depend on areadlink instead
of areadlink-with-size and stat.
Paul Eggert [Wed, 2 Dec 2020 22:25:41 +0000 (14:25 -0800)]
canonicalize-lgpl: fix EOVERFLOW bug
* lib/canonicalize-lgpl.c: Do not include <sys/stat.h>.
(__realpath): Do not use lstat. Just use readlink, as this
suffices and it avoids the EOVERFLOW problem that lstat has.
* modules/canonicalize-lgpl (Depends-on): Remove lstat, sys_stat.
Bruno Haible [Tue, 1 Dec 2020 18:57:17 +0000 (19:57 +0100)]
vma-iter: Add support for macOS11/arm64.
Patch suggested by Hill Ma <maahiuzeon@gmail.com> in
<https://gitlab.com/gnu-clisp/clisp/-/issues/27>
and by Martin Storsjö <martin@martin.st> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00003.html>.
* lib/vma-iter.c (vma_iterate): On arm64, use 64-bit type definitions.
Akim Demaille [Sun, 29 Nov 2020 14:59:22 +0000 (15:59 +0100)]
bitset: style: use consistent names
* bitset/list.c (lbitset_list_reverse): Rename 'bcount' as 'bitcnt',
and 'boffset' as 'bitoff', for consistency with the other
implementations.
* bitset/table.c (tbitset_list_reverse): Likewise.
Bruno Haible [Sun, 29 Nov 2020 22:14:56 +0000 (23:14 +0100)]
spawn-pipe tests: Fix test failure with MSVC.
* tests/test-spawn-pipe-child.c: Include <stdint.h>.
(gl_msvc_invalid_parameter_handler): New function.
(main): Set a global invalid-parameter handler.
* modules/spawn-pipe-tests (Depends-on): Add msvc-inval, stdint.
Bruno Haible [Sun, 29 Nov 2020 20:13:33 +0000 (21:13 +0100)]
fcntl: Work around NetBSD bug with F_DUPFD_CLOEXEC.
* m4/fcntl.m4 (gl_FUNC_FCNTL): Test whether F_DUPFD_CLOEXEC actually
works.
* lib/fcntl.c (rpl_fcntl_DUPFD_CLOEXEC): On NetBSD, use the same
fallback implementation as on Haiku.
* tests/test-fcntl.c (main): Add a test whether F_DUPFD_CLOEXEC is
effective.
* doc/posix-functions/fcntl.texi: Mention the NetBSD bug.
Bruno Haible [Sun, 29 Nov 2020 17:37:33 +0000 (18:37 +0100)]
spawn-pipe: Fix build on OS/2 kLIBC (regression 2020-11-28).
* lib/os2-spawn.h: New file, based on lib/windows-spawn.h.
* lib/os2-spawn.c: New file, based on lib/windows-spawn.c.
* lib/spawn-pipe.c: On OS/2 kLIBC, include "os2-spawn.h".
* lib/windows-spawn.c: Remove modifications for kLIBC.
* modules/spawn-pipe (Files): Add the new files.
(configure.ac): Arrange to compile os2-spawn.c on OS/2.
* lib/stdio.in.h (_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD,
_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM): New macros.
(_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD): Renamed from
_GL_ATTRIBUTE_FORMAT_PRINTF. Use _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD.
(_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM): Use
_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM.
* modules/vasnprintf (Depends-on): Add stdio.
* lib/vasnprintf.h: Include <stdio.h>.
(asnprintf, vasnprintf): Use the standard printf format attribute.
* modules/xvasprintf (Depends-on): Add stdio.
* lib/xvasprintf.h: Include <stdio.h>.
(xasprintf, xvasprintf): Use the standard printf format attribute.
* modules/xprintf (Depends-on): List stdio first.
* lib/xprintf.h (xprintf, xvprintf): Use a printf format attribute that
depends on GNULIB_VPRINTF_POSIX.
(xfprintf, xvfprintf): Use a printf format attribute that depends on
GNULIB_VFPRINTF_POSIX.
* modules/c-vasnprintf (Depends-on): Add stdio.
* lib/c-vasnprintf.h: Include <stdio.h>.
(c_vasnprintf): Use the standard printf format attribute.
* modules/c-vasprintf (Depends-on): Add stdio.
* lib/c-vasprintf.h: Include <stdio.h>.
(c_asprintf, c_vasprintf): Use the standard printf format attribute.
* modules/c-vsnprintf (Depends-on): Add stdio.
* lib/c-vsnprintf.h: Include <stdio.h>.
(c_vsnprintf): Use the standard printf format attribute.
* modules/c-snprintf (Depends-on): Add stdio.
* lib/c-snprintf.h: Include <stdio.h>.
(c_snprintf): Use the standard printf format attribute.
* modules/c-xvasprintf (Depends-on): Add stdio.
* lib/c-xvasprintf.h: Include <stdio.h>.
(c_xasprintf, c_xvasprintf): Use the standard printf format attribute.
* modules/error (Depends-on): Depend on stdio always.
* lib/error.h: Include <stdio.h>.
(_GL_ATTRIBUTE_SPEC_PRINTF): Remove macro.
(error, error_at_line): Use a printf format attribute that depends on
GNULIB_VFPRINTF_POSIX.
* lib/error.c (_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD): Renamed from
_GL_ATTRIBUTE_FORMAT_PRINTF.
* modules/verror (Depends-on): Add stdio.
* lib/verror.h: Include <stdio.h>. Don't include "error.h".
(verror, verror_at_line): Use the standard printf format attribute.
* lib/verror.c: Include "error.h".
* modules/argp (Depends-on): Add stdio.
* lib/argp.h (argp_error, __argp_error, argp_failure, __argp_failure):
Use a printf format attribute that depends on GNULIB_VFPRINTF_POSIX.
* modules/libtextstyle-optional (Depends-on): Add stdio.
* lib/textstyle.in.h (ostream_printf, ostream_vprintf): Use the standard
printf format attribute.
* tests/test-nonblocking-misc.h (dbgfprintf): Use the standard printf
format attribute.
Pádraig Brady [Mon, 23 Nov 2020 15:14:50 +0000 (15:14 +0000)]
selinux-at, selinux-h: use const correct declarations
* lib/se-selinux.in.h: Use const for "set" functions,
to match current selinux, and support cleaner user code.
* lib/selinux-at.c: Likewise.
* lib/selinux-at.h: Likewise.
Paul Eggert [Mon, 23 Nov 2020 07:37:57 +0000 (23:37 -0800)]
canonicalize-lgpl: fix memory leak
* lib/canonicalize-lgpl.c (__realpath): Fix unlikely memory leak,
which could have occurred if BUF was so large that malloc was
called. Do this by allocating EXTRA_BUF and BUF at the same time;
this eliminates the need to free BUF separately.
Paul Eggert [Sun, 22 Nov 2020 03:04:10 +0000 (19:04 -0800)]
parse-datetime: fix printf format typo
* lib/parse-datetime.y (parse_datetime2): Fix format typo in
previous patch to this file. Problem reported by Chris Elvidge in
<https://bugs.gnu.org/44763#32>.