]> Savannah Git Hosting - gnulib.git/log
gnulib.git
4 years agofindprog-in: Improve errno upon failure on native Windows.
Bruno Haible [Thu, 24 Dec 2020 12:32:39 +0000 (13:32 +0100)]
findprog-in: Improve errno upon failure on native Windows.

* lib/findprog-in.c (find_in_given_path): If the file basename has no
dot and the search with a suffix returned no result, do also a search
without a suffix, and set errno = ENOEXEC if we find a file in this way.
* tests/test-spawn-pipe-script.c (main): Update expected errno.

4 years agoposix_spawn, posix_spawnp: Fix execution of scripts.
Bruno Haible [Thu, 24 Dec 2020 02:49:20 +0000 (03:49 +0100)]
posix_spawn, posix_spawnp: Fix execution of scripts.

* m4/posix_spawn.m4 (gl_POSIX_SPAWN_SECURE): New macro.
(gl_POSIX_SPAWN_BODY): Invoke it. Set REPLACE_POSIX_SPAWN if posix_spawn
or posix_spawnp allows unsecure execution of scripts.
* doc/posix-functions/posix_spawn.texi: Document the script execution
problem.
* doc/posix-functions/posix_spawnp.texi: Likewise.

4 years agoAdd unit tests regarding execution of scripts.
Bruno Haible [Thu, 24 Dec 2020 00:14:49 +0000 (01:14 +0100)]
Add unit tests regarding execution of scripts.

* tests/executable-script: New file.
* tests/executable-shell-script: New file.
* tests/test-posix_spawn-script.c: New file.
* tests/test-posix_spawnp-script.c: New file.
* tests/test-execute-script.c: New file.
* tests/test-spawn-pipe-script.c: New file.
* modules/posix_spawn-tests (Files): Add
tests/test-posix_spawn-script.c, tests/executable-script,
tests/executable-shell-script.
(Makefile.am): Compile and run test-posix_spawn-script.
* modules/posix_spawnp-tests (Files): Add
tests/test-posix_spawnp-script.c, tests/executable-script,
tests/executable-shell-script.
(Makefile.am): Compile and run test-posix_spawnp-script.
* modules/execute-tests (Files): Add tests/test-execute-script.c,
tests/executable-script, tests/executable-shell-script.
(Makefile.am): Compile and run test-execute-script.
* modules/spawn-pipe-tests (Files): Add tests/test-spawn-pipe-script.c,
tests/executable-script, tests/executable-shell-script.
(Makefile.am): Compile and run test-spawn-pipe-script.

4 years agoDon't execute scripts without '#!' marker through /bin/sh.
Bruno Haible [Wed, 23 Dec 2020 22:58:17 +0000 (23:58 +0100)]
Don't execute scripts without '#!' marker through /bin/sh.

This reflects the change done in glibc through
<https://sourceware.org/bugzilla/show_bug.cgi?id=13134> and
<https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d96de9634a334af16c0ac711074c15ac1762b23c>.

* lib/spawni.c (internal_function): Remove macro.
(script_execute): Remove function.
(__spawni): Don't invoke script_execute.
* lib/execute.c (execute): Disable the ENOEXEC handling.
* lib/spawn-pipe.c (create_pipe): Likewise.
* NEWS: Mention the change.

4 years agoposix_spawn[p]: Fix compilation error on Windows (regr. 2020-12-14).
Bruno Haible [Thu, 24 Dec 2020 03:11:02 +0000 (04:11 +0100)]
posix_spawn[p]: Fix compilation error on Windows (regr. 2020-12-14).

Reported by Adrian Ebeling <devl@adrian-ebeling.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00189.html>.

* lib/spawni.c (__spawni): Update function parameters.

4 years agoposix_spawn tests: Add two more tests.
Bruno Haible [Wed, 23 Dec 2020 22:26:42 +0000 (23:26 +0100)]
posix_spawn tests: Add two more tests.

* tests/test-posix_spawn-inherit0.c: New file, based on
tests/test-posix_spawn-open2.c.
* tests/test-posix_spawn-inherit1.c: New file, based on
tests/test-posix_spawn-open2.c.
* modules/posix_spawn-tests (Files): Add them.
(Depends-on): Add fflush.
(Makefile.am): Compile and run test-posix_spawn-inherit0 and
test-posix_spawn-inherit1.

4 years agoposix_spawn tests: Add another test.
Bruno Haible [Wed, 23 Dec 2020 22:22:03 +0000 (23:22 +0100)]
posix_spawn tests: Add another test.

* tests/test-posix_spawn-open2.c: New file, based on
tests/test-posix_spawn-open1.c.
* modules/posix_spawn-tests (Files): Add it.
(Makefile.am): Compile and run test-posix_spawn-open1.

4 years agobuild-aux/config.guess
Karl Berry [Wed, 23 Dec 2020 17:10:41 +0000 (09:10 -0800)]
build-aux/config.guess

4 years agoRemove support for broken <wchar.h> in AIX 3.
Bruno Haible [Mon, 21 Dec 2020 01:49:20 +0000 (02:49 +0100)]
Remove support for broken <wchar.h> in AIX 3.

* m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Simplify test programs.

4 years agoRemove support for broken <wchar.h> in BSD/OS and OSF/1.
Bruno Haible [Mon, 21 Dec 2020 01:43:45 +0000 (02:43 +0100)]
Remove support for broken <wchar.h> in BSD/OS and OSF/1.

