]> Savannah Git Hosting - gnulib.git/log
gnulib.git
3 years agostack: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:58 +0000 (17:18 -0700)]
stack: prefer idx_t for indexes

* lib/stack.h (_GL_STACK_TYPE, _GL_STACK_PREFIX):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.

3 years agosavedir: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
savedir: prefer idx_t for indexes

* lib/savedir.c (streamsavedir):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.

3 years agoreadutmp: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
readutmp: prefer idx_t for indexes

* lib/readutmp.c (read_utmp):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.

3 years agoreadtokens: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
readtokens: prefer idx_t for indexes

* lib/readtokens.c (readtoken, readtokens):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.

3 years agolinebuffer: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
linebuffer: prefer idx_t for indexes

* lib/linebuffer.c (readlinebuffer_delim):
* lib/linebuffer.h (struct linebuffer):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.
* lib/linebuffer.h: Include idx.h.
* modules/linebuffer (Depends-on): Add idx.

3 years agogetusershell: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
getusershell: prefer idx_t for indexes

* lib/getusershell.c (line_size, readname):
Prefer idx_t to size_t for indexes, using idx_t-related allocators.

3 years agoexclude: prefer idx_t for most indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
exclude: prefer idx_t for most indexes

* lib/exclude.c (struct exclude_pattern, free_exclude_segment)
(file_pattern_matches, add_exclude, add_exclude_fp):
Prefer idx_t to size_t for indexes, and use idx_t-related allocators.

3 years agodfa: prefer idx_t for indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
dfa: prefer idx_t for indexes

* lib/dfa.c (mbs_to_wchar, state_index, dfaoptimize, dfaanalyze)
(icatalloc, enlist, allocmust, dfamust):
Prefer idx_t to size_t for indexes, and use idx_t-related allocators.

3 years agodirname: prefer idx_t for some indexes
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
dirname: prefer idx_t for some indexes

* lib/basename.c (base_name):
Prefer idx_t to size_t for indexes, and use idx_t-related allocators.
* lib/basename.c: Do not include xstrndup.h.
(basename): Simplify by always using memcpy.
* modules/dirname (Depends-on): Removbe xstrndup.

3 years agoxalloc: new idx_t-based allocators
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
xalloc: new idx_t-based allocators

This is for code that prefers to use idx_t for sizes.
* lib/xalloc.h (ximalloc, xizalloc, xicalloc, xirealloc)
(xireallocarray, ximemdup, ximemdup0) [GNULIB_XALLOC]:
New decls.
(x2nrealloc): Now just a decl, as the body is moved into xmalloc.c.
* lib/xmalloc.c: Include ialloc.h.
Rename some local parameters to be consistent with the .h files.
(nonnull): New static function.
(xmalloc, xcalloc): Simplify by using nonnull.
(ximalloc, xirealloc, xireallocarray, xizalloc, xicalloc)
(ximemdup, ximemdup0): New functions.
(x2nrealloc): Moved here from xalloc.h.
* modules/xalloc (Depends-on): Add ialloc.

3 years agoialloc: new module
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
ialloc: new module

* lib/ialloc.c, lib/ialloc.h, modules/ialloc: New files.

3 years agoexclude: improve wide-character hashing
Paul Eggert [Sat, 12 Jun 2021 00:18:57 +0000 (17:18 -0700)]
exclude: improve wide-character hashing

* lib/exclude.c (string_hasher_ci): Take the modulo at the end
rather than each time a wide character is retrieved; this should
be more efficient and should hash better.

3 years agoMake message in last commit more precise.
Bruno Haible [Fri, 11 Jun 2021 13:55:33 +0000 (15:55 +0200)]
Make message in last commit more precise.

Suggested by Eric Blake.

* gnulib-tool (func_emit_tests_Makefile_am): Add more precision to
'check-notice' message.

3 years agoClarify where to report test failures from Gnulib tests.
Bruno Haible [Thu, 10 Jun 2021 19:43:59 +0000 (21:43 +0200)]
Clarify where to report test failures from Gnulib tests.

* gnulib-tool (func_emit_tests_Makefile_am): Emit a dependency of
'check-am' on 'check-notice' that prints a notice.

3 years agoClarify that compiler warnings in the Gnulib tests can be ignored.
Bruno Haible [Thu, 10 Jun 2021 19:26:53 +0000 (21:26 +0200)]
Clarify that compiler warnings in the Gnulib tests can be ignored.

* gnulib-tool (func_emit_tests_Makefile_am): Emit overrides for CFLAGS
and CXXFLAGS. Emit a dependency of 'all' on 'all-notice' that prints a
notice.
(func_emit_initmacro_start): Add a second argument. If it is true, emit
code to require gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS.
(func_import, func_create_testdir): All callers updated.
* m4/gnulib-common.m4 (gl_CC_ALLOW_WARNINGS, gl_CXX_ALLOW_WARNINGS): New
macros.

3 years agosigsegv tests: Hide a null pointer from the compiler's optimizations.
Bruno Haible [Wed, 9 Jun 2021 19:34:22 +0000 (21:34 +0200)]
sigsegv tests: Hide a null pointer from the compiler's optimizations.

Patch by Paul Eggert.

* tests/test-sigsegv-catch-stackoverflow2.c
(null_pointer_to_volatile_int): New variable.
(main): Use it.

3 years agoget_ppid_of: Add support for DragonFly BSD.
Bruno Haible [Tue, 8 Jun 2021 01:40:26 +0000 (03:40 +0200)]
get_ppid_of: Add support for DragonFly BSD.

* lib/get_ppid_of.c: Treat DragonFly BSD like FreeBSD.

