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.
Collin Funk [Wed, 19 Mar 2025 01:37:48 +0000 (18:37 -0700)]
Prefer the __gnu_hurd__ macro over __GNU__.
* lib/get_ppid_of.c: Replace use of __GNU__ with __gnu_hurd__.
* lib/get_progname_of.c: Likewise.
* lib/sigsegv.c: Likewise.
* lib/sigsegv.in.h: Likewise.
* lib/vma-iter.c: Likewise.
* lib/vma-iter.h: Likewise.
* tests/test-ptsname.c: Likewise.
* tests/test-ptsname_r.c: Likewise.
* tests/test-sigsegv-catch-stackoverflow1.c: Likewise.
* tests/test-sigsegv-catch-stackoverflow2.c: Likewise.
* lib/getloadavg.c: Likewise. Adjust conditions and comments to account
for the fact that NeXT defines __GNU__ and not __gnu_hurd__.
Collin Funk [Tue, 18 Mar 2025 04:16:22 +0000 (21:16 -0700)]
utimensat: Work around a GNU/Hurd bug.
* lib/utimensat.c (rpl_utimensat) [__gnu_hurd__]: Check for out of range
tv_nsec values.
* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Likewise. Guess that utimensat
doesn't work on GNU/Hurd.
* doc/posix-functions/utimensat.texi: Mention the bug.
Collin Funk [Thu, 13 Mar 2025 01:55:26 +0000 (18:55 -0700)]
dup3: Fix behavior for equal file descriptors on Haiku.
* lib/dup3.c (dup3) [__HAIKU__]: Set errno to EINVAL and return -1 if
both file descriptors are equal.
* doc/posix-functions/dup3.texi: Document the Haiku bug.
Bruno Haible [Sun, 9 Mar 2025 09:19:20 +0000 (10:19 +0100)]
getlogin_r: Work around musl bug.
* lib/getlogin_r.c (getlogin_r): Add implementation for Linux.
* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Test whether getlogin_r has the
musl bug.
* tests/test-getlogin_r.c (main): Add another test.
* doc/posix-functions/getlogin_r.texi: Mention the workaround.
Bruno Haible [Sat, 1 Mar 2025 14:59:29 +0000 (15:59 +0100)]
package-version: Improve wording in './configure --help'.
Reported by Benno Schulenberg <bensberg@telfort.nl> in
<https://lists.gnu.org/archive/html/bug-gettext/2025-03/msg00000.html>.
* doc/package-version.texi: Recommend a dummy version number named
'package', not 'dummy'.
* m4/init-package-version.m4: Update comments accordingly.
* build-aux/git-version-gen: Likewise.
Bruno Haible [Sat, 22 Feb 2025 17:35:37 +0000 (18:35 +0100)]
getlocalename_l-unsafe-limited: New module.
* modules/getlocalename_l-unsafe-limited: New file.
* modules/getlocalename_l-unsafe (Depends-on): Add
getlocalename_l-unsafe-limited.
(Makefile.am): Don't compile getlocalename_l-unsafe.c if already
compiled as part of module 'getlocalename_l-unsafe-limited'.
Bruno Haible [Sat, 22 Feb 2025 17:11:38 +0000 (18:11 +0100)]
getlocalename_l-unsafe: New module.
* lib/getlocalename_l-unsafe.h: New file, based on
lib/getlocalename_l.c.
* lib/getlocalename_l-unsafe.c: New file.
* lib/getlocalename_l.c: Most code moved to
lib/getlocalename_l-unsafe.c.
(getlocalename_l): Implement based on getlocalename_l_unsafe.
* m4/getlocalename_l.m4 (gl_FUNC_GETLOCALENAME_L_UNSAFE,
gl_PREREQ_GETLOCALENAME_L_UNSAFE): New macros.
(gl_FUNC_GETLOCALENAME_L_SIMPLE): Require
gl_FUNC_GETLOCALENAME_L_UNSAFE.
(gl_PREREQ_GETLOCALENAME_L_SIMPLE): Now empty.
* modules/getlocalename_l-unsafe: New file.
* modules/getlocalename_l-simple (Files): Remove
lib/localename-table.h, lib/localename-table.c,
m4/intl-thread-locale.m4.
(Depends-on): Add getlocalename_l-unsafe. Remove setlocale-messages,
setlocale-null, free-posix.
(Makefile.am): Don't compile localename-table.c.
Bruno Haible [Fri, 21 Feb 2025 10:38:35 +0000 (11:38 +0100)]
host-cpu-c-abi: Improve support for loongarch32.
Reported by <wuruilong@loongson.cn>
in <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1098478>
via Simon Josefsson.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Prepare template for
__loongarch32__ in config.h.
(gl_HOST_CPU_C_ABI_32BIT): Speed up the configure test on loongarch*.
Bruno Haible [Fri, 21 Feb 2025 10:25:51 +0000 (11:25 +0100)]
getlocalename_l-simple: New module.
* lib/locale.in.h (newlocale, duplocale, freelocale): Now enabled by
module 'getlocalename_l-simple'.
(getlocalename_l): New declaration.
* lib/getlocalename_l.c: New file, based on lib/localename-unsafe.c,
with modifications for glibc systems, NetBSD, OpenBSD, Android.
* lib/localename-table.h (LCMIN): New macro.
* lib/struniq.h: Update a comment.
* lib/localename-unsafe.c: Don't define the
LOCALENAME_ENHANCE_LOCALE_FUNCS overrides here. Moved to
lib/getlocalename_l.c.
(gl_locale_name_thread_unsafe): Invoke getlocalename_l. Previous code
moved to lib/getlocalename_l.c.
* m4/intl-thread-locale.m4 (gt_INTL_THREAD_LOCALE_NAME): Improve support
for OpenBSD: Set gt_nameless_locales to yes and
gt_localename_enhances_locale_funcs to yes also when $gt_fake_locales is
yes.
* m4/getlocalename_l.m4: New file, based on m4/localename.m4.
* m4/localename.m4 (gl_LOCALENAME_UNSAFE, gl_LOCALENAME_UNSAFE_LIMITED):
Remove code that was moved to m4/getlocalename_l.m4.
* m4/locale_h.m4 (gl_LOCALE_H): Test whether getlocalename_l is
declared.
(gl_LOCALE_H_REQUIRE_DEFAULTS): Initialize GNULIB_GETLOCALENAME_L.
(gl_LOCALE_H_DEFAULTS): Initialize HAVE_GETLOCALENAME_L.
* modules/locale-h (Makefile.am): Substitute GNULIB_GETLOCALENAME_L,
HAVE_GETLOCALENAME_L.
* modules/getlocalename_l-simple: New file.
* modules/localename-unsafe (Files): Remove lib/localename-table.h,
lib/localename-table.c, lib/struniq.h.
(Depends-on): Add getlocalename_l-simple. Remove bool, flexmember,
free-posix, langinfo-h, thread-optim.
(Makefile.am): Don't compile localename-table.c.
* modules/localename-unsafe-limited (Depends-on): Add
getlocalename_l-simple.
* modules/newlocale (Link): New section.
* modules/duplocale (Link): Link with $(GETLOCALENAME_L_LIB).
* modules/freelocale (Link): New section.
* modules/newlocale-tests (Makefile.am): Link the test program with
$(GETLOCALENAME_L_LIB).
* modules/duplocale-tests (Makefile.am): Likewise.
* modules/freelocale-tests (Makefile.am): Likewise.
* modules/is*_l-tests (Makefile.am): Likewise.
* modules/tolower_l-tests (Makefile.am): Likewise.
* modules/toupper_l-tests (Makefile.am): Likewise.
* modules/strcasecmp_l-tests (Makefile.am): Likewise.
* modules/strncasecmp_l-tests (Makefile.am): Likewise.
* modules/strerror_l-tests (Makefile.am): Likewise.
* doc/posix-functions/getlocalename_l.texi: Mention the new module.
Bruno Haible [Fri, 21 Feb 2025 08:31:12 +0000 (09:31 +0100)]
setlocale-messages: New module.
* lib/setlocale-messages.h: New file.
* lib/setlocale-messages.c: New file, based on lib/setlocale.c.
* modules/setlocale-messages: New file.
* lib/setlocale.c: Include setlocale-messages.h.
(lc_messages_name): Remove variable.
(setlocale_single): Just invoke setlocale_messages.
* modules/setlocale (Depends-on): Add setlocale-messages.
Bruno Haible [Wed, 19 Feb 2025 22:46:37 +0000 (23:46 +0100)]
readutmp: Let callers distinguish LOGINs from USERs.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-02/msg00123.html>.
* lib/readutmp.h (LOGIN_PROCESS, UT_TYPE_LOGIN_PROCESS): New macros.
* lib/readutmp.c (read_utmp_from_systemd): Possibly use LOGIN_PROCESS
instead of USER_PROCESS, depending on the session's class.