* lib/wchar.in.h: Don't include <stdio.h>, <time.h>.
* lib/mbchar.h: Likewise.
* lib/mbiter.h: Likewise.
* lib/mbuiter.h: Likewise.
* m4/stdint.m4 (gl_STDINT_INCLUDES): Likewise.
* lib/mbfile.h: Don't include <time.h>.
* lib/mbswidth.h: Update comment.
* lib/stdint.in.h: Don't include <stddef.h>, <stdio.h>, <time.h> before
<wchar.h>.
* lib/wctype.in.h: Likewise.
* m4/btowc.m4 (gl_FUNC_BTOWC): Simplify test programs.
* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Likewise.
* m4/iswdigit.m4 (gl_FUNC_ISWDIGIT): Likewise.
* m4/iswxdigit.m4 (gl_FUNC_ISWXDIGIT): Likewise.
* m4/mbrlen.m4 (gl_FUNC_MBRLEN, gl_MBRLEN_INCOMPLETE_STATE,
gl_MBRLEN_RETVAL, gl_MBRLEN_NUL_RETVAL): Likewise.
* m4/mbrtoc32.m4 (gl_MBRTOC32_SANITYCHECK): Likewise.
* m4/mbrtowc.m4 (gl_FUNC_MBRTOWC, gl_MBRTOWC_INCOMPLETE_STATE,
gl_MBRTOWC_SANITYCHECK, gl_MBRTOWC_NULL_ARG1, gl_MBRTOWC_NULL_ARG2,
gl_MBRTOWC_RETVAL, gl_MBRTOWC_NUL_RETVAL, gl_MBRTOWC_STORES_INCOMPLETE,
AC_FUNC_MBRTOWC): Likewise.
* m4/mbsinit.m4 (gl_FUNC_MBSINIT): Likewise.
* m4/mbsnrtowcs.m4 (gl_MBSNRTOWCS_WORKS_IN_TRADITIONAL_LOCALE):
Likewise.
* m4/mbsrtowcs.m4 (gl_FUNC_MBSRTOWCS, gl_MBSRTOWCS_WORKS): Likewise.
* m4/mbstate_t.m4 (AC_TYPE_MBSTATE_T): Likewise.
* m4/mbswidth.m4 (gl_MBSWIDTH): Likewise.
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_LS): Likewise.
* m4/wchar_h.m4 (gl_WCHAR_H, gl_WCHAR_H_INLINE_OK): Likewise.
* m4/wcrtomb.m4 (gl_FUNC_WCRTOMB): Likewise.
* m4/wcsdup.m4 (gl_FUNC_WCSDUP): Likewise.
* m4/wcsnrtombs.m4 (gl_WCSNRTOMBS_WORKS_IN_TRADITIONAL_LOCALE):
Likewise.
* m4/wcsrtombs.m4 (gl_FUNC_WCSRTOMBS, gl_WCSRTOMBS_TERMINATION,
gl_WCSRTOMBS_NULL): Likewise.
* m4/wcstok.m4 (gl_FUNC_WCSTOK): Likewise.
* m4/wctob.m4 (gl_FUNC_WCTOB): Likewise.
* m4/wctype_h.m4 (gl_WCTYPE_H): Likewise.
* m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Likewise.
* m4/wint_t.m4 (gt_TYPE_WINT_T): Likewise.
* m4/wmemchr.m4 (gl_FUNC_WMEMCHR): Likewise.
* m4/wmemcmp.m4 (gl_FUNC_WMEMCMP): Likewise.
* m4/wmemcpy.m4 (gl_FUNC_WMEMCPY): Likewise.
* m4/wmemmove.m4 (gl_FUNC_WMEMMOVE): Likewise.
* m4/wmemset.m4 (gl_FUNC_WMEMSET): Likewise.

4 years agoisnanf: Fix autoconf test.
Bruno Haible [Mon, 21 Dec 2020 00:17:12 +0000 (01:17 +0100)]
isnanf: Fix autoconf test.

* m4/isnanf.m4 (gl_ISNANF_WORKS): Fix one of the NaN tests.

4 years agoRemove some of the support for obsolete IRIX 4 and 5.
Bruno Haible [Sun, 20 Dec 2020 22:24:54 +0000 (23:24 +0100)]
Remove some of the support for obsolete IRIX 4 and 5.

* m4/mountlist.m4 (AC_FUNC_GETMNTENT): Don't test for getmntent in
libsun.
* tests/init.sh (setup_): Don't talk about IRIX 5.

4 years agofilemode: Remove Cray support.
Bruno Haible [Sun, 20 Dec 2020 21:19:26 +0000 (22:19 +0100)]
filemode: Remove Cray support.

* lib/filemode.c (IS_MIGRATED_FILE): Remove macro.
(filemodestring): Don't produce an 'M' type.
* m4/filemode.m4 (gl_FILEMODE): Don't invoke AC_STRUCT_ST_DM_MODE.
* m4/st_dm_mode.m4: Remove file.
* modules/filemode (Files): Remove it.

4 years agofree-posix: assume glibc 2.33 fixes this.
Paul Eggert [Sun, 20 Dec 2020 21:29:04 +0000 (13:29 -0800)]
free-posix: assume glibc 2.33 fixes this.

* m4/free.m4 (gl_FUNC_FREE): Assume glibc 2.33+ is fixed.
Use compile-time test rather than guessing for cross-builds.

4 years agobackupfile: Fix compilation error on native Windows (regr. 2018-10-23).
Bruno Haible [Sun, 20 Dec 2020 14:10:05 +0000 (15:10 +0100)]
backupfile: Fix compilation error on native Windows (regr. 2018-10-23).

Reported by Adrian Ebeling <adrianebeling@gmx.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00156.html>.

* lib/backupfile.c (fpathconf): Define fallback, like for pathconf.

4 years agofloat: Fix compilation error when gnulib's float.h exists twice, part 2.
Bruno Haible [Sun, 20 Dec 2020 13:50:18 +0000 (14:50 +0100)]
float: Fix compilation error when gnulib's float.h exists twice, part 2.

Reported by Santiago Vila <sanvila@unex.es>.

* lib/float.in.h (GNULIB_defined_long_double_union): New macro.

4 years agofloat: Fix compilation error when gnulib's float.h exists twice.
Bruno Haible [Sun, 20 Dec 2020 13:41:29 +0000 (14:41 +0100)]
float: Fix compilation error when gnulib's float.h exists twice.

Reported by Santiago Vila <sanvila@unex.es>.

* lib/float.in.h (GNULIB_defined_long_double_union): New macro.

4 years agofree-posix: Assume future POSIX compliance only on OpenBSD and Solaris.
Bruno Haible [Sat, 19 Dec 2020 19:19:45 +0000 (20:19 +0100)]
free-posix: Assume future POSIX compliance only on OpenBSD and Solaris.

* m4/free.m4 (gl_FUNC_FREE): Guess yes only on OpenBSD and Solaris.
Don't trust _POSIX_VERSION for this test.

4 years agofree-posix: port to GNU/Linux
Paul Eggert [Sat, 19 Dec 2020 16:14:38 +0000 (08:14 -0800)]
free-posix: port to GNU/Linux

* m4/free.m4 (gl_FUNC_FREE): Don’t assume GNU hosts are free of
the bug, as it occurs on Ubuntu 20.10 x86-64 and, I assume, on
other GNU/Linux hosts.

4 years agofree-posix: Add tests.
Bruno Haible [Sat, 19 Dec 2020 12:26:24 +0000 (13:26 +0100)]
free-posix: Add tests.

* tests/test-free.c: New file.
* tests/macros.h (ASSERT_NO_STDIO,
WRITE_MACROEXPANDED_INTEGER_TO_STDERR, WRITE_INTEGER_TO_STDERR,
WRITE_TO_STDERR): New macros.
* modules/free-posix-tests: New file.

