Bruno Haible [Tue, 3 Oct 2023 13:59:57 +0000 (15:59 +0200)]
access: Work around trailing slash bug on Mac OS X 10.5.
* m4/access.m4 (gl_FUNC_ACCESS): Test whether access honors a trailing
slash. Set REPLACE_ACCESS to 1 and define ACCESS_TRAILING_SLASH_BUG if
not.
* lib/access.c (access): Add an implementation for Unix-like platforms.
* tests/test-access.c (main): Test for result if the argument has a
trailing slash.
* modules/access-tests (Depends-on): Add 'symlink'.
* doc/posix-functions/access.texi: Mention the Mac OS X bug.
Bruno Haible [Tue, 3 Oct 2023 08:51:06 +0000 (10:51 +0200)]
string-c++-tests, uchar-c++-tests: Fix link errors on Mac OS X.
* modules/string-c++-tests (Makefile.am): Link test-string-c++ with
$(LIBC32CONV).
* modules/uchar-c++-tests (Makefile.am): Link test-uchar-c++ with
$(LIBC32CONV).
Paul Eggert [Sun, 1 Oct 2023 01:03:48 +0000 (18:03 -0700)]
regex-quote: fix recently-introduced typo
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2023-09/msg00146.html
* lib/regex-quote.c (regex_quote_copy): Add missing #endif.
Bruno Haible [Sat, 30 Sep 2023 14:15:44 +0000 (16:15 +0200)]
getcwd-lgpl: Tweaks.
* lib/unistd.in.h (getcwd): Mention the module 'getcwd-lgpl'.
* lib/getcwd-lgpl.c (rpl_getcwd): Minimize scope of local variables.
* tests/test-getcwd-lgpl.c (main): Use GNU coding style.
KO Myung-Hun [Mon, 25 Sep 2023 14:38:28 +0000 (23:38 +0900)]
fdopendir: Use Windows code path on OS/2 kLIBC
* lib/closedir.c (closedir): Use Windows code path.
* lib/dirent.in.h (_gl_register_dirp_fd, _gl_unregister_dirp_fd):
Remove.
* lib/dirfd.c (_gl_register_dirp_fd, _gl_unregister_dirp_fd): Remove.
(dirfd): Use Windows code path.
* lib/fdopendir.c (fdopendir): Use Windows code path.
* lib/opendir.c (opendir): Use Windows code path.
* m4/closedir.m4 (REPLACE_CLOSEDIR): Use Windows code path.
* m4/dirent_h.m4 (DIR_HAS_FD_MEMBER): Use Windows code path.
* m4/dirfd.m4 (REPLACE_DIRFD): Use Windows code path.
* m4/fchdir.m4 (HAVE_FCHDIR): Replace fchdir() if dirfd() does not work.
* m4/opendir.m4 (REPLACE_OPENDIR): Use Windows code path.
* m4/readdir.m4 (REPLACE_READDIR): Use Windows code path.
* m4/rewinddir.m4 (REPLACE_REWINDDIR): Use Windows code path.
* modules/fchdir (Depends-on): Include dirent always.
Paul Eggert [Tue, 26 Sep 2023 22:49:02 +0000 (15:49 -0700)]
Remaining support for GNULIB_MCEL_PREFER
Support mcel API in remaining modules where this might matter,
for apps that prefer it.
* lib/mbmemcasecmp.c, lib/mbscspn.c, lib/mbsncasecmp.c, lib/mbsnlen.c:
* lib/mbspbrk.c, lib/mbspcasecmp.c, lib/mbssep.c, lib/mbsspn.c:
* lib/regex-quote.c:
Include mcel.h instead of mbiterf.h or mbuiterf.h,
if GNULIB_MCEL_PREFER.
* lib/mbmemcasecmp.c (mbmemcasecmp), lib/mbscspn.c (mbscspn):
* lib/mbsncasecmp.c (mbsncasecmp), lib/mbsnlen.c (mbsnlen):
* lib/mbspbrk.c (mbspbrk), lib/mbspcasecmp.c (mbspcasecmp):
* lib/mbssep.c (mbssep), lib/mbsspn.c (mbsspn):
* lib/regex-quote.c (regex_quote_length, regex_quote_copy):
Use mcel API, if GNULIB_MCEL_PREFER.
* lib/mbscspn.c, lib/mbspbrk.c, lib/mbspcasecmp.c, lib/mbsspn.c:
Include stdlib.h, for MB_CUR_MAX.
* modules/mbmemcasecmp, modules/mbsncasecmp, modules/mbspcasecmp:
Depend on c32tolower.
* modules/regex-quote: Depend on mempcpy.
Paul Eggert [Tue, 26 Sep 2023 06:01:55 +0000 (23:01 -0700)]
mbscasestr: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
This mirrors the recent changes to mbsstr.
* lib/mbscasestr.c [GNULIB_MCEL_PREFER]: Include mcel.h not mbuiter.h.
(mbchar_t, mb_equal) [GNULIB_MCEL_PREFER]: New type and function,
to make it easier to use common code.
(knuth_morris_pratt_multibyte): Don't assume mbchar_t's alignment
is at least that of size_t.
(knuth_morris_pratt_multibyte, mbscasestr) [GNULIB_MCEL_PREFER]:
Use mcel API.
* modules/mbscasestr (Depends-on): Add alignasof.
* top/maint.mk (sc_readme_link_install): Change the value of the
variable in_vc_files to contain a pattern for the README file.
(sc_readme_link_copying): Likewise.
Previously, the above rules always passed, because the generated
list of files was empty. Bug introduced when adding the rules
in commit 53b4bf3018.
Paul Eggert [Thu, 21 Sep 2023 19:46:52 +0000 (12:46 -0700)]
mbschr, mbsrchr: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
* lib/mbschr.c, lib/mbsrchr.c: Include stdlib.h, for MB_CUR_MAX.
[GNULIB_MCEL_PREFER]: Include mcel.h instead of mbuiterf.h.
(mbschr, mbsrchr) [GNULIB_MCEL_PREFER]: Use mcel API.
Paul Eggert [Thu, 21 Sep 2023 21:26:24 +0000 (14:26 -0700)]
gnulib-common: don’t suppress -Wpedantic
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/bug-gnulib/2023-09/msg00130.html
* m4/gnulib-common.m4 (_GL_HAVE___HAS_C_ATTRIBUTE): New macro.
Use it instead of ‘defined __has_c_attribute’.
Bruno Haible [Sat, 16 Sep 2023 09:28:23 +0000 (11:28 +0200)]
lib-symbol-visibility: Fix a misnomer.
* doc/lib-symbol-visibility.texi: Rename LIBFOO_DLL_EXPORTED to
LIBFOO_SHLIB_EXPORTED. Prefer the term "shared library", since the term
"DLL" applies only to Windows.
* lib/relocatable.h (RELOCATABLE_SHLIB_EXPORTED): Renamed from
RELOCATABLE_DLL_EXPORTED. Prefer the term "shared library", since the
term "DLL" applies only to Windows.
* lib/mbtowc-lock.c (SHLIB_EXPORTED): Renamed from DLL_EXPORTED.
* lib/nl_langinfo-lock.c (SHLIB_EXPORTED): Likewise.
* lib/setlocale-lock.c (SHLIB_EXPORTED): Likewise.
gnu-web-doc-update: fix updating of manual directory
* build-aux/gnu-web-doc-update: Correctly change to the 'manual' directory,
since $tmp is a relative path. This avoids removing files
outside of the 'manual' directory. Broken since commit e979787d.
Paul Eggert [Sun, 10 Sep 2023 00:44:12 +0000 (17:44 -0700)]
propername: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
* lib/propername.c: Include mcel.h, not mbchar.h and mbuiter.h.
(mbsstr_trimmed_wordbounded): Use mcel API.
* modules/propername (Depends-on): Add c32isalnum.
Paul Eggert [Sun, 10 Sep 2023 00:22:19 +0000 (17:22 -0700)]
trim: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
* lib/trim.c: Include mcel.h, not mbchar.h and mbuiterf.h.
(trim2): Use mcel API.
* modules/trim (Depends-on): Add c32isspace.
Paul Eggert [Sun, 10 Sep 2023 00:14:15 +0000 (17:14 -0700)]
mbsstr: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
* lib/mbsstr.c [GNULIB_MCEL_PREFER]: Include mcel.h not mbuiter.h.
(mbchar_t, mb_equal) [GNULIB_MCEL_PREFER]: New type and function,
to make it easier to use common code.
(knuth_morris_pratt_multibyte): Don't assume mbchar_t's alignment
is at least that of size_t.
(knuth_morris_pratt_multibyte, mbsstr) [GNULIB_MCEL_PREFER]:
Use mcel API.
* modules/mbsstr (Depends-on): Add alignasof.
Paul Eggert [Sat, 9 Sep 2023 22:47:27 +0000 (15:47 -0700)]
mbslen: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
* lib/mbslen.c: Include mcel.h instead of mbuiterf.h.
(mbslen): Use mcel API.
Paul Eggert [Sat, 9 Sep 2023 16:53:02 +0000 (09:53 -0700)]
chown: work around symlink issues on odd platforms
Problem reported by Jordi Sanfeliu in:
https://lists.gnu.org/archive/html/bug-gnulib/2023-07/msg00116.html
* lib/chown.c (rpl_chown) [CHOWN_MODIFIES_SYMLINK]:
Do not declare unused locals st, stat_valid.
Redo to just call chown if arg is a symlink.
This induces a race but is perhaps the best we can do easily
on oddball platforms where chown does not follow symlinks.
Paul Eggert [Thu, 7 Sep 2023 21:51:58 +0000 (14:51 -0700)]
mbscasecmp: support GNULIB_MCEL_PREFER
* lib/mbscasecmp.c: Include stdlib.h, since we use MB_CUR_MAX.
Include uchar.h, for c32tolower.
(GNULIB_MCEL_PREFER): Include mcel.h instead of mbuiterf.h.
(mbscasecmp) [GNULIB_MCEL_PREFER]: Use mcel instead of mbuiterf.
* modules/mbscasecmp (Depends-on): Add c32tolower, stdlib, uchar.
Depend on mbuiterf only if not preferring mcel.
Paul Eggert [Thu, 7 Sep 2023 21:51:58 +0000 (14:51 -0700)]
exclude: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
* lib/exclude.c: Include mcel.h instead of mbuiter.h.
(string_hasher_ci): Use mcel_scanz instead of mbui_init,
mbui_avail, mbui_cur, and mbui_advance.
* modules/exclude: Do not depend on mbuiter.
Paul Eggert [Thu, 7 Sep 2023 21:51:56 +0000 (14:51 -0700)]
mcel-bench-tests: new module
* modules/mcel-bench-tests, tests/bench-mcel.c: New files.
* tests/bench-multibyte.h (TEXT_LATIN_ASCII_LINE1)
(TEXT_FRENCH_UTF8_LINE1, TEXT_GREEK_UTF8_LINE1)
(TEXT_CHINESE_UTF8_LINE1): New macros.
(text_random_bytes): New constant.
* tests/bench.h (timing_output): Mark with _GL_UNUSED,
since bench-mcel.c does not use it.
Bruno Haible [Thu, 7 Sep 2023 14:21:25 +0000 (16:21 +0200)]
c-*snprintf: Fix some clang -Wmissing-prototypes warnings.
* lib/c-snprintf.c: Include c-snprintf.h instead of <stdio.h>.
* lib/c-vsnprintf.c: Include c-vsnprintf.h instead of <stdio.h>.
* lib/c-vasnprintf.c: Include c-vasnprintf.h.
Bruno Haible [Thu, 7 Sep 2023 00:20:05 +0000 (02:20 +0200)]
doc: Refine documentation of MSVC support for shared libraries.
* doc/lib-symbol-visibility.texi (Exported Symbols of Shared Libraries):
Recommend to define BUILDING_SHARED as an Autoconf variable. Recommend
to test DLL_EXPORT.
Bruno Haible [Tue, 5 Sep 2023 14:36:11 +0000 (16:36 +0200)]
stdint, *printf: Update doc about MSVC.
* doc/posix-headers/stdint.texi: MSVC 14 has <stdint.h>.
* doc/posix-functions/*printf.texi: Current mingw and MSVC 14 support
the j, t, z size specifiers.
* doc/glibc-functions/obstack_*printf.texi: Likewise.
Bruno Haible [Mon, 4 Sep 2023 19:54:09 +0000 (21:54 +0200)]
Use statement-expressions without warnings, even in strict ISO C mode.
Suggested by Eric Blake <eblake@redhat.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00025.html>.
* lib/error.in.h (__gl_error_call): Use the variant with obvious control
flow also with clang. Use '__extension__' to avoid -Wpedantic warnings.
* lib/math.in.h (gl_signbitf, gl_signbitd, gl_signbitl): Define as
macros even when __STRICT_ANSI__ is defined. But use '__extension__' to
avoid -Wpedantic warnings.
* lib/setenv.c (KNOWN_VALUE): Use '__extension__' to avoid -Wpedantic
warnings.
* lib/xalloc-oversized.h (xalloc_oversized): Use optimized variant even
when __STRICT_ANSI__ is defined. But use '__extension__' to avoid
-Wpedantic warnings.
Paul Eggert [Mon, 4 Sep 2023 01:14:53 +0000 (18:14 -0700)]
same-inode, stat-size: support pointers too
Add functions and macros so that we can test pointers to struct
stat as well as plain struct stat. This lets coreutils deal with
structs that are only partly initialized, without relying on
undefined behavior.
* NEWS: Mention this.
* doc/posix-headers/sys_stat.texi, doc/stat-size.texi:
Mention this and modernize.
* lib/at-func2.c (at_func2):
* lib/fts.c (same_fd):
* lib/rename.c (rpl_rename) [RENAME_HARD_LINK_BUG]:
* lib/same-inode.c: New file.
* lib/same.c (same_nameat):
* lib/term-style-control.c (activate_term_style_controller):
Prefer psame_inode (a, b) to SAME_INODE (*a, *b).
* lib/hash-triple-simple.c (triple_compare_ino_str):
* lib/hash-triple.c (triple_compare):
Prefer PSAME_INODE (a, b) to SAME_INODE (*a, *b).
psame_inode is not suitable since the args are not struct stat *.
* lib/same-inode.h: Check that config.h is included first.
(SAME_INODE_INLINE, PSAME_INODE): New macros.
(SAME_INODE): Reimplement in terms of PSAME_INODE.
(psame_inode): New function.
* lib/stat-size.h (STP_BLKSIZE, STP_NBLOCKS): New macros.
(ST_BLKSIZE, ST_NBLOCKS): Use them.
* lib/term-style-control.c (log_signal_handler_called):
Always define as a function, to pacify -Wunused*.
* modules/canonicalize-lgpl-tests (Files): Add m4/musl.m4.
(Depends-on): Call gl_MUSL_LIBC.
* modules/same-inode (Files): Add same-inode.c.
(Depends-on): Add extern-inline, stdbool.
(lib_SOURCES): New macro.
* tests/test-binary-io.c, tests/test-canonicalize-lgpl.c:
* tests/test-canonicalize.c, tests/test-cloexec.c:
* tests/test-dup-safer.c, tests/test-dup2.c, tests/test-error.c:
* tests/test-fcntl.c, tests/test-fdopendir.c, tests/test-fgetc.c:
* tests/test-fputc.c, tests/test-fread.c, tests/test-fstat.c:
* tests/test-fstatat.c, tests/test-ftruncate.c:
* tests/test-fwrite.c, tests/test-getcwd.c:
* tests/test-getdtablesize.c, tests/test-isblank.c:
* tests/test-linkat.c, tests/test-lock.c, tests/test-lstat.h:
* tests/test-malloc-gnu.c, tests/test-openat.c:
* tests/test-pthread-thread.c, tests/test-pthread_sigmask1.c:
* tests/test-pthread_sigmask2.c, tests/test-ptsname.c:
* tests/test-ptsname_r.c, tests/test-raise.c:
* tests/test-realloc-gnu.c, tests/test-rwlock1.c:
* tests/test-sigprocmask.c, tests/test-snprintf.c:
* tests/test-stat.h, tests/test-term-style-control-hello.c:
* tests/test-term-style-control-yes.c, tests/test-thread_create.c:
* tests/test-unlinkat.c, tests/test-vasnprintf.c:
* tests/test-xalloc-die.c:
Adjust to these changes, and fix some warnings elicited by
-Wall -Wextra that I ran into while testing.
* top/maint.mk (sc_prohibit_stat_st_blocks): Mention STP_NBLOCKS.
Reported by Agostino Sarubbo via Sam James <sam@gentoo.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00000.html>.
* lib/sha1.h: Test the OpenSSL major version before attempting to
include <openssl/configuration.h>.
* lib/sha256.h: Likewise.
* lib/sha512.h: Likewise.
* lib/md5.h: Likewise.
* lib/sm3.h: Likewise.
Paul Eggert [Thu, 31 Aug 2023 01:26:52 +0000 (18:26 -0700)]
readutmp: fix core dump if --enable-systemd
Problem reported by Thorsten Kukuk <https://bugs.gnu.org/65617>.
* lib/readutmp.c (read_utmp_from_systemd):
Don’t assume session_ptr != NULL if num_sessions == 0.
In practice it can be null, and the man page OKs this behavior.
Paul Eggert [Wed, 30 Aug 2023 17:15:09 +0000 (10:15 -0700)]
wchar-single: fix module broken since 2021
Adjust to 2021-03-07 change “Rename GNULIB_WCHAR_SINGLE to
GNULIB_WCHAR_SINGLE_LOCALE”. Apparently nobody noticed that
the module was broken. Perhaps we should obsolete the module?
* modules/wchar-single (GNULIB_WCHAR_SINGLE_LOCALE): Define.