3 years agosigsegv: Document context type for DragonFly BSD.
Bruno Haible [Tue, 8 Jun 2021 01:22:22 +0000 (03:22 +0200)]
sigsegv: Document context type for DragonFly BSD.

* lib/sigsegv.in.h (stackoverflow_context_t): On DragonFly BSD, it is a
pointer to 'struct sigcontext'.

3 years agodynarray, scratch_buffer: Fix VPATH builds (regression from yesterday).
Bruno Haible [Tue, 8 Jun 2021 00:32:41 +0000 (02:32 +0200)]
dynarray, scratch_buffer: Fix VPATH builds (regression from yesterday).

* modules/dynarray (configure.ac): Invoke AC_PROG_MKDIR_P.
(Makefile.am): Create malloc/ directory before creating
malloc/dynarray.gl.h and malloc/dynarray-skeleton.gl.h.
* modules/scratch_buffer (configure.ac): Invoke AC_PROG_MKDIR_P.
(Makefile.am): Create malloc/ directory before creating
malloc/scratch_buffer.gl.h.

3 years agoptsname_r: Add support for DragonFly BSD 6.0.
Bruno Haible [Mon, 7 Jun 2021 23:27:08 +0000 (01:27 +0200)]
ptsname_r: Add support for DragonFly BSD 6.0.

* lib/ptsname_r.c (__ptsname_r): Add implementation for DragonFly BSD.
* tests/test-ptsname_r.c (main): Treat Dragonfly BSD like Solaris.

3 years agoAvoid some test failures on DragonFly BSD 6.0.
Bruno Haible [Mon, 7 Jun 2021 23:17:02 +0000 (01:17 +0200)]
Avoid some test failures on DragonFly BSD 6.0.

* tests/test-c32isalnum.c (main): On Dragonfly BSD, disable tests that
fail.
* tests/test-c32isalpha.c (main): Likewise.
* tests/test-c32islower.c (main): Likewise.
* tests/test-c32isupper.c (main): Likewise.
* tests/test-ptsname.c (main): Treat Dragonfly BSD like Solaris.

3 years agomountlist: recognize fuse.portal as dummy file system
Kamil Dudka [Mon, 7 Jun 2021 12:43:03 +0000 (14:43 +0200)]
mountlist: recognize fuse.portal as dummy file system

This was originally proposed at:

    https://lists.gnu.org/archive/html/bug-gnulib/2021-02/msg00053.html

As the full review might take some time, would it be possible to apply
at least the part related to fuse.portal file systems?  They started to
cause problems recently:

    https://bugs.launchpad.net/ubuntu/+source/xdg-desktop-portal/+bug/1905623
    https://github.com/muesli/duf/issues/35
    https://bugzilla.redhat.com/1913358

3 years agohost-os: Add support for DragonFly BSD.
Bruno Haible [Mon, 7 Jun 2021 21:46:15 +0000 (23:46 +0200)]
host-os: Add support for DragonFly BSD.

* m4/host-os.m4 (gl_HOST_OS): On DragonFly BSD, set
HOST_OPERATING_SYSTEM to "DragonFly BSD", not "Dragonfly".

3 years agothread: Fix test link error on DragonFly BSD 6.0.
Bruno Haible [Mon, 7 Jun 2021 19:26:31 +0000 (21:26 +0200)]
thread: Fix test link error on DragonFly BSD 6.0.

* lib/glthread/thread.c (gl_thread_create): Moved to here...
* lib/glthread/thread.h (gl_thread_create): ...from here.
(_GLTHREAD_THREAD_INLINE): Remove macro.
Remove _GL_INLINE_HEADER_BEGIN/END invocations.

3 years agosigsegv: Avoid a gcc warning "declaration of 'sig' shadows a parameter".
Bruno Haible [Mon, 7 Jun 2021 02:24:50 +0000 (04:24 +0200)]
sigsegv: Avoid a gcc warning "declaration of 'sig' shadows a parameter".

Reported by Dmitry V. Levin <ldv@altlinux.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-06/msg00018.html>.

* lib/sigsegv.c (sigsegv_handler): Use a different local variable name
than 'sig'.

3 years agoFix comments.
Bruno Haible [Sun, 6 Jun 2021 23:19:05 +0000 (01:19 +0200)]
Fix comments.

3 years agoscratch_buffer: Avoid conflict with prepr. macros owned by the system.
Bruno Haible [Sun, 6 Jun 2021 22:56:50 +0000 (00:56 +0200)]
scratch_buffer: Avoid conflict with prepr. macros owned by the system.

* lib/scratch_buffer.h: Don't include <libc-config.h>. Define
_GL_LIKELY, _GL_UNLIKELY. Include malloc/scratch_buffer.gl.h instead of
malloc/scratch_buffer.h.
* modules/scratch_buffer (Depends-on): Add builtin-expect.
(Makefile.am): Arrange to create malloc/scratch_buffer.gl.h from
malloc/scratch_buffer.h.

3 years agodynarray: Avoid conflict with preprocessor macros owned by the system.
Bruno Haible [Sun, 6 Jun 2021 22:54:25 +0000 (00:54 +0200)]
dynarray: Avoid conflict with preprocessor macros owned by the system.

* lib/dynarray.h: Don't include <libc-config.h>. Define _GL_LIKELY,
_GL_UNLIKELY. Include malloc/dynarray.gl.h instead of malloc/dynarray.h.
Include malloc/dynarray-skeleton.gl.h instead of
malloc/dynarray-skeleton.c.
* modules/dynarray (Depends-on): Add builtin-expect.
(Makefile.am): Arrange to create malloc/dynarray.gl.h from
malloc/dynarray.h and malloc/dynarray-skeleton.gl.h from
malloc/dynarray-skeleton.c.