4 years agofree-posix: Add C++ declaration test.
Bruno Haible [Fri, 18 Dec 2020 23:28:02 +0000 (00:28 +0100)]
free-posix: Add C++ declaration test.

* tests/test-stdlib-c++.cc (free): New declaration.

4 years agofree-posix: New module, renamed from 'free'.
Bruno Haible [Fri, 18 Dec 2020 23:18:50 +0000 (00:18 +0100)]
free-posix: New module, renamed from 'free'.

* modules/free-posix: Renamed from modules/free.
(configure.ac): Update gl_STDLIB_MODULE_INDICATOR invocation.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_FREE_POSIX,
not GNULIB_FREE.
* modules/stdlib (Makefile.am): Substitute GNULIB_FREE_POSIX, not
GNULIB_FREE.
* lib/stdlib.in.h (free): Test GNULIB_FREE_POSIX, not GNULIB_FREE.
* doc/posix-functions/free.texi: Mention the module 'free-posix' and
what it does.
* NEWS: Mention that module 'free' no longer exists.
* modules/canonicalize (Depends-on): Add free-posix. Remove free.
* modules/canonicalize-lgpl (Depends-on): Likewise.

4 years agofree: Remove support for obsolete platforms.
Bruno Haible [Fri, 18 Dec 2020 22:58:37 +0000 (23:58 +0100)]
free: Remove support for obsolete platforms.

* m4/free.m4 (gl_FUNC_FREE): Assume free(NULL) works. Don't define
CANNOT_FREE_NULL.
* lib/free.c (rpl_free): Don't test CANNOT_FREE_NULL.
* modules/free (Description): Update.
* doc/posix-functions/free.texi: Don't mention SunOS 4 any more.

4 years agointprops: port to ICC 2021.1 Beta 20201112
Paul Eggert [Fri, 18 Dec 2020 18:18:40 +0000 (10:18 -0800)]
intprops: port to ICC 2021.1 Beta 20201112

* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P):
Port to ICC 2021.1, which has a non-working __builtin_mul_overflow_p.
Add a clause for other compilers that claim to support
__builtin_mul_overflow_p, since we might as well find out about
slackers other than Clang and ICC.
(INT_MULTIPLY_WRAPV): ICC 2021 has GCC bug 91450, so treat it
like older GCCs even when it claims to be a newer one.

4 years agointprops: Avoid potentially buggy __builtin_add_overflow in GCC 5, 6.
Bruno Haible [Fri, 18 Dec 2020 12:10:27 +0000 (13:10 +0100)]
intprops: Avoid potentially buggy __builtin_add_overflow in GCC 5, 6.

Reported by Stefan Liebler <stli@linux.ibm.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00152.html>.

* lib/intprops.h (_GL_HAS_BUILTIN_ADD_OVERFLOW): Don't define for
GCC 5.x and 6.x.
* lib/glob.c (size_add_wrapv): Don't use __builtin_add_overflow for
GCC 5.x and 6.x.

4 years agofree: Fix warning.
Bruno Haible [Thu, 17 Dec 2020 23:41:07 +0000 (00:41 +0100)]
free: Fix warning.

Reported by Pádraig Brady <P@draigBrady.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00148.html>.

* lib/stdlib.in.h (free): New declaration.
* m4/stdlib_h.m4 (gl_STDLIB_H): Test whether 'free' is declared.
(gl_STDLIB_H_DEFAULTS): Initialize GNULIB_FREE, REPLACE_FREE.
* modules/stdlib (Makefile.am): Substitute GNULIB_FREE, REPLACE_FREE.
* m4/free.m4 (gl_FUNC_FREE): Set REPLACE_FREE, instead of defining
'free' as a macro here.
* modules/free (Depends-on): Add stdlib.
(configure.ac): Test REPLACE_FREE. Invoke gl_STDLIB_MODULE_INDICATOR.

4 years agocanonicalize-lgpl: fix AIX test failures
Paul Eggert [Thu, 17 Dec 2020 09:22:55 +0000 (01:22 -0800)]
canonicalize-lgpl: fix AIX test failures

This merges the recent canonicalize.c fix into canonicalize-lgpl.c.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-12/msg00138.html
* lib/canonicalize-lgpl.c: Include sys/stat.h.
(__realpath): When testing a file name ending in '/', use stat
rather than readlink, so that it does the right thing on AIX.
* modules/canonicalize-lgpl (Depends-on): Add stat, sys_stat.

4 years agocanonicalize: omit second readlink when not needed
Paul Eggert [Thu, 17 Dec 2020 09:13:40 +0000 (01:13 -0800)]
canonicalize: omit second readlink when not needed

* lib/canonicalize.c (canonicalize_filename_mode_stk):
Omit second readlink when (can_exist != CAN_MISSING
&& startlen != 0 && !logical).  Simplify.

4 years agocanonicalize: remove arbitrary 8192-byte limit
Paul Eggert [Thu, 17 Dec 2020 07:50:34 +0000 (23:50 -0800)]
canonicalize: remove arbitrary 8192-byte limit

Remove canonicalize.c’s arbitrary 8192-byte limit on platforms
like GNU Hurd that do not define the PATH_MAX macro, and similarly
for canonicalize-lgpl.c’s arbitrary 1024-byte limit.  Do this by
using scratch buffers.  Lessen the number of differences between
the two source files, to simplify this and future maintenance.
* lib/canonicalize-lgpl.c (__realpath):
* lib/canonicalize.c (canonicalize_filename_mode_stk):
Use scratch buffers instead of malloc and malloca.  This avoids
the need for alloca, and avoids the need for malloc in most cases.
* lib/canonicalize-lgpl.c, lib/canonicalize.c: Make these files
easier to compare, e.g., by sorting include files and by switching
to the GNU convention of calling file names "file names", not
"path names".  Include stdbool.h, scratch_buffer.h.
* lib/canonicalize-lgpl.c (IDX_MAX) [_LIBC]: New macro.
(malloca) [_LIBC]: Remove.
[!_LIBC]: Do not include malloca.h.
(get_path_max): New function, so that pathconf is called only in
the rare and dubious case when when RESOLVED is not null and
PATH_MAX is not defined.  Invoke pathconf on "/" not the input
file name, as we care about the longest file name starting from
"/" (not from the input file name), and POSIX does not specify
what pathconf does on a non-directory file anyway.  If PATH_MAX is
not defined, do not worry about overriding a path_max of 0, and do
not let path_max exceed IDX_MAX.
(__realpath): Remove an assumption that file name components
cannot exceed 1024 bytes when PATH_MAX is not defined (wrong for
the Hurd, presumably).
When allocating the result, allocate it to just the right size;
this costs nothing when the result is smaller than 1023 bytes,
and for larger results it's probably worth the CPU to call realloc,
as canonicalize.c already does.
* lib/canonicalize.c: Include attribute.h.
Do not include pathmax.h or xgetcwd.h.
(PATH_MAX): Do not define, so file names longer than 8192 bytes
work on platforms with no fixed limit.
(canonicalize_filename_mode_stk): New function, with
the content of the old canonicalize_filename_mode.
Use getcwd instead of xgetcwd, and readlink instead of areadlink,
since the scratch buffers now do memory management for us.
Use rawmemchr instead of adding strlen.
Use mempcpy instead of mempcpy + size.
Assume free preserves errno.
(canonicalize_filename_mode): Use it.
* modules/canonicalize (Depends-on): Remove areadlink, pathmax,
xgetcwd.  Add attribute, free, getcwd, mempcpy, rawmemchr,
scratch_buffer, stdbool, xalloc-die.
* modules/canonicalize-lgpl (Depends-on): Remove alloca-opt,
malloca, realloc-posix.  Add scratch_buffer, stdbool.

