1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-04-28 06:33:36 +00:00

7224 Commits

Author SHA1 Message Date
Bruno Haible
4890a0c51a utimens: Use issymlink.
* lib/utimens.c (lutimens): Use issymlink instead of readlink.
* modules/utimens (Depends-on): Remove readlink. Add issymlink.
2025-08-15 00:23:44 +02:00
Bruno Haible
8f61201292 unlinkat: Use issymlinkat.
* lib/unlinkat.c (rpl_unlinkat): Use issymlinkat instead of readlinkat.
* modules/unlinkat (Depends-on): Remove readlinkat. Add issymlinkat.
2025-08-15 00:23:41 +02:00
Bruno Haible
e71bb18ba1 unlink: Use issymlink.
* lib/unlink.c (rpl_unlink): Use issymlink instead of readlink.
* modules/unlink (Depends-on): Remove readlink. Add issymlink.
2025-08-15 00:23:38 +02:00
Bruno Haible
f8b1b1628b renameatu: Use issymlinkat.
* lib/renameatu.c (renameatu): Use issymlinkat instead of readlinkat.
* modules/renameatu (Depends-on): Remove readlinkat. Add issymlinkat.
2025-08-15 00:23:35 +02:00
Bruno Haible
3dbfcbf5ed rename: Use issymlink.
* lib/rename.c (rpl_rename): Use issymlink instead of readlink.
* modules/rename (Depends-on): Remove readlink. Add issymlink.
2025-08-15 00:23:32 +02:00
Bruno Haible
2f0b2ccec3 fchmodat: Use issymlinkat.
* lib/fchmodat.c (fchmodat): Use issymlinkat instead of readlinkat.
* modules/fchmodat (Depends-on): Add issymlinkat, openat.
2025-08-15 00:23:29 +02:00
Bruno Haible
2a98a9ae33 lchmod: Use issymlink, issymlinkat.
* lib/lchmod.c (lchmod): Use issymlink instead of readlink and
issymlinkat instead of readlinkat.
* modules/lchmod (Depends-on): Remove readlink. Add issymlink,
issymlinkat.
2025-08-15 00:23:27 +02:00
Bruno Haible
f478e006d3 lchown: Use issymlink.
* lib/lchown.c (lchown): Use issymlink instead of readlink.
* modules/lchown (Depends-on): Remove readlink. Add issymlink.
2025-08-15 00:23:22 +02:00
Bruno Haible
3cbc197fcf chown: Use issymlink.
* lib/chown.c (rpl_chown): Use issymlink instead of readlink.
* modules/chown (Depends-on): Add issymlink.
2025-08-15 00:23:14 +02:00
Bruno Haible
16db5fb3f0 issymlink, issymlinkat: New modules.
* lib/sys_stat.in.h: Invoke _GL_INLINE_HEADER_BEGIN,
_GL_INLINE_HEADER_END. Include <errno.h>, <unistd.h>.
(_GL_ISSYMLINK_INLINE, _GL_ISSYMLINKAT_INLINE): New macros.
(issymlink, issymlinkat): New declarations.
* lib/unistd.in.h: Do the #include <fcntl.h>, when needed for O_CLOEXEC,
at the end of the file. So that when <fcntl.h> includes <sys/stat.h>,
the declarations of readlink() and readlinkat() on native Windows are
already present.
* lib/issymlink.c: New file.
* lib/issymlinkat.c: New file.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_REQUIRE_DEFAULTS): Initialize
GNULIB_ISSYMLINK, GNULIB_ISSYMLINKAT.
* modules/sys_stat-h (Depends-on): Add extern-inline.
(Makefile.am): Substitute GNULIB_ISSYMLINK, GNULIB_ISSYMLINKAT.
* modules/issymlink: New file.
* modules/issymlinkat: New file.
2025-08-15 00:22:28 +02:00
Paul Eggert
64d97a0660 Prefer readlink to lstat+S_ISLNK when easy
To test for a symlink, use readlink, not lstat+S_ISLNK,
when the lstat is used only for the symlink test.
This avoids EOVERFLOW issues.
* lib/lchown.c (rpl_lchown) [CHOWN_CHANGE_TIME_BUG]:
* lib/rename.c (rpl_rename):
[!(_WIN32 && !__CYGWIN__) && (RENAME_TRAILING_SLASH_SOURCE_BUG
|| RENAME_DEST_EXISTS_BUG || RENAME_HARD_LINK_BUG)]:
* lib/renameatu.c (renameatu):
[HAVE_RENAMEAT && RENAME_TRAILING_SLASH_SOURCE_BUG]:
* lib/unlink.c (rpl_unlink):
* lib/unlinkat.c (rpl_unlinkat):
* lib/utimens.c (lutimens) [!HAVE_LUTIMENS]:
Prefer readlink to lstat+S_ISLNK.
* modules/lchown, modules/rename, modules/unlink, modules/utimens:
(Depends-on): Add readlink.
* modules/unlinkat (Depends-on): Add fstatat, readlinkat.
2025-08-11 18:01:37 -07:00
Bruno Haible
93a89add7d test-framework-sh: Ensure TESTS_ENVIRONMENT gets augmented in gltests/.
* modules/test-framework-sh (Applicability): New section.
2025-08-10 13:40:48 +02:00
Bruno Haible
19b6bc71b0 git-merge-changelog: Remove module.
It is now available through
$ git clone https://git.savannah.gnu.org/git/vc-changelog.git
see https://gitweb.git.savannah.gnu.org/gitweb/?p=vc-changelog.git .