3 years agoglob-h: Make last patch work with Solaris 10 cc.
Bruno Haible [Sun, 6 Jun 2021 23:18:01 +0000 (01:18 +0200)]
glob-h: Make last patch work with Solaris 10 cc.

* modules/glob-h (Makefile.am): Also transform the '__restrict' macro.

3 years agoglob-h: Avoid conflict with preprocessor macros owned by the system.
Bruno Haible [Sun, 6 Jun 2021 22:34:54 +0000 (00:34 +0200)]
glob-h: Avoid conflict with preprocessor macros owned by the system.

This fixes a compilation error on DragonFly BSD 6.0.

* lib/glob.in.h: Don't include <libc-config.h>. Don't define __USE_GNU.
Include glob-libc.gl.h instead of glob-libc.h.
* modules/glob-h (Makefile.am): Arrange to create glob-libc.gl.h from
glob-libc.h.
* lib/libc-config.h: Add comment.

3 years agoChangeLog: add entries for the last three commits
Dmitry V. Levin [Sun, 6 Jun 2021 08:00:00 +0000 (08:00 +0000)]
ChangeLog: add entries for the last three commits

3 years agoregex-tests: test for regressions fixed by the previous commit
Dmitry V. Levin [Sun, 6 Jun 2021 08:00:00 +0000 (08:00 +0000)]
regex-tests: test for regressions fixed by the previous commit

* tests/test-regex.c (tests): Add test cases for *+ and ** regressions
fixed by the previous commit.

Link: https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00134.html
3 years agoregex: fix match with possessive quantifier
Egor Ignatov [Wed, 26 May 2021 09:08:19 +0000 (12:08 +0300)]
regex: fix match with possessive quantifier

Fix behaviour introduced in 70b673eb7, where regexps with
possessive quantifier("*+") didn't match.

* lib/regexec.c (set_regs): Pop if CUR_NODE has already been checked
only when we have a fail stack.

Fixes: 70b673eb7 ("regex: fix longstanding backref match bug")
Signed-off-by: Egor Ignatov <egori@altlinux.org>
3 years agoregex-tests: remove incorrect comment
Dmitry V. Levin [Sun, 6 Jun 2021 08:00:00 +0000 (08:00 +0000)]
regex-tests: remove incorrect comment

* tests/test-regex.c (tests): Remove the comment saying that some tests
are not used.  That comment was copied along with tests from glibc
where some of these tests are commented out.

Fixes: 70b673eb7 ("regex: fix longstanding backref match bug")
3 years agolib-symbol-visibility: Make configure check work for newer GCC.
Bruno Haible [Sat, 5 Jun 2021 15:07:06 +0000 (17:07 +0200)]
lib-symbol-visibility: Make configure check work for newer GCC.

Reported by Ozkan Sezer <sezeroz@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00117.html>.

* m4/visibility.m4 (gl_VISIBILITY): Add a function definition for each
declaration in the test program.

3 years agovasnprintf: Don't leak memory when memory allocation fails.
Bruno Haible [Sat, 5 Jun 2021 13:44:26 +0000 (15:44 +0200)]
vasnprintf: Don't leak memory when memory allocation fails.

Found by Coverity. Reported by Mike Fabian <mfabian@redhat.com> in
<https://lists.gnu.org/archive/html/bug-libunistring/2021-06/msg00000.html>.

* lib/vasnprintf.c (VASNPRINTF): In places where a local variable points
to heap-allocated storage, free that storage before doing
'goto out_of_memory;'.

3 years agognulib-tool: Stop doing license notice replacements.
Bruno Haible [Fri, 4 Jun 2021 20:27:10 +0000 (22:27 +0200)]
gnulib-tool: Stop doing license notice replacements.

* gnulib-tool: Don't document --more-symlinks and --more-hardlinks any
more.
(do_copyrights): Remove variable.
(func_import): Don't perform license updates on imported files any more.
* pygnulib/GLInfo.py: Don't document --more-symlinks any more.
* doc/gnulib-intro.texi (Copyright): Document the new situation.
* doc/gnulib.texi (Module description): Likewise.
* NEWS: Mention the change.

3 years agogit-merge-changelog: Fix license.
Bruno Haible [Fri, 4 Jun 2021 20:13:43 +0000 (22:13 +0200)]
git-merge-changelog: Fix license.

* modules/git-merge-changelog (License): Change back to GPL.
* lib/git-merge-changelog.c: Use a GPLv3+ notice.

3 years agoPut GPLv3+ notices in source files where appropriate.
Bruno Haible [Fri, 4 Jun 2021 18:55:56 +0000 (20:55 +0200)]
Put GPLv3+ notices in source files where appropriate.