4 years agocanonicalize-lgpl: simplify merge to glibc
Paul Eggert [Mon, 14 Dec 2020 19:59:20 +0000 (11:59 -0800)]
canonicalize-lgpl: simplify merge to glibc

This patch lessens the differences between git glibc
stdlib/canonicalize.c and lib/canonicalize-lgpl.c.
The (perhaps wishful) goal is to make them identical.
* lib/canonicalize-lgpl.c [!_LIBC]:
Include <libc-config.h>, not config.h.
Omit an unnecessary (!HAVE_CANONICALIZE_FILE_NAME ||
!FUNC_REALPATH_WORKS || defined _LIBC) #if.
Do not include alloca.h, since we use malloca now.
[_LIBC]: Include <eloop-threshold.h>, and define dummy macros
FILE_SYSTEM_PREFIX_LEN, IS_ABSOLUTE_FILE_NAME, ISSLASH, malloca,
freea so that the mainline code can be kept #ifdef free.
[!_LIBC]: Remove dummy macros for SHLIB_COMPAT, versioned_symbol,
compat_symbol, weak_alias, __set_errno since libc-config.h does that.
Add redirecting macros __mempcpy, __pathconf, __rawmemchr,
__eloop_threshold.  All uses of their definiens changed.
(SIZE_MAX): Remove; no longer needed.
(alloc_failed): Remove, and remove all instances.
No need for alloc_failed now that free preserves errno.
(__realpath): Default path_max to 1024 instead of 8192, as that’s
the glibc tradition and is safer when the 2nd argument is null.
Use __rawmemchr instead of strchr.
Use __mempcpy where appropriate.
Simplify test for overflow so that it does not need SIZE_MAX.
Do not preserve errno around free or freea calls; no longer needed.
Mark __realpath with libc_hidden_def.
* modules/canonicalize-lgpl (Depends-on): Add free, libc-config,
malloc-posix, mempcpy, realloc-posix, rawmemchr.
* modules/free: Now LGPLv2+, for canonicalize-lgpl.

4 years agofree: preserve errno
Paul Eggert [Mon, 14 Dec 2020 19:38:18 +0000 (11:38 -0800)]
free: preserve errno

* lib/free.c (rpl_free): Preserve errno.  Check for null only if
CANNOT_FREE_NULL is defined, as an optimization for POSIX 2008
platforms that do not preserve errno.
* m4/free.m4 (gl_FUNC_FREE): Check whether free preserves errno.
Also, define CANNOT_FREE_NULL if free cannot free NULL.
* modules/free (configure.ac): Also replace 'free' if
it does not preserve errno.

4 years agoidx: simplify IDX_MAX, remove IDX_WIDTH
Paul Eggert [Thu, 17 Dec 2020 07:52:24 +0000 (23:52 -0800)]
idx: simplify IDX_MAX, remove IDX_WIDTH

* lib/idx.h (IDX_MAX): Simplify by removing obsolete reference
to UNSIGNED_IDX_T.
(IDX_WIDTH): Remove, since it’s not used and its value
arguably should be PTRDIFF_WIDTH anyway.

4 years agoposix_spawn_file_actions_addfchdir-tests: Rename test.
Bruno Haible [Thu, 17 Dec 2020 02:00:25 +0000 (03:00 +0100)]
posix_spawn_file_actions_addfchdir-tests: Rename test.

* tests/test-posix_spawn-fchdir.c: Renamed from
tests/test-posix_spawn5.c.
* modules/posix_spawn_file_actions_addfchdir-tests (Files, Makefile.am):
Update.

4 years agoposix_spawn_file_actions_addchdir-tests: Rename test.
Bruno Haible [Thu, 17 Dec 2020 01:56:21 +0000 (02:56 +0100)]
posix_spawn_file_actions_addchdir-tests: Rename test.

* tests/test-posix_spawn-chdir.c: Renamed from
tests/test-posix_spawn4.c.
* modules/posix_spawn_file_actions_addchdir-tests (Files, Makefile.am):
Update.

4 years agoposix_spawn-tests: Rename test.
Bruno Haible [Thu, 17 Dec 2020 01:47:40 +0000 (02:47 +0100)]
posix_spawn-tests: Rename test.

* tests/test-posix_spawn-open1.c: Renamed from
tests/test-posix_spawn3.c.
* modules/posix_spawn-tests (Files, Makefile.am): Update.

4 years agoposix_spawnp-tests: Rename test.
Bruno Haible [Thu, 17 Dec 2020 01:44:31 +0000 (02:44 +0100)]
posix_spawnp-tests: Rename test.

* tests/test-posix_spawn-dup2-stdin.c: Renamed from
tests/test-posix_spawn2.c.
* tests/test-posix_spawn-dup2-stdin.in.sh: Renamed from
tests/test-posix_spawn2.in.sh.
* modules/posix_spawnp-tests (Files, Makefile.am): Update.

4 years agoposix_spawnp-tests: Rename test.
Bruno Haible [Thu, 17 Dec 2020 01:38:08 +0000 (02:38 +0100)]
posix_spawnp-tests: Rename test.

* tests/test-posix_spawn-dup2-stdout.c: Renamed from
tests/test-posix_spawn1.c.
* tests/test-posix_spawn-dup2-stdout.in.sh: Renamed from
tests/test-posix_spawn1.in.sh.
* modules/posix_spawnp-tests (Files, Makefile.am): Update.