* lib/git-merge-changelog.c: Remove file.
* modules/git-merge-changelog: Remove file.
* NEWS: Mention the change.
2025-08-05 23:20:41 +02:00
Bruno Haible
7e5312beab nlcanon tests: Fix last commit.
* tests/init.sh (setup_): Revert last change.
* modules/test-framework-sh (Makefile.am): Augment TESTS_ENVIRONMENT
here.
* modules/nlcanon-tests (Makefile.am): Don't augment TESTS_ENVIRONMENT
here.
2025-08-05 01:20:58 +02:00
Bruno Haible
c7fd199085 nlcanon: Add tests.
* tests/test-nlcanon.sh: New file.
* modules/nlcanon-tests: New file.
* tests/init.sh (setup_): Adjust also top_builddir, if set.
2025-08-04 13:23:54 +02:00
Bruno Haible
ef6e2fcf72 nlcanon: New module.
* build-aux/nlcanon.sh.in: New file, with a function func_tmpdir taken
from build-aux/csharpexec.sh.in.
* modules/nlcanon: New file.
2025-08-04 12:44:14 +02:00
Paul Eggert
2410984b5b Shorten GCC bug URLs 2025-08-02 10:28:08 -07:00
Paul Eggert
948ba80168 copy-file-range: work around glibc bug 33245
Problem reported by Leah Neukirchen <https://bugs.gnu.org/79139>.
* lib/copy-file-range.c: Include sys-limits.h.
(copy_file_range) [glibc 2.42 and earlier]:
Copy at most SYS_BUFSIZE_MAX bytes.
* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE):
Replace on glibc platforms, as well as on Linux platforms.
* modules/copy-file-range (Files): Add lib/sys-limits.h.
2025-08-01 16:54:42 -07:00
Paul Eggert
626f229915 copy-file-range: tune for more-modern kernels
* lib/copy-file-range.c [__linux__ && HAVE_COPY_FILE_RANGE]:
Include <linux/version.h>.  Include <sys/utsname.h>
only for kernel 5.2 and earlier.
(CHECK_LINUX_KERNEL_VERSION): New macro.
(copy_file_range) [__linux__ && HAVE_COPY_FILE_RANGE]:
Call utsname only when built for kernel 5.2 and earlier.
(copy_file_range) [!__linux__ && HAVE_COPY_FILE_RANGE]:
Use underlying copy_file_range.  This doesn’t change
behavior since the code is not compiled in this case,
but it makes the code a bit cleaner.
* modules/copy-file-range (Depends-on): Add bool.
2025-08-01 16:54:42 -07:00
Bruno Haible
ca5ebe4b57 nstrftime: Handle non-Gregorian calendars the same way on all platforms.
Suggested by Collin Funk.

