Paul Eggert [Thu, 17 Apr 2025 07:24:27 +0000 (00:24 -0700)]
getlogin-tests: remove xalloc dependency
* modules/getlogin-tests (Depends-on): Remove xalloc.
(test_getlogin_LDADD): Remove @LIBINTL@.
* tests/test-getlogin.c: Do not include xalloc.h.
(main): Use a static rather than heap storage.
Paul Eggert [Thu, 17 Apr 2025 07:22:43 +0000 (00:22 -0700)]
Pacify GCC 15’s new -Wtrailing-whitespace option
* m4/builtin-expect.m4 (gl___BUILTIN_EXPECT):
* m4/iconv.m4 (AM_ICONV_LINK, AM_ICONV):
Avoid whitespace at line end in C code.
* modules/unitypes-h (unitypes_restrict):
Likewise, bearing in mind that configure.ac lines will be indented
so such lines containing only '])' should be avoided when they
generate C code.
Paul Eggert [Thu, 17 Apr 2025 07:13:49 +0000 (00:13 -0700)]
manywarnings: update C warnings for GCC 15
Adjust for C programs compiled by GCC 15.
This is merely changes to commentary; no changes to
the flags passed to GCC.
* build-aux/gcc-warning.spec: Add warnings introduced in GCC 15.
Sort for LC_ALL=C, so that the update procedure is reproducible.
* m4/manywarnings.m4: Specify LC_ALL=C in comment.
Bruno Haible [Wed, 16 Apr 2025 22:09:05 +0000 (00:09 +0200)]
getopt-posix: Avoid trouble due to 'struct rpl_option'.
* lib/getopt.in.h: Arrange for the system's <getopt.h> to define
'struct sys_option' instead of 'struct option'.
* lib/getopt-pfx-ext.h (option): Don't rename to rpl_option.
Paul Eggert [Mon, 14 Apr 2025 22:42:40 +0000 (15:42 -0700)]
regex: remove _REGEX_NELTS
This is a cleanup after the recent fix for undefined behavior.
* lib/regex.h (_REGEX_NELTS): Remove, as it is no longer useful.
All uses removed. Remove no-longer-needed uses of #pragma GCC.
Paul Eggert [Mon, 14 Apr 2025 01:01:08 +0000 (18:01 -0700)]
regex: match current Emacs behavior
* config/srclist.txt: Comment out regex.h, since we now
disagree with glibc.
* lib/regex.h (RE_SYNTAX_EMACS):
Match Emacs 21+ behavior, not Emacs 20-.
* m4/regex.m4 (gl_REGEX): Check for this Emacs fix.
Bruno Haible [Sun, 13 Apr 2025 21:18:10 +0000 (23:18 +0200)]
getlogin_r tests: Avoid writing to a literal string.
* tests/test-getlogin_r.c: Include xalloc.h.
(main): Pass a writable string to putenv().
* modules/getlogin_r-tests (Depends-on): Add xalloc.
(Makefile.am): Link the program with libintl when needed.
Bruno Haible [Sun, 13 Apr 2025 21:17:06 +0000 (23:17 +0200)]
getlogin tests: Avoid writing to a literal string.
* tests/test-getlogin.c: Include xalloc.h.
(main): Pass a writable string to putenv().
* modules/getlogin-tests (Depends-on): Add xalloc.
(Makefile.am): Link the program with libintl when needed.
Bruno Haible [Sun, 13 Apr 2025 15:48:56 +0000 (17:48 +0200)]
vasnprintf tests: Fix compilation error on MSVC (regression yesterday).
* tests/test-vasnprintf-posix2.c (main): Disable the new test on
platforms where the 'long double' value range is insufficient.
* tests/test-vasnwprintf-posix2.c (main): Likewise.
aligned-malloc tests: Simplify a macro definition and improve comment.
Suggested by Bruno Haible.
* tests/test-aligned-malloc.c (ALIGNMENT): Undefine without checking.
Mention that the #undef is for AIX which defines it beforehand in
<sys/socket.h>.
Bruno Haible [Sat, 12 Apr 2025 07:32:43 +0000 (09:32 +0200)]
localeconv tests: Add multithread-safety test.
* tests/test-localeconv-mt.c: New file, based on
tests/test-nl_langinfo-mt.c.
* modules/localeconv-tests (Files): Add it.
(Depends-on): Add setlocale, thread, nanosleep.
(Makefile.am): Arrange to compile and run test-localeconv-mt.
Bruno Haible [Fri, 11 Apr 2025 14:59:24 +0000 (16:59 +0200)]
vasnprintf: Follow glibc's behaviour on glibc systems.
* lib/vasnprintf.c (DCHAR_MBSNLEN): Define fallback.
(VASNPRINTF): Use it on for width handling on glibc.
* modules/vasnprintf (Depends-on): Add mbsnlen.
* modules/c-vasnprintf (Depends-on): Likewise.
Paul Eggert [Mon, 7 Apr 2025 08:45:17 +0000 (01:45 -0700)]
file-has-acl: port symlink code to Cygwin
Problem reported by Corinna Vinschen in:
https://lists.gnu.org/r/bug-gnulib/2025-03/msg00112.html
* lib/file-has-acl.c (acl_get_link_np): New static function,
defined only if needed; include <fcntl.h> if needed for this.
(HAVE_ACL_GET_LINK_NP): Define this if defining acl_get_link_np.
* lib/stdio-impl.h (fp_) [__HAIKU__]: Define to FILE which is an
incomplete type on Haiku.
(_IO_EOF_SEEN) [__HAIKU__]: Define macro.
* lib/fseeko.c (fp_) [!__HAIKU__]: Define to fp.
(fseeko): Use fp_ instead of fp.
Bruno Haible [Wed, 2 Apr 2025 22:45:30 +0000 (00:45 +0200)]
Silence some -Wunterminated-string-initialization warnings.
* lib/base32.c (base32_encode): Mark b32str as not NUL-terminated.
* lib/base64.c (b64c): Mark as not NUL-terminated.
* lib/bcp47.c (struct script): Mark the 'code' field as not
NUL-terminated.
* lib/striconveh.c (mem_cd_iconveh_internal): Mark hex as not
NUL-terminated.
* lib/unicase/special-casing.in.h (struct special_casing_rule): Mark the
'code' field as not NUL-terminated.
Bruno Haible [Mon, 31 Mar 2025 09:30:12 +0000 (11:30 +0200)]
acl, file-has-acl tests: Strengthen tests on Cygwin.
Suggested by Corinna Vinschen in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-03/msg00126.html>.
* tests/test-set-mode-acl.sh: On Cygwin, use group 1 instead of the
non-existent group 0.
* tests/test-copy-acl.sh: Likewise.
* tests/test-file-has-acl.sh: Likewise.
* top/bootstrap-funclib.sh (autogen): Don't pass unnecessary -I's when
invoking autoreconf. The order of M4 include directories is reflected
in Makefile.in content. Our GNUmakefile _version rule invoke
autoreconf without any extra -I, and this difference in how autoreconf
is invoked results in different tarballs for "make dist" vs "make
release" which is undesirable.
Paul Eggert [Tue, 25 Mar 2025 00:00:20 +0000 (17:00 -0700)]
same-inode: don't assume memory objects have ino
* lib/same-inode.h (psame_inode): Do not assume shared and/or
typed memory objects have reliable st_dev and st_ino when given to
stat-like functions, as POSIX does not guarantee this.
I don’t know of any such platforms (QNX perhaps?) but it’s
easy to be safe.
Bruno Haible [Sat, 22 Mar 2025 12:03:43 +0000 (13:03 +0100)]
setlocale-messages: Rename to setlocale-fixes and add Android support.
* lib/setlocale-fixes.h: Renamed from lib/setlocale-messages.h.
(setlocale_fixed, setlocale_fixed_null): New declarations.
* lib/setlocale-fixes.c: Renamed from lib/setlocale-messages.h.
(lc_cat_name): New variable.
(cat_to_index, index_to_cat): New macro.
(lc_all_name): New variable.
(cat_names): New constant.
(fill_lc_all_name, extract_single_name, setlocale_fixed,
setlocale_fixed_null): New functions.
* m4/setlocale.m4 (gl_FUNC_SETLOCALE): Set NEED_SETLOCALE_IMPROVED to 1
on Android.
* lib/setlocale.c: Include setlocale-fixes.h instead of
setlocale-messages.h.
(setlocale_unixlike) [__ANDROID__]: Use setlocale_fixed instead of
setlocale_mtsafe.
(setlocale_improved): On Android, use setlocale_fixed_null instead of
setlocale.
* lib/getlocalename_l-unsafe.c: Include setlocale-fixes.h instead of
setlocale-messages.h.
(getlocalename_l_unsafe): On Android, use setlocale_fixed_null instead
of setlocale_null.
* modules/setlocale-fixes: Renamed from modules/setlocale-messages.
(Files): Update.
(configure.ac): Compile the .c file also on Android.
(Include): Include setlocale-fixes.h instead of setlocale-messages.h.
* modules/setlocale (Depends-on): Add setlocale-fixes. Remove
setlocale-messages.
* modules/getlocalename_l-unsafe (Depends-on): Likewise.
* doc/posix-functions/setlocale.texi: Mention the Android problem.
Bruno Haible [Fri, 21 Mar 2025 15:25:59 +0000 (16:25 +0100)]
getloadavg: Improve Linux and Android support.
* lib/getloadavg.c [__linux__, __ANDROID__]: Include <sys/param.h> and
<sys/sysinfo.h>.
(getloadavg) [__linux__, __ANDROID__]: Use sysinfo() instead of reading
/proc/loadavg.
(LINUX_LDAV_FILE): Remove macro.
Bruno Haible [Fri, 21 Mar 2025 12:15:55 +0000 (13:15 +0100)]
parse-duration: Work around an strtoul() misfeature.
* lib/parse-duration.c (str_const_to_ul): Reject a + or - sign between
the optional whitespace and the digits.
* tests/test-parse-duration.sh: Add some tests with expected failure.
* tests/test-parse-duration.c (main): Fix usage message.
Bruno Haible [Fri, 21 Mar 2025 11:20:24 +0000 (12:20 +0100)]
mountlist: Work around an strtoul() misfeature.
* lib/mountlist.c: Include c-ctype.h.
(dev_from_mount_options): Ignore the dev=... option if its value starts
with whitespace or with a + or - sign.
* modules/mountlist (Depends-on): Add c-ctype.
Bruno Haible [Fri, 21 Mar 2025 10:46:43 +0000 (11:46 +0100)]
mountlist: Replace a configure-time error with a compile-time error.
Reported by Yury V. Zaytsev <yury@shurup.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-03/msg00080.html>.
* m4/mountlist.m4 (gl_MOUNTLIST): Instead of aborting the configuration,
define MOUNTED_NOT_PORTED.
* lib/mountlist.c (read_file_system_list): Err out if MOUNTED_NOT_PORTED
is defined.
* modules/mountlist (configure.ac, Makefile.am): Compile mountlist.c on
all platforms.
Collin Funk [Wed, 19 Mar 2025 04:50:00 +0000 (21:50 -0700)]
futimens: Work around a GNU/Hurd bug.
* m4/futimens.m4 (gl_FUNC_FUTIMENS): Check if futimens validates the
tv_nsec values of the timespec argument. Set bits in a return value
instead of exiting early.
* doc/posix-functions/futimens.texi (futimens): Mention the GNU/Hurd
bug. Mention the same bug occurs on NetBSD 10.
Collin Funk [Wed, 19 Mar 2025 02:58:25 +0000 (19:58 -0700)]
mountlist: Add tests.
* modules/mountlist-tests: New file.
* tests/test-mountlist.c: New file.
* modules/mountlist (Usable-in-testdir): Remove section.
* gnulib-tool.sh (func_create_testdir): Allow mountlist to be used in
testdirs.