4 years agofindprog-in: Allow overriding the current directory.
Bruno Haible [Mon, 14 Dec 2020 19:56:04 +0000 (20:56 +0100)]
findprog-in: Allow overriding the current directory.

* lib/findprog.h (find_in_given_path): Add directory argument.
* lib/findprog-in.c (find_in_given_path): Likewise.
* lib/execute.c (execute): Update caller.
* lib/spawn-pipe.c (create_pipe): Likewise.
* lib/windows-spawn.c (spawnpvech): Likewise.
* NEWS: Mention the change.

4 years agoposix_spawn-internal: Make better use of 'const'.
Bruno Haible [Mon, 14 Dec 2020 18:22:14 +0000 (19:22 +0100)]
posix_spawn-internal: Make better use of 'const'.

* lib/spawn_int.h (__spawni): Does not need write access to the elements
of argv and envp.
* lib/spawni.c (__spawni, script_execute): Likewise.
* lib/spawn.c (posix_spawn): Update caller.
* lib/spawnp.c (posix_spawnp): Likewise.

4 years agospawn: Make it compile on native Windows.
Bruno Haible [Mon, 14 Dec 2020 17:07:28 +0000 (18:07 +0100)]
spawn: Make it compile on native Windows.

* modules/spawn (Depends-on): Add signal-h.

4 years agowindows-spawn: Avoid shadowing a variable.
Bruno Haible [Mon, 14 Dec 2020 17:05:38 +0000 (18:05 +0100)]
windows-spawn: Avoid shadowing a variable.

* lib/windows-spawn.c (spawnpvech): Rename local variable 'flags'.

4 years agostring: port memchr macro to AIX 7.2 XLC
Paul Eggert [Mon, 14 Dec 2020 01:32:34 +0000 (17:32 -0800)]
string: port memchr macro to AIX 7.2 XLC

Its <string.h> defines a memchr macro to help inlining.
* lib/string.in.h (memchr): #undef before #defining.

4 years agocanonicalize: fix AIX test failures
Paul Eggert [Mon, 14 Dec 2020 01:16:01 +0000 (17:16 -0800)]
canonicalize: fix AIX test failures

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-12/msg00109.html
* lib/canonicalize.c (canonicalize_filename_mode):
When testing a file name ending in '/', use stat rather than
readlink, so that it does the right thing on AIX.
* modules/canonicalize (Depends-on): Add readlink, to pull in the
recent changes in the Gnulib readlink module.

4 years agoAssume readlink/readlinkat ERANGE fix
Paul Eggert [Mon, 14 Dec 2020 00:56:10 +0000 (16:56 -0800)]
Assume readlink/readlinkat ERANGE fix

* lib/areadlink-with-size.c (areadlink_with_size):
* lib/areadlinkat-with-size.c (areadlinkat_with_size):
* lib/careadlinkat.c (readlink_stk):
Do not worry about readlink or readlinkat failing with errno == ERANGE,
since the Gnulib readlink and readlinkat modules now fix that.

4 years agogetcwd: port to AIX
Paul Eggert [Mon, 14 Dec 2020 00:51:58 +0000 (16:51 -0800)]
getcwd: port to AIX

* lib/getcwd.c [!_LIBC]: Undef stat64 before #defining it,
in case our sys/stat.h #defined a function macro with the same name.

4 years agoreadlink, readlinkat: add ERANGE portability
Paul Eggert [Mon, 14 Dec 2020 00:48:26 +0000 (16:48 -0800)]
readlink, readlinkat: add ERANGE portability

Fix some portability issues with Gnulib's readlink and readlinkat,
notably mostly working around the ERANGE problem in AIX and HP-UX.
* doc/posix-functions/readlink.texi:
* doc/posix-functions/readlinkat.texi:
ERANGE problem is mostly fixed now.  Mention AIX problem with
trailing / and EINVAL.  Lessen differences between these two files.
* lib/readlink.c (rpl_readlink):
* lib/readlinkat.c (rpl_readlinkat):
If stat ("FILE/", ...) reports EOVERFLOW, treat FILE/ as an
existing directory.  Mostly work around READLINK_TRUNCATE BUG.
Lessen spurious differences between the readlink and readlinkat code.
* lib/readlinkat.c (rpl_readlinkat):
Fix bug where stat was used where fstatat was intended.
* m4/readlink.m4 (gl_FUNC_READLINK):
Rename gl_cv_func_readlink_works to gl_cv_func_readlink_trailing_slash
to identify readlink problems more precisely.  All uses changed.
Guess no on AIX or HP-UX for this variable.
Add check for whether readlink truncates results,
and define new macro READLINK_TRUCATE_BUG accordingly.
* m4/readlinkat.m4 (gl_FUNC_READLINKAT):
Also check gl_cv_func_readlink_trailing_slash when deciding
whether to replace readlinkat.
* modules/readlinkat (Depends-on): Most dependencies are also
needed if replacing readlinkat.  fstatat is different, as it
is needed only if replacing an existing readlinkat.

4 years agospawn-pipe: Fix hanging processes on Windows (regression 2020-11-30).
Bruno Haible [Sun, 13 Dec 2020 20:45:55 +0000 (21:45 +0100)]
spawn-pipe: Fix hanging processes on Windows (regression 2020-11-30).

* lib/spawn-pipe.c (create_pipe): After spawning the subprocess, close
the stdin_handle and/or stdout_handle.

4 years agoFix gnulib-tool error when some modules occur in tests/.
Bruno Haible [Sat, 12 Dec 2020 23:28:20 +0000 (00:28 +0100)]
Fix gnulib-tool error when some modules occur in tests/.

* doc/gnulib.texi (Specification): Update statistics.
(Autoconf macros): Don't suggest to use AC_LIBOBJ in a .m4 file.
(Using AC_LIBOBJ): New section.
* check-AC_LIBOBJ: New file.
* modules/fnmatch-gnu (Files): Add lib/fnmatch.c.
* modules/fopen-gnu (Files): Add lib/fopen.c.
* modules/memmem (Files): Add lib/memmem.c.
* modules/renameat (Files): Add lib/at-func2.c.
* modules/strcasestr (Files): Add lib/strcasestr.c.
* modules/strstr (Files): Add lib/strstr.c.

4 years agosh-quote, execute, spawn-pipe, etc.: Make better use of 'const'.
Bruno Haible [Sat, 12 Dec 2020 03:18:54 +0000 (04:18 +0100)]
sh-quote, execute, spawn-pipe, etc.: Make better use of 'const'.