* modules/nstrftime-limited: New file, based on modules/nstrftime.
* modules/nstrftime (Depends-on): Add nstrftime-limited.
Add localename-unsafe. Remove localename-unsafe-limited.
(configure.ac): Invoke gl_MODULE_INDICATOR.
(Makefile.am): Don't add nstrftime.c to lib_SOURCES; this would conflict
with modules/nstrftime-limited.
(Link): Add $(LIBTHREAD).
* lib/strftime.c (SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME): Don't force
to false if GNULIB_NSTRFTIME is defined.
* modules/nstrftime-tests (Makefile.am): Link test-nstrftime,
test-nstrftime-?? with $(LIBTHREAD).
2025-07-29 22:31:13 +02:00
Bruno Haible
287e6b888a git-merge-changelog: Fix upstream/downstream heuristic for "git pull".
* lib/git-merge-changelog.c: Suggest to pass %Y as 4th parameter.
Include <errno.h>, spawn-pipe.h, wait-process.h, xvasprintf.h,
c-ctype.h.
(_): New macro.
(execute_and_read_line): New function, from lib/javacomp.c.
(is_all_hex_digits): New function.
(long_options): Moved into 'main'.
(usage): Document the --debug option.
(main): Accept a --debug option and turn on debugging at runtime instead
of compile-time. Accept an optional other_conflict_label parameter.
Improve 'downstream' determination using two heuristics.
* modules/git-merge-changelog (Depends-on): Add spawn-pipe,
wait-process, xvasprintf, c-ctype.
2025-07-29 16:28:48 +02:00
Collin Funk
f07c45598e sys_un-h: Make sure that the 'sys' subdirectory is created.
* modules/sys_un-h (Makefile.am): Make the 'sys' subdirectory. Remove
@NMD@ that is not applicable to subdirectories.
2025-07-21 19:04:09 -07:00
Bruno Haible
4393ea5ae8 nstrftime: Add support for non-Gregorian calendars.
* lib/calendars.h: New file.
* lib/calendar-thai.h: New file.
* lib/calendar-persian.h: New file.
* lib/calendar-ethiopian.h: New file.
* lib/strftime.h (nstrftime): Document which directives don't work with
non-Gregorian calendars.
* lib/strftime.c (SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME): New macro.
Include localcharset.h, localename.h, calendars.h.
(CAL_ARGS): New macro.
(my_strftime): Recognize locales with non-Gregorian calendars. Pass cal
and caldate down to __strftime_internal.
(__strftime_internal): Accept additional parameters cal, caldate.
Remove rejection of modifier 'O' for directive 'Y' and allow a non-ASCII
alternate digits base. Produce calendar-aware output for the directives
'b', 'h', 'B', 'x', 'd', 'e', 'm', 'Y'.
* modules/nstrftime (Files): Add the calendar files.
(Depends-on): Add localcharset.
(Link): New section.
* modules/fprintftime (Link): New section.
* tests/test-nstrftime-DE.c: New file.
* tests/test-nstrftime-TH.c: New file.
* tests/test-nstrftime-IR.c: New file.
* tests/test-nstrftime-ET.c: New file.
* modules/nstrftime-tests (Files): Add them.
(Depends-on): Add localcharset, setenv.
(Makefile.am): Link test-nstrftime with $(INTL_MACOSX_LIBS). Arrange to
compile and run test-nstrftime-DE, test-nstrftime-TH, test-nstrftime-IR,
test-nstrftime-ET.
2025-07-15 12:19:54 +02:00
Bruno Haible
d3b2982379 localename-unsafe-limited: Extend to more platforms.
* modules/localename-unsafe-limited (Description): Update platforms
list.
(Files): Add m4/intlmacosx.m4, m4/musl.m4.
(Depends-on): Add localename-environ, strdup, windows-mutex.
(configure.ac): Invoke gl_MUSL_LIBC.
(Link): Add $(INTL_MACOSX_LIBS).
* m4/localename.m4 (gl_LOCALENAME_UNSAFE): Don't require
gl_LOCALE_H_DEFAULTS.
(gl_LOCALENAME_UNSAFE_LIMITED): Require gt_INTL_MACOSX.
2025-07-15 11:12:34 +02:00
Bruno Haible
c95444f726 getlocalename_l-unsafe-limited: Extend to more platforms.
* modules/getlocalename_l-unsafe-limited (Description): Update platforms
list.
(Files): Add m4/intl-thread-locale.m4.
(Depends-on): Add setlocale-fixes.
(configure.ac): Invoke gl_FUNC_GETLOCALENAME_L_UNSAFE and
gl_PREREQ_GETLOCALENAME_L_UNSAFE. Update platforms list.
2025-07-15 10:56:38 +02:00
Bruno Haible
d2dccfd6e0 localename-unsafe: Reduce dependencies.
* lib/localename-unsafe.c: Include windows-mutex.h instead of
glthread/lock.h.
(get_lcid_lock): Change type to glwthread_mutex_t.
(get_lcid): Use glwthread_mutex_* functions.
* modules/localename-unsafe (Depends-on): Add  windows-mutex. Remove
lock.
2025-07-15 10:39:37 +02:00
Paul Eggert
e94aad0ca4 safe-alloc: make obsolete and remove REALLOC_N
Problem reported by Vivien Kraus in:
https://lists.gnu.org/r/bug-gnulib/2025-07/msg00073.html
This module never caught on.
* lib/safe-alloc.h (REALLOC_N): Remove.
* modules/safe-alloc: Now obsolete.
* tests/test-safe-alloc.c (main): Remove REALLOC_N test.
2025-07-13 00:49:59 -07:00
Paul Eggert
6164b4cb08 float-h: work around GCC bug 120993
Also, fix a too-low LDBL_MAX on this platform, a problem that
contributed to LDBL_NORM_MAX test failures with C23 PowerPC GCC
with ibmlongdouble.
* lib/float.c (gl_LDBL_MAX): On PowerPC with ibmlongdouble, the
correct value is 2**1024 - 2**918, not 2**1024 - 2**971.  Also,
use C99 hex double notation for the divisor, as it’s clearer and
should work nowadays.
* lib/float.in.h: Simplify by not worring whether it’s AIX or
GNU/Linux when redefining LDBL_* macros on PowerPC GCC with
ibmlongdouble, as the problem seems to be universal then.
(LDBL_NORM_MAX): On PowerPC GCC with ibmlongdouble, define to be
LDBL_MAX, so that it’s 2**1024 - 2**918, doubling GCC’s value
if supplied.
* modules/float-h-tests (Depends-on): Remove floorl, ldexpl.
Add truncl.
(test_float_h_LDADD): Likewise for libraries.
* tests/test-float-h.c (test_isfinitel): New static function,
so that we need not rely on isfinitel.
(normalize_long_double): Work even if X is negative or not finite.
Do not rely on frexpl or ldexpl.  Use truncl instead of floorl
so that the negative results are consistent with positive.
Defend against fritzy PowerPC long double arithmetic.
2025-07-08 17:39:39 -07:00
Paul Eggert
55a366a06f float-h-tests: port to C23 PowerPC GCC
Problem reported by C. Neidhal
<https://lists.gnu.org/r/bug-gnulib/2025-07/msg00021.html>.
* modules/float-h-tests (Depends-on): Add floorl, frexpl, ldexpl.
(test_float_h_LDADD): Link the resulting libms too.
* tests/test-float-h.c: Include math.h.
(normalize_long_double): New function.
(test_long_double): Use it.
2025-07-06 12:33:42 -07:00
Collin Funk
a5c7974191 pagealign_alloc: Don't assume pointers fit in 'unsigned long'.
* modules/pagealign_alloc (Depends-on): Add stdint-h.
* lib/pagealign_alloc.c: Include stdint.h.
(pagealign_alloc): Cast pointers to 'uintptr_t' instead of 'unsigned
long'.
2025-07-06 10:07:35 -07:00
Bruno Haible
4ed606dd83 options tests: Fix link error.
* modules/options (Link): New section.
* modules/options-tests (Makefile.am): Link test-options and
test-options-prog with LIBINTL.
2025-06-30 11:22:40 +02:00
Bruno Haible
6fcb0ee83f kwset tests: Fix link error.
* modules/kwset-tests (Makefile.am): Link test-kwset with LIBINTL.
2025-06-30 08:45:50 +02:00
Bruno Haible
2140e5c54e options: Add tests.
* tests/test-options.c: New file, based on tests/test-getopt_long.h.
* tests/test-options-prog.c: New file.
* modules/options-tests: New file.
2025-06-27 15:46:55 +02:00
Bruno Haible
0d1077abf9 options: New module.
* lib/options.h: New file.
* lib/options.c: New file.
* modules/options: New file.
* doc/glibc-functions/getopt_long.texi: Mention the new module.
2025-06-27 15:27:24 +02:00
Bruno Haible
84f19f053c kwset: Add tests.
* lib/kwset.c (kwsexec): Correct documentation.
* tests/test-kwset.c: New file.
* modules/kwset-tests: New file.
2025-06-25 15:58:41 +02:00
Bruno Haible
1ff1804ab9 kwset: New module.
* lib/kwset.h: New file, from GNU grep.
* lib/kwset.c: New file, from GNU grep.
Include <limits.h>, minmax.h. Don't include system.h.
(IGNORE_DUPLICATE_BRANCH_WARNING): New macro, from grep/src/system.h.
(NCHAR): New enum value, from grep/src/system.h.
(to_uchar): New function, from grep/src/system.h.
* modules/kwset: New file.
2025-06-25 15:58:36 +02:00
Bruno Haible
c731f33152 file-has-acl tests: Avoid test failure on Cygwin.
* modules/file-has-acl-tests (Makefile.am): Add host_os to the
TESTS_ENVIRONMENT.
* tests/test-file-has-acl-2.sh: On Cygwin, skip this test.
2025-06-09 12:51:14 +02:00
Bruno Haible
730d136ce6 test-xfail: Relicense more permissively.
* modules/test-xfail (License): Change to 'GPLed build tool'.
2025-06-04 23:30:10 +02:00
Bruno Haible
948faa77a5 fts: Update dependencies.
* modules/fts (Depends-on): Add close, dirfd, fstatat, openat. Remove
lstat, open, opendir.
2025-06-03 11:27:26 +02:00
Bruno Haible
073f998968 stdcountof-h: Tweaks.
Reported by Alejandro Colomar <alx@kernel.org>.