* lib/*.{h,c}: Use GPLv3+ notice whenever the module description says
so.
* build-aux/pmccabe.css: Likewise.

3 years agoPut LGPLv3+ notices in source files where appropriate.
Bruno Haible [Fri, 4 Jun 2021 18:55:53 +0000 (20:55 +0200)]
Put LGPLv3+ notices in source files where appropriate.

* lib/**.{h,c}: Use LGPLv3+ notice whenever the module description says
so.

3 years agoPut "LGPLv3+ or GPLv2+" notices in source files where appropriate.
Bruno Haible [Fri, 4 Jun 2021 18:55:49 +0000 (20:55 +0200)]
Put "LGPLv3+ or GPLv2+" notices in source files where appropriate.

* lib/**.{h,c,gperf}: Use "LGPLv3+ or GPLv2+" notice whenever the module
description says so.

3 years agoGenerate correct license notices in libunistring files.
Bruno Haible [Fri, 4 Jun 2021 18:55:46 +0000 (20:55 +0200)]
Generate correct license notices in libunistring files.

* lib/gen-uni-tables.c (output_library_license, output_tests_license):
New functions.
(output_predicate, output_category, output_combclass,
output_bidi_category, output_decimal_digit, output_digit,
output_numeric, output_mirror, output_joining_type,
output_joining_group, output_scripts, output_scripts_byname,
output_blocks, output_ident_category, output_lbrk_tables,
output_wbrk_tables, output_gbp_table, output_decomposition_tables,
output_composition_tables, output_simple_mapping, output_casing_rules):
Invoke output_library_license.
(output_predicate_test, output_decimal_digit_test, output_digit_test,
output_numeric_test, output_joining_type_test,
output_joining_group_test, output_gbp_test, output_simple_mapping_test):
Invoke output_tests_license.
* lib/uni*/*.h, lib/uni*/*.gperf: Regenerated.
* tests/uni*/*.h: Likewise.

3 years agoGenerate correct license notices in libunistring files.
Bruno Haible [Fri, 4 Jun 2021 18:55:44 +0000 (20:55 +0200)]
Generate correct license notices in libunistring files.

* lib/uniname/gen-uninames.lisp (main): Emit a copyright and license
notice.
* lib/uniname/uninames.h: Regenerated.

3 years agoPut LGPLv2+ notices in source files where appropriate.
Bruno Haible [Fri, 4 Jun 2021 18:55:41 +0000 (20:55 +0200)]
Put LGPLv2+ notices in source files where appropriate.