* lib/sh-quote.h (shell_quote_argv): Does not need write access to the
elements of argv.
* lib/sh-quote.c (shell_quote_argv): Likewise.
* lib/windows-spawn.h (prepare_spawn): Add 'const' the argument type and
the return type.
* lib/windows-spawn.c (prepare_spawn): Likewise.
* lib/os2-spawn.h (prepare_spawn): Likewise.
* lib/os2-spawn.c (prepare_spawn): Likewise.
* lib/execute.h (execute): Does not need write access to the elements of
prog_argv.
* lib/execute.c (execute): Likewise.
* lib/spawn-pipe.h (create_pipe_out, create_pipe_in, create_pipe_bidi):
Likewise.
* lib/spawn-pipe.c (create_pipe, create_pipe_bidi, create_pipe_in,
create_pipe_out): Likewise.
* lib/pipe-filter.h (pipe_filter_ii_execute, pipe_filter_gi_create):
Likewise.
* lib/pipe-filter-ii.c (pipe_filter_ii_execute): Likewise.
* lib/pipe-filter-gi.c (pipe_filter_gi_create): Likewise.
* lib/javaexec.h (execute_fn): Does not need write access to the
elements of prog_argv.
* lib/javaexec.c (execute_java_class): Update variable types and remove
casts to 'char *'.
* lib/csharpexec.h (execute_fn): Does not need write access to the
elements of prog_argv.
* lib/csharpexec.c (execute_csharp_using_mono,
execute_csharp_using_sscli): Update variable types and remove casts to
'char *'.
* lib/javacomp.c (compile_using_envjavac, compile_using_gcj,
compile_using_javac, compile_using_jikes, is_envjavac_gcj,
is_envjavac_gcj43, is_gcj_present, is_gcj_43, is_javac_present,
is_jikes_present): Update variable types and remove casts to 'char *'.
* lib/javaversion.c (execute_and_read_line): Does not need write access
to the elements of prog_argv.
* lib/csharpcomp.c (compile_csharp_using_mono,
compile_csharp_using_sscli): Update variable types and remove casts to
'char *'.
* tests/test-sh-quote.c (main): Update variable types and remove casts
to 'char *'.
* tests/test-execute-main.c (main): Update variable types and remove
casts to 'char *'.
* tests/test-spawn-pipe-main.c (test_pipe): Update variable types and
remove casts to 'char *'.
* NEWS: Mention the changes.

4 years agoexecute-tests: Fix compilation error with MSVC.
Bruno Haible [Sat, 12 Dec 2020 02:55:48 +0000 (03:55 +0100)]
execute-tests: Fix compilation error with MSVC.

* tests/test-execute-child.c (is_device): With _fstat, use
'struct _stat', not 'struct stat'.

4 years agovararrays: just use 2.70
Paul Eggert [Sat, 12 Dec 2020 01:35:59 +0000 (17:35 -0800)]
vararrays: just use 2.70

* m4/vararrays.m4 (AC_C_VARARRAYS): Do not override Autoconf 2.70
and later, since Autoconf 2.70 matches Gnulib now.

4 years agosys_types: just use 2.70
Paul Eggert [Sat, 12 Dec 2020 01:34:53 +0000 (17:34 -0800)]
sys_types: just use 2.70

* m4/sys_types_h.m4 (AC_HEADER_MAJOR):
Reindent to match Autoconf sources.
Use Autoconf 2.70 as a prerequisite, not 2.69c.

4 years agostdint: port to Autoconf 2.70
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.

4 years agopid_t.m4: just use 2.70
Paul Eggert [Fri, 11 Dec 2020 23:52:22 +0000 (15:52 -0800)]
pid_t.m4: just use 2.70

* m4/pid_t.m4 (AC_TYPE_PID_T):
Use Autoconf 2.70 as a prerequisite, not 2.69c.

4 years agolargefile: just use 2.70
Paul Eggert [Fri, 11 Dec 2020 23:51:27 +0000 (15:51 -0800)]
largefile: just use 2.70

* m4/largefile.m4 (_AC_SYS_LARGEFILE_TEST_INCLUDES):
Use Autoconf 2.70 as a prerequisite, not 2.69c.

4 years agoAC_C_RESTRICT: update from Autoconf
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.

4 years agoextensions: update from Autoconf
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.

4 years agoalloca: update from Autoconf
Paul Eggert [Fri, 11 Dec 2020 23:46:17 +0000 (15:46 -0800)]
alloca: update from Autoconf

* m4/alloca.m4 (gl_PREREQ_ALLOCA):
Trivial update to match Autoconf 2.70.

4 years agomemchr: Work around memory overrun bug on AIX 7.2.
Bruno Haible [Fri, 11 Dec 2020 11:14:03 +0000 (12:14 +0100)]
memchr: Work around memory overrun bug on AIX 7.2.

* m4/memchr.m4 (gl_FUNC_MEMCHR): Test against AIX 7.2 bug.
* doc/posix-functions/memchr.texi: Mention the AIX bug.

4 years agoexecute-tests: Fix compilation error on AIX in 32-bit mode.
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.

4 years agowindows-spawn: Relicense under LGPLv2+.
Bruno Haible [Thu, 10 Dec 2020 22:49:28 +0000 (23:49 +0100)]
windows-spawn: Relicense under LGPLv2+.

* modules/windows-spawn (License): Change to LGPLv2+.

4 years agoexecute, spawn-pipe: Fix memory leak on native Windows.
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.

4 years agofindprog-in: Relicense under LGPLv2+.
Bruno Haible [Thu, 10 Dec 2020 20:47:39 +0000 (21:47 +0100)]
findprog-in: Relicense under LGPLv2+.

Paul Smith's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00072.html>.

* modules/findprog-in (License): Change to LGPLv2+.

4 years agofindprog-in: Don't exit upon out-of-memory.
Bruno Haible [Thu, 10 Dec 2020 20:32:54 +0000 (21:32 +0100)]
findprog-in: Don't exit upon out-of-memory.

* lib/findprog.h (find_in_given_path): Document ENOMEM as possible error
code.
* lib/findprog-in.c: Don't include xalloc.h.
(find_in_given_path): Call concatenated_filename, not
xconcatenated_filename. Call strdup, not xstrdup. Upon out-of-memory,
return NULL with errno set.
* modules/findprog-in (Depends-on): Remove xconcat-filename, xalloc. Add
concat-filename, strdup-posix, malloc-posix.

4 years agofmaf: Work around a bug on FreeBSD 12.2/arm.
Bruno Haible [Wed, 9 Dec 2020 23:15:42 +0000 (00:15 +0100)]
fmaf: Work around a bug on FreeBSD 12.2/arm.