* lib/stdcountof.in.h (countof): Parenthesize better.
* modules/stdcountof-h (Description): To appear in C2y, not C23.
2025-06-03 00:48:06 +02:00
Bruno Haible
3b239ab56f stdcountof-h: Add tests.
* tests/test-stdcountof-h.c: New file.
* tests/test-stdcountof-h-c++.cc: New file.
* modules/stdcountof-h-tests: New file.
* modules/stdcountof-h-c++-tests: New file.
2025-06-02 23:44:55 +02:00
Bruno Haible
8617124d25 stdcountof-h: New module.
* lib/stdcountof.in.h: New file.
* m4/stdcountof_h.m4: New file.
* modules/stdcountof-h: New file.
2025-06-02 23:42:17 +02:00
Bruno Haible
df7978ac7f stddef-h: Fix compilation errors in C++ mode (regression 2025-05-27).
* m4/stddef_h.m4 (gl_STDDEF_H): Set and substitute HAVE_C_UNREACHABLE.
Don't test for unreachable in <stddef.h> in C++. Set
GL_GENERATE_STDDEF_H to true always.
* lib/stddef.in.h (gl_unreachable): Renamed from _gl_unreachable. Test
HAVE_C_UNREACHABLE.
(unreachable): Don't define in C++ mode. Don't define if
HAVE_C_UNREACHABLE is 1.
* modules/stddef-h (Makefile.am): Substitute HAVE_C_UNREACHABLE.
* tests/test-stddef-h.c (test_unreachable_optimization,
test_unreachable_noreturn): Don't define in C++ mode.
(test_gl_unreachable_optimization, test_gl_unreachable_noreturn): New
functions.
* tests/test-stddef-h-c++3.cc (test_cxx_unreachable_1): Test
gl_unreachable instead of unreachable.
* lib/error.in.h (__gl_error_call1): Use gl_unreachable instead of
unreachable.
2025-06-02 18:43:34 +02:00
Bruno Haible
c384a44fc2 stat-time tests: Add C++ tests.
* tests/test-stat-time-c++.cc: New file.
* modules/stat-time-c++-tests: New file.
* modules/stat-time-tests (Depends-on): Add stat-time-c++-tests.
2025-06-01 01:10:43 +02:00
Paul Eggert
0a12fa9db0 fcntl-safer-tests: also update this for fifos
* modules/fcntl-safer-tests (Depends-on): Add mkfifo.
(configure.ac) Check for alarm decl.
* tests/test-fcntl-safer.c:
Include sys/stat.h, for mkfifo.
[HAVE_DECL_ALARM]: Include signal.h, for alarm.
2025-05-28 12:32:30 -07:00
Paul Eggert
87555a5961 open, openat: handle O_DIRECTORY on special files
On deficient platforms where we must check for directories
ourselves when opening files, check before opening as well as after.
This prevents a hang when trying to open a special file like a
fifo in a context where a directory is required.  Although there
is still a race so we could still hang in a perverse situation,
it’s the best we can do and it is better than hanging in the
more-common case.
* lib/open.c (lstatif): New static function.
(open) [REPLACE_FCHDIR]: Also inspect O_CREAT.
* lib/open.c (open), lib/openat.c (rpl_openat):
When checking for directories, also do this before opening.
Also, respect O_NOFOLLOW when checking for directories.
* lib/openat.c: Remove a few more unnecessary differences from open.c.
* modules/open (Depends-on): Depend on lstat.
* modules/openat (Depends-on): Add fstatat.
* modules/open-tests, modules/openat-tests:
(configure.ac) Check for alarm decl.
* tests/test-open.c, tests/test-openat.c:
Include sys/stat.h, for mkfifo.
[HAVE_DECL_ALARM]: Include signal.h, for alarm.
* tests/test-open.h (test_open): Fail if test takes too long
because we tried to open a fifo.  Test opening /dev/null,
/dev/tty and a fifo, with a trailing "/" and with O_DIRECTORY.
2025-05-28 10:41:49 -07:00
Bruno Haible
d19a73d049 stddef-h: Make 'unreachable' usable in C++ mode.
Reported by Pierre Ossman <ossman@cendio.se>
at <https://savannah.gnu.org/bugs/?67152>.