* lib/**.{h,c,gperf}: Use LGPLv2+ notice whenever the module description
says so.

3 years agoPut "unlimited" notices in source files where appropriate.
Bruno Haible [Fri, 4 Jun 2021 18:55:39 +0000 (20:55 +0200)]
Put "unlimited" notices in source files where appropriate.

* build-aux/prefix-gnulib-mk: Use "unlimited" notice, since the module
description says so.

3 years agoPut public domain notices in source files where appropriate.
Bruno Haible [Fri, 4 Jun 2021 18:55:35 +0000 (20:55 +0200)]
Put public domain notices in source files where appropriate.

* lib/{alloca.c,atexit.c,memmove.c}: Use public domain notice.

3 years agoRevamp check-copyright script.
Bruno Haible [Fri, 4 Jun 2021 18:49:16 +0000 (20:49 +0200)]
Revamp check-copyright script.

* check-copyright: Search only the first 50 lines of each file.
Recognize 'LGPLv3+ or GPLv2+', 'unlimited', and 'public domain' license
notices. For files that are part of several modules, consider the
weakest among the licenses. Allocate more room for the first output
column.

3 years agognupload, git-merge-changelog: Fix module description.
Bruno Haible [Fri, 4 Jun 2021 18:42:44 +0000 (20:42 +0200)]
gnupload, git-merge-changelog: Fix module description.

* gnulib-tool (func_import, func_create_testdir): Treat
'GPLv2+ build tool' like 'GPLed build tool'.
* pygnulib/GLImport.py (prepare): Likewise.
* modules/gnupload (License): Change to 'GPLv2+ build tool'.
* modules/git-merge-changelog (License): Change to GPLv2+.

3 years agoNew directory with license notices.
Bruno Haible [Fri, 4 Jun 2021 18:03:22 +0000 (20:03 +0200)]
New directory with license notices.

* etc/license-notices/*: New files.

3 years agoreallocarray-tests: port to weird platforms
Paul Eggert [Sun, 30 May 2021 17:04:06 +0000 (10:04 -0700)]
reallocarray-tests: port to weird platforms

* tests/test-reallocarray.c (main): Don’t assume that
PTRDIFF_MAX / 2 + 1 <= SIZE_MAX.  POSIX allows platforms
where this isn’t true, though I don’t know of any examples.

3 years agodfa, etc.: prefer xreallocarray to older name
Paul Eggert [Sun, 30 May 2021 17:02:20 +0000 (10:02 -0700)]
dfa, etc.: prefer xreallocarray to older name

* lib/dfa.c (addtok_mb, realloc_trans_if_necessary, enlist):
* lib/readtokens.c (readtokens):
* tests/uninorm/test-u32-normalize-big.c:
(read_normalization_test_file):
Prefer xreallocarray to the equivalent xnrealloc.
The newer name follows the glibc lead of ‘reallocarray’.

3 years agoWrite 'LGPLv3+ or GPLv2+' instead of 'LGPLv3+ or GPLv2'.
Bruno Haible [Sun, 30 May 2021 12:37:06 +0000 (14:37 +0200)]
Write 'LGPLv3+ or GPLv2+' instead of 'LGPLv3+ or GPLv2'.

* modules/* (License): Change.
* gnulib-tool (func_import, func_create_testdir): Likewise.

3 years ago* stackvma.c: Fix misspelled comment.
Paul Eggert [Sat, 29 May 2021 17:19:30 +0000 (10:19 -0700)]
* stackvma.c: Fix misspelled comment.

3 years agosigsegv: Port to Solaris 11
Paul Eggert [Sat, 29 May 2021 17:14:01 +0000 (10:14 -0700)]
sigsegv: Port to Solaris 11

Problem reported by Kiyoshi KANAZAWA in:
https://lists.gnu.org/r/bug-m4/2021-05/msg00020.html
* lib/stackvma.c (_FILE_OFFSET_BITS): #undef on Solaris and Android.

3 years agoautoupdate
Karl Berry [Tue, 25 May 2021 22:05:09 +0000 (15:05 -0700)]
autoupdate

3 years agoc-stack: Document another restriction.
Bruno Haible [Mon, 24 May 2021 10:32:25 +0000 (12:32 +0200)]
c-stack: Document another restriction.

Triggered by a discussion with Paul Eggert.

* lib/c-stack.h: Mention that ACTION should not use nested functions.

3 years agostdio: Fix compilation error on DragonFly BSD.
Bruno Haible [Sat, 22 May 2021 20:14:28 +0000 (22:14 +0200)]
stdio: Fix compilation error on DragonFly BSD.

* lib/stdio.in.h (fcloseall): Treat DragonFly BSD like FreeBSD.

3 years agogetprogname: port to Tru64
Larkin Nickle [Sat, 22 May 2021 19:17:50 +0000 (12:17 -0700)]
getprogname: port to Tru64

* lib/getprogname.c: Treat __osf__ like __sgi, except
with /proc/123 instead of /proc/pinfo/123.

3 years agosigsegv: don’t assume SIGSTKSZ is a constant
Paul Eggert [Fri, 21 May 2021 21:41:42 +0000 (14:41 -0700)]
sigsegv: don’t assume SIGSTKSZ is a constant

* m4/sigaltstack.m4 (SV_SIGALTSTACK): Don’t attempt to override
SIGSTKSZ.  Instead, use an array that is plenty large, while
checking that it’s large enough.  Also, be consistent about
putting that array in static storage rather than on the stack.
* tests/altstack-util.h (SIGSTKSZ): Don’t define.
(MYSTACK_SIZE): New macro, used consistently instead of SIGSTKSZ.
(mystack_storage, mystack): Now static.
(prepare_alternate_stack) [defined SIGSTKSZ]:
Check that MYSTACK_SIZE is large enough.

3 years agofstatat: doc improvement
Paul Eggert [Thu, 20 May 2021 18:24:52 +0000 (11:24 -0700)]
fstatat: doc improvement

* doc/posix-functions/fstatat.texi (fstatat):
Mention AT_EMPTY_PATH when talking about empty strings.

3 years agoc-stack: Support catching stack overflow on most platforms without libsigsegv.
Bruno Haible [Mon, 17 May 2021 01:36:35 +0000 (03:36 +0200)]
c-stack: Support catching stack overflow on most platforms without libsigsegv.

* lib/c-stack.c: Remove all Solaris-specific code. Include <sigsegv.h>
always.
* m4/c-stack.m4: Remove all Solaris-specific code.
(gl_C_STACK): Test $with_libsigsegv from module 'sigsegv'.
* modules/c-stack (Files): Remove m4/libsigsegv.m4.
(Depends-on): Add sigsegv. Remove havelib, intprops, inttypes, mempcpy,
sigaction, stdbool.

3 years agosigsegv, c-stack: Avoid compilation error with glibc >= 2.34.
Bruno Haible [Mon, 17 May 2021 00:13:12 +0000 (02:13 +0200)]
sigsegv, c-stack: Avoid compilation error with glibc >= 2.34.

* lib/sigsegv.in.h (SIGSTKSZ): On glibc systems, redefine to a suitable
constant.
* m4/sigaltstack.m4 (SV_SIGALTSTACK): Likewise.
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Likewise.

3 years agosigsegv: Add tests.
Bruno Haible [Sun, 16 May 2021 16:29:48 +0000 (18:29 +0200)]
sigsegv: Add tests.

* tests/test-sigsegv-catch-segv1.c: New file, from GNU libsigsegv with
modifications.
* tests/test-sigsegv-catch-segv2.c: Likewise.
* tests/test-sigsegv-catch-stackoverflow1.c: Likewise.
* tests/test-sigsegv-catch-stackoverflow2.c: Likewise.
* tests/altstack-util.h: Likewise.
* tests/mmap-anon-util.h: Likewise.
* modules/sigsegv-tests: New file.

3 years agosigsegv: New module.
Bruno Haible [Sun, 16 May 2021 13:20:12 +0000 (15:20 +0200)]
sigsegv: New module.

* lib/sigsegv.in.h: New file, from GNU libsigsegv with modifications.
* lib/sigsegv.c: Likewise.
* lib/stackvma.h: Likewise.
* lib/stackvma.c: Likewise.
* m4/sigaltstack.m4: Likewise.
* m4/stack-direction.m4: Likewise.
* modules/sigsegv: New file.

3 years agorealloc-gnu: avoid glibc MALLOC_CHECK_ issue
Pádraig Brady [Sat, 15 May 2021 16:50:33 +0000 (17:50 +0100)]
realloc-gnu: avoid glibc MALLOC_CHECK_ issue

* tests/test-realloc-gnu.c (main): if MALLOC_CHECK_ env var
is set then don't check ENOMEM is returned from realloc().
See https://sourceware.org/bugzilla/show_bug.cgi?id=27870
Note it doesn't suffice to unsetenv() this var within the program,
as the hooks have already been set up at that stage.

3 years agoc-stack: work around Solaris 11 bugs
Paul Eggert [Sat, 15 May 2021 05:48:20 +0000 (22:48 -0700)]
c-stack: work around Solaris 11 bugs

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2021-05/msg00062.html
* lib/c-stack.c: Always include sigsegv.h if HAVE_LIBSIGSEGV.
(USE_LIBSIGSEGV): Do not use libsigsegv if the kernel
has the si_addr bug and libsigsegv is too old to work
around it.
(segv_handler) [!USE_LIBSIGSEGV]: Do not trust si_addr
if BOGUS_SI_ADDR_UPON_STACK_OVERFLOW.
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC):
Define BOGUS_SI_ADDR_UPON_STACK_OVERFLOW on Solaris 2.11 SPARC.
And do not define HAVE_XSI_STACK_OVERFLOW_HEURISTIC.

3 years agofcntl tests: Avoid failure in MacPorts.
Bruno Haible [Fri, 14 May 2021 21:50:52 +0000 (23:50 +0200)]
fcntl tests: Avoid failure in MacPorts.

Reported by Nicholas Gaya <nicholasgaya@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00014.html>.

* tests/test-fcntl.c (main): Close fd 10 before assuming that it is
closed.
* tests/test-execute-main.c: Update comment.

3 years agolinked-list-unportable-test: New module.
Bruno Haible [Fri, 14 May 2021 21:32:08 +0000 (23:32 +0200)]
linked-list-unportable-test: New module.

* modules/linked-list-unportable-tests: New file, based on
modules/linked-list-tests.
* modules/linked-list-tests: Remove the unportable tests from here.
Depend on linked-list-unportable-tests.

3 years agovalgrind-tests: Doc fix and introduce AM_VALGRINDFLAGS.
Simon Josefsson [Fri, 14 May 2021 17:23:23 +0000 (19:23 +0200)]
valgrind-tests: Doc fix and introduce AM_VALGRINDFLAGS.

* doc/valgrind-tests.texi (Using valgrind automatically): Clarify
when the parallel vs serial test harness is used, suggested by
Bruno Haible <bruno@clisp.org>.
* m4/valgrind-tests.m4: Add VALGRIND_PROGRAM and AM_VALGRINDFLAGS.

3 years agomalloc-gnu, realloc-gnu, calloc-gnu: Ensure errno gets set to ENOMEM.
Bruno Haible [Fri, 14 May 2021 17:04:05 +0000 (19:04 +0200)]
malloc-gnu, realloc-gnu, calloc-gnu: Ensure errno gets set to ENOMEM.

* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): Set gl_cv_func_malloc_posix to
'no' also on Solaris.

3 years agoDEPENDENCIES: Mention the requirement for 'join'.
Bruno Haible [Fri, 14 May 2021 16:05:22 +0000 (18:05 +0200)]
DEPENDENCIES: Mention the requirement for 'join'.

Reported by Simon Josefsson <simon@josefsson.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00047.html>.

* DEPENDENCIES: Mention 'join' among the core POSIX utilities.

3 years ago*alloc-gnu tests: Use ASSERT macro.
Bruno Haible [Fri, 14 May 2021 13:35:24 +0000 (15:35 +0200)]
*alloc-gnu tests: Use ASSERT macro.

* tests/test-malloc-gnu.c: Include "macros.h".
(main): Use ASSERT.
* tests/test-calloc-gnu.c: Include "macros.h".
(main): Use ASSERT.
* tests/test-realloc-gnu.c: Include "macros.h".
(main): Use ASSERT.
* tests/test-reallocarray.c: Include "macros.h".
(main): Use ASSERT.
* modules/malloc-gnu-tests (Files): Add tests/macros.h.
* modules/calloc-gnu-tests (Files): Likewise.
* modules/realloc-gnu-tests (Files): Likewise.
* modules/reallocarray-tests (Files): Likewise.

3 years agovalgrind-tests: Fix 'sh: yes: unknown operand' error.
Simon Josefsson [Fri, 14 May 2021 13:22:02 +0000 (15:22 +0200)]
valgrind-tests: Fix 'sh: yes: unknown operand' error.

* m4/valgrind-tests.m4: Protect variable usage.

3 years agovalgrind-tests: Fix LOG_VALGRIND when valgrind is missing.
Simon Josefsson [Fri, 14 May 2021 13:03:25 +0000 (15:03 +0200)]
valgrind-tests: Fix LOG_VALGRIND when valgrind is missing.

* m4/valgrind-tests.m4: Clear all variables when missing.

3 years agovalgrind-tests: Better option handling.
Simon Josefsson [Fri, 14 May 2021 12:17:20 +0000 (14:17 +0200)]
valgrind-tests: Better option handling.

* m4/valgrind-tests.m4: Support new variables VALGRINDFLAGS and
DEFAULT_VALGRINDFLAGS.
* doc/valgrind-tests.texi (Running self-tests under valgrind): Improve.

3 years agowindows-spawn: Don't assume that UNICODE is not defined.
Markus Mützel [Thu, 6 May 2021 13:20:30 +0000 (15:20 +0200)]
windows-spawn: Don't assume that UNICODE is not defined.

* lib/windows-spawn.h (compose_handles_block): Use type STARTUPINFOA.

3 years agogetrandom: Produce a better error code.
Bruno Haible [Thu, 13 May 2021 19:33:55 +0000 (21:33 +0200)]
getrandom: Produce a better error code.

Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00025.html>.

* lib/getrandom.c (getrandom): When open() fails with an error that does
not indicate the absence of the file, fail with that error code, not
with ENOSYS.

3 years agofstatat: Document a glibc 2.7 bug.
Bruno Haible [Thu, 13 May 2021 19:23:09 +0000 (21:23 +0200)]
fstatat: Document a glibc 2.7 bug.

* doc/posix-functions/fstatat.texi: Document an old glibc 2.7 bug.

3 years agoposix_spawn, posix_spawnp: Fix build error on Minix 3.3.
Bruno Haible [Thu, 13 May 2021 13:48:38 +0000 (15:48 +0200)]
posix_spawn, posix_spawnp: Fix build error on Minix 3.3.

* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): If posix_spawn does not exist
but is declared, set REPLACE_POSIX_SPAWN.
* doc/posix-functions/posix_spawn.texi: Update platforms list.
* doc/posix-functions/posix_spawnp.texi: Likewise.

3 years agoreallocarray tests: Avoid test failure on NetBSD.
Bruno Haible [Thu, 13 May 2021 10:11:04 +0000 (12:11 +0200)]
reallocarray tests: Avoid test failure on NetBSD.

* tests/test-reallocarray.c (main): Accept EOVERFLOW error code.

3 years agognulib-tool: Fail properly if the 'join' program is not found.
Bruno Haible [Wed, 12 May 2021 10:35:21 +0000 (12:35 +0200)]
gnulib-tool: Fail properly if the 'join' program is not found.

Reported by Simon Josefsson <simon@josefsson.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00029.html>.

* gnulib-tool: Bail out early of the 'join' program is not found.

3 years ago{realloc,calloc}-gnu: Fix autoconf macro (regression 2021-04-18).
Bruno Haible [Sun, 9 May 2021 22:59:21 +0000 (00:59 +0200)]
{realloc,calloc}-gnu: Fix autoconf macro (regression 2021-04-18).

* m4/realloc.m4 (gl_FUNC_REALLOC_POSIX): Don't reset REPLACE_REALLOC
to 0 if it is already 1 after gl_FUNC_REALLOC_GNU was executed.
* m4/calloc.m4 (gl_FUNC_CALLOC_POSIX): Don't reset REPLACE_CALLOC
to 0 if it is already 1 after gl_FUNC_CALLOC_GNU was executed.

3 years ago{malloc,realloc,calloc}-gnu: Fix autoconf macro (regression 2021-04-18).
Bruno Haible [Sun, 9 May 2021 20:10:40 +0000 (22:10 +0200)]
{malloc,realloc,calloc}-gnu: Fix autoconf macro (regression 2021-04-18).

* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Don't assume that
_AC_FUNC_MALLOC_IF expands to a single shell statement.
* m4/realloc.m4 (gl_FUNC_REALLOC_GNU): Don't assume that
_AC_FUNC_REALLOC_IF expands to a single shell statement.
* m4/calloc.m4 (gl_FUNC_CALLOC_GNU): Don't assume that
_AC_FUNC_CALLOC_IF expands to a single shell statement.

3 years agomalloc-gnu, realloc-gnu, calloc-gnu: Ensure errno gets set on IRIX.
Bruno Haible [Sun, 9 May 2021 16:36:41 +0000 (18:36 +0200)]
malloc-gnu, realloc-gnu, calloc-gnu: Ensure errno gets set on IRIX.

* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): Require AC_CANONICAL_HOST. Set
gl_cv_func_malloc_posix to 'no' also on IRIX.

3 years agomalloc-gnu, realloc-gnu, calloc-gnu tests: Verify errno is set.
Bruno Haible [Sun, 9 May 2021 16:34:58 +0000 (18:34 +0200)]
malloc-gnu, realloc-gnu, calloc-gnu tests: Verify errno is set.

* tests/test-malloc-gnu.c: Include <errno.h>.
(main): Verify that, when an allocation larger than PTRDIFF_MAX failed,
errno is ENOMEM.
* tests/test-realloc-gnu.c: Likewise.
* tests/test-calloc-gnu.c: Likewise.

3 years agogetrandom: Fail with ENOSYS when the system has no randomness source.
Bruno Haible [Sun, 9 May 2021 14:51:10 +0000 (16:51 +0200)]
getrandom: Fail with ENOSYS when the system has no randomness source.

* lib/getrandom.c (getrandom): When open() fails, set errno to ENOSYS.

3 years agofree tests: Avoid test failure on glibc < 2.15.
Bruno Haible [Sun, 9 May 2021 13:45:03 +0000 (15:45 +0200)]
free tests: Avoid test failure on glibc < 2.15.

* tests/test-free.c (main): Skip the hairy test on glibc < 2.15.

3 years agoFix build error when libintl is installed.
Bruno Haible [Sun, 9 May 2021 02:19:48 +0000 (04:19 +0200)]
Fix build error when libintl is installed.

* modules/posix_spawn_file_actions_addchdir-tests (Makefile.am): Link
test-posix_spawn-chdir with libintl.
* modules/posix_spawn_file_actions_addfchdir-tests (Makefile.am): Link
test-posix_spawn-fchdir with libintl.

4 years agoFix build when an older libunistring is installed (regr. 2020-02-23).
Bruno Haible [Fri, 7 May 2021 10:51:47 +0000 (12:51 +0200)]
Fix build when an older libunistring is installed (regr. 2020-02-23).

* modules/unitypes (configure.ac): Arrange to generate the .h file if
the installed one is from a version < 0.9.11.
* modules/unicase/base (configure.ac): Likewise.
* modules/uniconv/base (configure.ac): Likewise.
* modules/unilbrk/base (configure.ac): Likewise.
* modules/uninorm/base (configure.ac): Likewise.
* modules/unistdio/base (configure.ac): Likewise.
* modules/unistr/base (configure.ac): Likewise.
* modules/uniwbrk/base (configure.ac): Likewise.
* modules/uniwidth/base (configure.ac): Likewise.
* modules/unictype/base (configure.ac): Arrange to generate the .h file
if the installed one is from a version < 0.9.8.
* modules/unigbrk/base (configure.ac): Likewise.

4 years agoautoupdate
Karl Berry [Thu, 6 May 2021 16:09:34 +0000 (09:09 -0700)]
autoupdate

4 years agoimmutable: Fix crash when immmalloc() fails.
Bruno Haible [Fri, 30 Apr 2021 23:13:47 +0000 (01:13 +0200)]
immutable: Fix crash when immmalloc() fails.

Found by GCC 11 '-fanalyzer'.

* lib/immutable.c (immstrdup): Don't crash when immmalloc() fails.

4 years agosupersede: Fix crash when malloc() fails.
Bruno Haible [Fri, 30 Apr 2021 23:03:41 +0000 (01:03 +0200)]
supersede: Fix crash when malloc() fails.

Found by GCC 11 '-fanalyzer'.

* lib/supersede.c (create_temp_file): Don't crash when malloc() fails.

4 years agolibc-config: fix include problem on older Debian
Paul Eggert [Tue, 27 Apr 2021 18:23:28 +0000 (11:23 -0700)]
libc-config: fix include problem on older Debian

https://lists.gnu.org/r/bug-gnulib/2021-04/msg00198.html
* lib/cdefs.h: Use __GNULIB_CDEFS, not __GLIBC__,
to determine whether to include the bits/* files.
* lib/libc-config.h (__WORDSIZE): Remove.
(__GNULIB_CDEFS): New macro.

4 years agognulib-tool: port better to current Autoconf
Paul Eggert [Tue, 27 Apr 2021 06:31:29 +0000 (23:31 -0700)]
gnulib-tool: port better to current Autoconf

* doc/gnulib-tool.texi (Initial import): Don’t mention
AC_PROG_CC_STDC as it’s deprecated in current Autoconf.
* gnulib-tool (func_done_dir): Suggest replacing
AC_PROG_CC_STDC and AC_PROG_CC_C99, as per current Autoconf.

4 years agoreallocarray: a bit more tuning
Paul Eggert [Mon, 26 Apr 2021 06:11:15 +0000 (23:11 -0700)]
reallocarray: a bit more tuning

* lib/reallocarray.c: Include intprops.h.
(reallocarray): Use INT_MULTIPLY_WRAPV instead of
xalloc_oversized, as it now suffices and is likely a bit more
efficient (five fewer machine insns on Ubuntu 20.10 x86-64).
* modules/reallocarray (Depends-on): Depend on intprops, not
xalloc-oversized.  Use conditional dependencies to avoid building
realloc-gnu when not needed.

4 years agoreallocarray: don’t crash if item size is 0
Paul Eggert [Mon, 26 Apr 2021 01:24:42 +0000 (18:24 -0700)]
reallocarray: don’t crash if item size is 0

This problem affects only platforms where xalloc_oversized
divides a number by the size arg.  Fix this by defining
xalloc_oversized (n, s) to work even if s == 0.
* lib/malloca.h, lib/xalloc-oversized.h: Document new behavior.
* lib/xalloc-oversized.h (__xalloc_oversized): Do not crash if S==0.
* tests/test-reallocarray.c (main): Test for the bug.

4 years agoFix messed-up previous patch
Paul Eggert [Sun, 25 Apr 2021 01:17:45 +0000 (18:17 -0700)]
Fix messed-up previous patch

4 years agoxmalloca, etc.: avoid unlikely trap
Paul Eggert [Sun, 25 Apr 2021 01:13:40 +0000 (18:13 -0700)]
xmalloca, etc.: avoid unlikely trap

* lib/xmalloca.h (xnmalloca):
Use size_t, not ptrdiff_t, to avoid implementation-defined
behavior (which could include a trap) if N is 0 and S exceeds
PTRDIFF_MAX.
* lib/xalloc-oversized.h: Adjust comment to match.

4 years agoxmalloca, etc.: fix some xalloc-oversized issues
Paul Eggert [Sun, 25 Apr 2021 00:59:53 +0000 (17:59 -0700)]
xmalloca, etc.: fix some xalloc-oversized issues

* lib/malloca.h (nmalloca):
* lib/xmalloca.h (xnmalloca): Convert S to ptrdiff_t to avoid
arithmetic overflow if N and S are both narrower than ptrdiff_t.
* lib/xalloc-oversized.h (xalloc_oversized):
Don’t say that args must be ptrdiff_t or size_t or wider.
The macro returns the correct answer even when that is not
the case, and it’s the caller’s responsibility to avoid
howlers like (xalloc_oversized (n, s) ? NULL : malloc (n * s))
when N and S are both narrower than ptrdiff_t and size_t.
Add a comment to that effect.
* lib/xmalloca.h: Include xalloc-oversized.h, since this file uses
xalloc_oversized.  Add comments about side effects and avoid
unnecessary parens.
* modules/xmalloca (Depends-on): Add xalloc-oversized.

4 years agoreallocarray: check for ptrdiff_t overflow
Paul Eggert [Sat, 24 Apr 2021 17:45:45 +0000 (10:45 -0700)]
reallocarray: check for ptrdiff_t overflow

* doc/glibc-functions/reallocarray.texi (reallocarray):
Mention ptrdiff_t overflow.
* lib/reallocarray.c (reallocarray): Reindent as per usual GNU.
* lib/stdlib.in.h (reallocarray): Allow reallocarray to be replaced.
* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY):
Check for ptrdiff_t overflow.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Set up REPLACE_REALLOCARRAY.
* modules/reallocarray (Files): Add malloc.m4.
(configure.ac): Also test REPLACE_REALLOCARRAY.
* modules/reallocarray-tests (Depends-on): Add stdint.
* modules/stdlib (stdlib.h): Substitute REPLACE_REALLOCARRAY.
* tests/test-reallocarray.c: Include stdint.h.
(main): Check for ptrdiff_t overflow.