* m4/fmaf.m4 (gl_FUNC_FMAF_WORKS): Add one more test.
* doc/posix-functions/fmaf.texi: Mention the FreeBSD bug.

4 years agothreadlib: Fix test-fstrcmp failure on FreeBSD 11.
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.

4 years agomath C++ tests: Fix compilation error in with clang >= 7 on FreeBSD.
Bruno Haible [Wed, 9 Dec 2020 17:08:18 +0000 (18:08 +0100)]
math C++ tests: Fix compilation error in with clang >= 7 on FreeBSD.

* lib/math.in.h (isnan): For clang >= 7 on FreeBSD, declare 'rpl_isnan',
not 'isnan'.

4 years agostd-gnu11: Make compatible with Autoconf 2.70.
Bruno Haible [Wed, 9 Dec 2020 03:06:40 +0000 (04:06 +0100)]
std-gnu11: Make compatible with Autoconf 2.70.

* m4/std-gnu11.m4: Disable the entire file if Autoconf >= 2.70 is in
use.

4 years agoargp: Avoid undefined behaviour when invoking qsort().
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.

4 years agoargp: Improve comments.
Bruno Haible [Tue, 8 Dec 2020 18:54:27 +0000 (19:54 +0100)]
argp: Improve comments.

* lib/argp-help.c: Add sectioning comments. Write NULL to designate a
null pointer.
(struct hol_entry): Fix comment regarding sort order of group.
(hol_entry_short_iterate, hol_entry_long_iterate): Add comment.
(until_short, canon_doc_option, hol_entry_qcmp): Improve comment.
(hol_cluster_is_child, argp_hol): Move functions.
(HOL_ENTRY_PTRCMP): Remove unused macro.

4 years agoargp: Don't pass invalid arguments to isspace() and isalnum().
Bruno Haible [Tue, 8 Dec 2020 18:21:03 +0000 (19:21 +0100)]
argp: Don't pass invalid arguments to isspace() and isalnum().

* lib/argp-help.c (canon_doc_option): Cast character to 'unsigned int'
before passing it to isspace() or isalnum().

4 years agoargp: Don't rely on undefined behaviour of _tolower().
Bruno Haible [Tue, 8 Dec 2020 18:02:02 +0000 (19:02 +0100)]
argp: Don't rely on undefined behaviour of _tolower().

Patch by Eric Blake
<https://lists.gnu.org/archive/html/bug-gnulib/2009-09/msg00287.html>.

* lib/argp-help.c (hol_entry_cmp): Don't use _tolower on values that are
not upper-case.  Pass correct range to tolower.

4 years agounicodeio: Fix wrong result on FreeBSD.
Bruno Haible [Mon, 7 Dec 2020 20:13:54 +0000 (21:13 +0100)]
unicodeio: Fix wrong result on FreeBSD.

* lib/unicodeio.c (unicode_to_mb): Handle question mark fallback
characters on all platforms.

4 years agoget-rusage-data tests: Avoid test failure on FreeBSD/x86_64.
Bruno Haible [Mon, 7 Dec 2020 19:57:47 +0000 (20:57 +0100)]
get-rusage-data tests: Avoid test failure on FreeBSD/x86_64.

* tests/test-get-rusage-data.c (main): Don't expect a strict increase on
FreeBSD systems.

4 years agoget-rusage-data: Fix link error on FreeBSD 12.2/arm64.
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.

4 years agoCorrect interaction between gl_ANSI_CXX and AC_PROG_CXX.
Bruno Haible [Mon, 7 Dec 2020 13:05:09 +0000 (14:05 +0100)]
Correct interaction between gl_ANSI_CXX and AC_PROG_CXX.

Suggested by Zack Weinberg in
<https://savannah.gnu.org/support/?110294>.

* m4/ansi-c++.m4 (gl_ANSI_CXX): Mark AC_PROG_CXX as provided.
* modules/uchar-c++-tests: Revert the workaround from 2020-08-18.

4 years agoTweak the Windows oldnames workaround.
Bruno Haible [Mon, 7 Dec 2020 12:50:53 +0000 (13:50 +0100)]
Tweak the Windows oldnames workaround.

Reported by Daniel R. Hurtmans <Daniel.Hurtmans@ulb.ac.be> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00073.html>.

* lib/unistd.in.h: On native Windows, include <io.h> and <direct.h>
always.
(getcwd): Use _GL_CXXALIAS_MDA_CAST.
* lib/stdlib.in.h (putenv): Likewise.

4 years agodoc: fix flat address space discussion
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.

4 years agodoc: document -static-libubsan more
Paul Eggert [Sun, 6 Dec 2020 18:03:37 +0000 (10:03 -0800)]
doc: document -static-libubsan more

* doc/gnulib-readme.texi (High Quality): Document pros and cons of
-static-libubsan a bit more.  Mostly cons.

4 years agodoc: Add more details regarding the undefined behaviour sanitizer.
Bruno Haible [Sun, 6 Dec 2020 16:59:45 +0000 (17:59 +0100)]
doc: Add more details regarding the undefined behaviour sanitizer.

* doc/gnulib-readme.texi (High Quality): Describe
-fsanitize-undefined-trap-on-error better.

4 years agoDo the Windows oldnames workaround through the C++ GNULIB_NAMESPACE.
Bruno Haible [Sun, 6 Dec 2020 15:43:36 +0000 (16:43 +0100)]
Do the Windows oldnames workaround through the C++ GNULIB_NAMESPACE.

Reported by Daniel R. Hurtmans <Daniel.Hurtmans@ulb.ac.be> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00029.html>.