* m4/stddef_h.m4 (gl_STDDEF_H): Also test whether unreachable is defined
by <stddef.h> in C++ mode.
* lib/stddef.in.h: In C++ mode, include <utility> and either import
'unreachable' from the std namespace or define it as an inline function.
* tests/test-stddef-h.c: Disable some tests in C++ mode.
* tests/test-stddef-h-c++.cc: Perform nearly the same tests in C++ mode
as in C mode.
* tests/test-stddef-h-c++2.cc: Rename some variables. Disable the NULL
test with clang on Windows.
* tests/test-stddef-h-c++3.cc: New file.
* modules/stddef-h-c++-tests (Files): Include it.
(Makefile.am): Link test-stddef-h-c++ with test-stddef-h-c++3.o.
2025-05-28 01:59:05 +02:00
Bruno Haible
e08dafdf04 selinux-h: Fix error with MSVC.
* lib/se-selinux.in.h: Add comment.
* modules/selinux-h (Depends-on): Add sys_types-h.
2025-05-25 21:21:32 +02:00
Collin Funk
e331531a77 stdckdint-h: Don't generate header if it is not needed.
Suggested by Paul Eggert in:
<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00216.html>.

* m4/stdckdint_h.m4: New file.
* modules/stdckdint-h (Files): Add m4/stdckdint_h.m4.
(configure.ac): Remove checks and just invoke gl_STDCKDINT_H.
(Makefile.am): Replace variables set by ./configure.
* lib/stdckdint.in.h: Include the compilers header if it exists.  Add
comment mentioning expected future standardization in C++26.
(ckd_add, ckd_sub, ckd_mul): Only define if the compilers definitions do
not work.
2025-05-22 19:33:05 -07:00
Collin Funk
7ee6e40b67 stdckdint-h: Work around missing declarations with g++ 15.0.
* modules/stdckdint-h (configure.ac): Generate the header if the system
has one and C++ is being used.
2025-05-19 21:29:03 -07:00