* lib/c++defs.h (_GL_CXXALIAS_MDA_CAST): New macro.
* lib/fcntl.in.h (creat, open):  In C++ mode, when GNULIB_NAMESPACE is
defined: 1. Define a symbol in this namespace. 2. Don't redirect using
a preprocessor #define.
* lib/math.in.h (j0, j1, jn, y0, y1, yn): Likewise.
* lib/search.in.h (lfind, lsearch): Likewise.
* lib/stdio.in.h (fcloseall, fdopen, fileno, getw, putw, tempnam):
Likewise.
* lib/stdlib.in.h (ecvt, fcvt, gcvt, mktemp, putenv): Likewise.
* lib/string.in.h (memccpy, strdup): Likewise.
* lib/sys_stat.in.h (chmod, umask): Likewise.
* lib/time.in.h (tzset): Likewise.
* lib/unistd.in.h (access, chdir, close, dup, dup2, execl, execle,
execlp, execv, execve, execvp, execvpe, getcwd, getpid, isatty, lseek,
read, rmdir, swab, unlink, write): Likewise.
* lib/utime.in.h (utime): Likewise.
* lib/wchar.in.h (wcsdup): Likewise.
* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize HAVE_DECL_FCLOSEALL.
(gl_STDIO_H): Set HAVE_DECL_FCLOSEALL.
* modules/stdio (Makefile.am): Substitute HAVE_DECL_FCLOSEALL.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_DECL_ECVT,
HAVE_DECL_FCVT, HAVE_DECL_GCVT.
(gl_STDLIB_H): Set HAVE_DECL_ECVT, HAVE_DECL_FCVT, HAVE_DECL_GCVT.
* modules/stdlib (Makefile.am): Substitute HAVE_DECL_ECVT,
HAVE_DECL_FCVT, HAVE_DECL_GCVT.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_EXECVPE.
(gl_UNISTD_H): Set HAVE_DECL_EXECVPE.
* modules/unistd (Makefile.am): Substitute HAVE_DECL_EXECVPE.
* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize HAVE_DECL_WCSDUP.
(gl_WCHAR_H): Set HAVE_DECL_WCSDUP.
* modules/wchar (Makefile.am): Substitute HAVE_DECL_WCSDUP.

4 years agodoc: Mention some missing function declarations.
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.

4 years agodoc: Tweak example.
Bruno Haible [Sun, 6 Dec 2020 11:49:58 +0000 (12:49 +0100)]
doc: Tweak example.

* doc/intprops.texi (Checking Integer Overflow): Use 'printf', not
'print'.

4 years agofilenamecat-tests: Use idx_t for nonnegative ptrdiff_t variables.
Bruno Haible [Sun, 6 Dec 2020 11:31:15 +0000 (12:31 +0100)]
filenamecat-tests: Use idx_t for nonnegative ptrdiff_t variables.

* tests/test-filenamecat.c: Include idx.h.
(main): Mark prefixlen as nonnegative.
* modules/filenamecat-tests (Depends-on): Add idx.

4 years agotime_rz: Use idx_t for nonnegative ptrdiff_t variables.
Bruno Haible [Sun, 6 Dec 2020 11:31:13 +0000 (12:31 +0100)]
time_rz: Use idx_t for nonnegative ptrdiff_t variables.

* lib/time_rz.c: Include idx.h.
(save_abbr): Mark zone_size as nonnegative.
* modules/time_rz (Depends-on): Add idx.

4 years agoparse-datetime: Use idx_t for nonnegative ptrdiff_t variables.
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.

4 years agofnmatch: Use idx_t for nonnegative ptrdiff_t variables.
Bruno Haible [Sun, 6 Dec 2020 11:31:08 +0000 (12:31 +0100)]
fnmatch: Use idx_t for nonnegative ptrdiff_t variables.

* lib/fnmatch.c: Include idx.h. In glibc, define idx_t directly.
* lib/fnmatch_loop.c (EXT): Mark slen, new_used, plensize as
nonnegative.
* modules/fnmatch (Depends-on): Add idx.

4 years agoc-stack: Use idx_t for nonnegative ptrdiff_t variables.
Bruno Haible [Sun, 6 Dec 2020 11:31:06 +0000 (12:31 +0100)]
c-stack: Use idx_t for nonnegative ptrdiff_t variables.

* lib/c-stack.c: Include idx.h.
(die): Mark buflen as nonnegative.
* modules/c-stack (Depends-on): Add idx.

4 years agobackupfile: Use idx_t for nonnegative ptrdiff_t variables.
Bruno Haible [Sun, 6 Dec 2020 11:30:42 +0000 (12:30 +0100)]
backupfile: Use idx_t for nonnegative ptrdiff_t variables.

* lib/backupfile.c: Include idx.h.
(numbered_backup): Mark base_offset as nonnegative.
(backupfile_internal): Likewise.
* modules/backup-rename (Depends-on): Add idx.
* modules/backupfile (Depends-on): Likewise.

4 years agodoc: fix curved quotes issue
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.

4 years agodoc: mention static and dynamic checking
Paul Eggert [Sun, 6 Dec 2020 01:31:43 +0000 (17:31 -0800)]
doc: mention static and dynamic checking

* doc/gnulib-readme.texi (High Quality): Add a bit of advice
for static and dynamic checking.

4 years agointprops: Add INT_ADD_OK etc.
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.

4 years agodoc: move exotic platfroms to Target Platforms
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.

4 years agodoc: minor rewording for IBM i
Paul Eggert [Sat, 5 Dec 2020 19:42:28 +0000 (11:42 -0800)]
doc: minor rewording for IBM i

4 years agodoc: mention intptr_t etc. and IBM i
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.

4 years agoutime: Fix a test failure on macOS 10.13.
Bruno Haible [Sat, 5 Dec 2020 01:51:06 +0000 (02:51 +0100)]
utime: Fix a test failure on macOS 10.13.

* lib/utime.c (utime): Fix mistake in last commit.

4 years agoutime: Fix a test failure on macOS 10.13.
Bruno Haible [Fri, 4 Dec 2020 23:17:02 +0000 (00:17 +0100)]
utime: Fix 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>.

* m4/utime.m4 (gl_FUNC_UTIME): Test whether utime handles trailing
slashes on files.
* lib/utime.c (utime): Add alternative implementation for Unix
platforms.
* modules/utime (Depends-on): Add stat.
* doc/posix-functions/utime.texi: Mention the macOS 10.13 bug.
* doc/posix-functions/lstat.texi: Mention that macOS 10.13 also has the
trailing-slash bug.
* doc/posix-functions/open.texi: Likewise.
* doc/posix-functions/stat.texi: Likewise.
* doc/posix-functions/symlink.texi: Likewise.

4 years agointprops: update doc and mention Unisys
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.

4 years agoidx: Clarify that idx_t always behaves like a signed type.
Bruno Haible [Fri, 4 Dec 2020 02:19:47 +0000 (03:19 +0100)]
idx: Clarify that idx_t always behaves like a signed type.

Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00034.html>.

* lib/idx.h: Clarify that idx_t always behaves like a signed type.
Don't test UNSIGNED_IDX_T.

4 years agoidx: New module.
Bruno Haible [Thu, 3 Dec 2020 21:56:22 +0000 (22:56 +0100)]
idx: New module.

* lib/idx.h: New file.
* modules/idx: New file.
* lib/canonicalize-lgpl.c: Include idx.h. Use idx_t instead of
ptrdiff_t.
* lib/canonicalize.c: Likewise.
* modules/canonicalize-lgpl (Depends-on): Add idx.
* modules/canonicalize (Depends-on): Likewise.