Paul Eggert [Wed, 25 Oct 2023 21:14:15 +0000 (14:14 -0700)]
base32: new function isubase32; also, tune.
* lib/base32.c (BASE32_INLINE): Define.
(base32_to_int): Rename from b32 and make it extern. All uses changed.
(uchar_in_range): Remove. All uses removed.
(isbase32, base32_decode_ctx_init):
Move to lib/base32.h and make inline.
* lib/base32.h: Ignore -Wtype-limits, so that we needn’t
worry about uchar_in_range.
(BASE32_INLINE): Define, and use _GL_INLINE_HEADER_BEGIN.
(isubase32): New function, useful as it as a different signature.
(isbase32): Define in terms of isubase32.
* modules/base32 (Depends-on): Add extern-inline.
Paul Eggert [Wed, 25 Oct 2023 21:00:40 +0000 (14:00 -0700)]
base64: new function isubase64; also, tune.
* lib/base64.c (BASE64_INLINE): Define.
(base64_to_int): Rename from b64 and make it extern. All uses changed.
(uchar_in_range): Remove. All uses removed.
(isbase64, base64_decode_ctx_init):
Move to lib/base64.h and make inline.
* lib/base64.h: Ignore -Wtype-limits, so that we needn’t
worry about uchar_in_range.
(BASE64_INLINE): Define, and use _GL_INLINE_HEADER_BEGIN.
(isubase64): New function, useful as it as a different signature.
(isbase64): Define in terms of isubase64.
* modules/base64 (Depends-on): Add extern-inline.
Paul Eggert [Wed, 25 Oct 2023 01:37:37 +0000 (18:37 -0700)]
isnanl-tests, stdio-tests: pacify GCC -Wshadow
* tests/test-isnanl.h (NWORDS): Remove.
(memory_long_double): Do not redefine in an inner scope.
All uses changed to use the snan.h memory_long_double.
* tests/test-stdio.c (NWORDS): Remove.
(memory_long_double): Do not redefine in an inner scope.
The snan.h memory_long_double is fine here.
Bruno Haible [Sun, 15 Oct 2023 21:03:59 +0000 (23:03 +0200)]
pthread-spin: Fix warnings on FreeBSD 5.2.1/i386.
* lib/pthread.in.h (pthread_spinlock_t): Override if <pthread.h> defines
pthread_spinlock_t but we need to approximate spinlocks with mutexes.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): When the pthread_spin_*
functions are declared but don't exist, mark them as REPLACEd.
Bruno Haible [Sun, 15 Oct 2023 20:00:04 +0000 (22:00 +0200)]
pthread-spin: Fix link errors on FreeBSD 5.2.1/i386.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Test not only whether
<pthread.h> defines the pthread_spinlock_t type, but also whether the
function pthread_spin_init is actually defined.
Bruno Haible [Sun, 15 Oct 2023 19:57:26 +0000 (21:57 +0200)]
pthread_mutex_timedlock: Fix link errors on FreeBSD 5.2.1/i386.
* m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK): Test
not only whether pthread_mutex_timedlock is declared, but also whether
it is actually defined.
Bruno Haible [Sun, 15 Oct 2023 17:10:29 +0000 (19:10 +0200)]
lock: Make Autoconf macro more robust.
* m4/pthread_rwlock_rdlock.m4 (gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER):
Require gl_THREADLIB, not gl_THREADLIB_EARLY. Needed to get the value of
LIBMULTITHREAD.
Bruno Haible [Sat, 14 Oct 2023 19:50:49 +0000 (21:50 +0200)]
totalorder*: Fix test failures on SH4.
* lib/snan.h: Update comment.
* lib/totalorderf.c (totalorderf): On sh4, invert bit 22 before
comparing two NaNs.
* lib/totalorder.c (totalorder): On sh4, invert bit 51 before comparing
two NaNs.
* lib/totalorderl.c (totalorderl): On sh4, invert bit 51 or 47 of the
xhi, yhi parts before comparing two NaNs.
Bruno Haible [Sat, 14 Oct 2023 18:48:13 +0000 (20:48 +0200)]
totalorder*: Fix test failures on PA-RISC and MIPS CPUs.
* lib/totalorderf.c (totalorderf): On hppa and mips, invert bit 22
before comparing two NaNs.
* lib/totalorder.c (totalorder): On hppa and mips, invert bit 51 before
comparing two NaNs.
* lib/totalorderl.c: Include <float.h>.
(totalorderl): On hppa and mips, invert bit 51 or 47 of the xhi, yhi
parts before comparing two NaNs.
* modules/totalorderl (Depends-on): Add 'float'.
Bruno Haible [Sat, 14 Oct 2023 18:43:47 +0000 (20:43 +0200)]
totalorder* tests: Test also the signalling NaNs.
* tests/test-totalorder.h: Include signed-snan.h.
(main): Change the array initializer to contain memory_* objects rather
than floating-point numbers. This is needed for i386 and x86_64 CPUs.
* tests/test-totalorder.c (TOTALORDER_TYPE): Use memory_double.
(TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN,
TOTALORDER_NEGATIVE_SNAN): New macros.
* tests/test-totalorderf.c (TOTALORDER_TYPE): Use memory_float.
(TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN,
TOTALORDER_NEGATIVE_SNAN): New macros.
* tests/test-totalorderl.c (TOTALORDER_TYPE): Use memory_long_double.
(TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN,
TOTALORDER_NEGATIVE_SNAN): New macros.
* modules/totalorder-tests (Depends-on): Add signed-snan.
* modules/totalorderf-tests (Depends-on): Likewise.
* modules/totalorderl-tests (Depends-on): Likewise.
Bruno Haible [Sat, 14 Oct 2023 18:43:39 +0000 (20:43 +0200)]
totalorder* tests: Verify also the function signatures.
* tests/test-totalorder.h: New file, based on tests/test-totalorder.c.
* tests/test-totalorder.c: Check the signature. Include
test-totalorder.h for the rest.
* tests/test-totalorderf.c: Include <config.h>, <math.h>. Check the
signature. Include test-totalorder.h instead of test-totalorder.c.
* tests/test-totalorderl.c: Likewise.
* modules/totalorder-tests (Files): Add test-totalorder.h, signature.h.
* modules/totalorderf-tests (Files): Add test-totalorder.h, signature.h.
Remove test-totalorder.c.
* modules/totalorderl-tests (Files): Likewise.
Bruno Haible [Sat, 14 Oct 2023 10:34:25 +0000 (12:34 +0200)]
snan: Fix the value of SNaNl() on i386, x86_64, ia64 CPUs.
* lib/snan.h (construct_SNaNl): On i386, x86_64, ia64 CPUs, invert
bit 62, not bit 63, of the mantissa.
* m4/snan.m4 (gl_SNAN): Require gl_LONG_DOUBLE_VS_DOUBLE.
* modules/snan (Files): Add m4/math_h.m4.
Bruno Haible [Fri, 13 Oct 2023 11:54:58 +0000 (13:54 +0200)]
tests: Make use of signed signalling NaNs.
* tests/test-signbit.c: Include signed-snan.h instead of snan.h.
(test_signbitf): Test positive_SNaNf, negative_SNaNf, instead of only
SNaNf.
(test_signbitd): Test positive_SNaNd, negative_SNaNd, instead of only
SNaNd.
(test_signbitl): Test positive_SNaNl, negative_SNaNl, instead of only
SNaNl.
* tests/test-stdio.c: Include signed-snan.h instead of snan.h.
(main): Test positive_SNaNd, negative_SNaNd, instead of only SNaNd.
Also, test positive_NaNd, negative_NaNd, instead of NaNd.
* modules/signbit-tests (Depends-on): Add signed-snan. Remove snan.
* modules/stdio-tests (Depends-on): Likewise.
Bruno Haible [Fri, 13 Oct 2023 11:46:17 +0000 (13:46 +0200)]
signed-snan: New module.
* lib/snan.h (construct_SNaNf): New function, extracted from SNaNf.
(SNaNf): Use it.
(construct_SNaNd): New function, extracted from SNaNd.
(SNaNd): Use it.
(construct_SNaNl): New function, extracted from SNaNl.
(SNaNl): Use it.
* lib/signed-snan.h: New file.
* modules/signed-snan: New file.
Bruno Haible [Thu, 12 Oct 2023 23:04:27 +0000 (01:04 +0200)]
nan, snan tests: Avoid test failures.
* tests/test-nan-1.c (main): Special handling of arm CPUs with software
floating-point emulation.
* tests/test-snan-1.c (main): Likewise. Disable tests that are known to
fail.
* tests/test-snan-2.c (main): Skip tests that are known to fail.
* modules/snan-tests (Files): Add m4/math_h.m4.
(configure.ac): Require gl_LONG_DOUBLE_VS_DOUBLE.
* m4/math_h.m4 (gl_LONG_DOUBLE_VS_DOUBLE): Mention also NetBSD/sparc32.
Bruno Haible [Thu, 12 Oct 2023 22:41:57 +0000 (00:41 +0200)]
fpe-tracking, fpe-trapping: New modules.
* lib/fpe-trapping.h: New file.
* m4/mathfunc.m4 (gl_MATHFUNC): Handle also the type fp_except_t.
* m4/fpe.m4: New file.
* modules/fpe-tracking: New file.
* modules/fpe-trapping: New file.
Bruno Haible [Thu, 12 Oct 2023 18:59:58 +0000 (20:59 +0200)]
nan: New module.
* lib/nan.h: Renamed from tests/nan.h. Change double-inclusion guard.
* modules/nan: New file.
* modules/*-tests: Depend on this module instead of embedding
tests/nan.h.
Bruno Haible [Wed, 11 Oct 2023 14:43:07 +0000 (16:43 +0200)]
unictype/category-and-not: Add more tests.
Suggested by Arindam Sharma <arindam.sharma@imperial.ac.uk>.
* tests/unictype/test-categ_and_not.c (main): Add two more test cases.
* modules/unictype/category-and-not-tests (Depends-on): Add
unictype/category-Cc.
Bruno Haible [Sun, 8 Oct 2023 07:59:03 +0000 (09:59 +0200)]
isfinite: Work around a bug with 'long double' in glibc 2.5/ia64.
* m4/isfinite.m4 (gl_ISFINITEL_WORKS): Require
gl_LONG_DOUBLE_EXPONENT_LOCATION. Test also another NaN value.
* modules/isfinite (Files): Add m4/exponentl.m4.
* doc/posix-functions/isfinite.texi: Mention also a 'long double'
problem on ia64.
Bruno Haible [Sat, 7 Oct 2023 10:49:15 +0000 (12:49 +0200)]
totalorder*: Fix compilation error on glibc 2.25..2.30.
* m4/totalorder.m4 (gl_FUNC_TOTALORDERF): Test whether <math.h> has an
incompatible declaration of totalorderf, and set REPLACE_TOTALORDERF
to 1 if so.
(gl_FUNC_TOTALORDER): Test whether <math.h> has an incompatible
declaration of totalorder, and set REPLACE_TOTALORDER to 1 if so.
(gl_FUNC_TOTALORDERL): Test whether <math.h> has an incompatible
declaration of totalorderl, and set REPLACE_TOTALORDERL to 1 if so.
Paul Eggert [Thu, 5 Oct 2023 19:19:08 +0000 (12:19 -0700)]
totalorder: speed up configuration
* m4/totalorder.m4 (gl_FUNC_TOTALORDERF, gl_FUNC_TOTALORDER)
(gl_FUNC_TOTALORDERL): Avoid unnecessary call to AC_SEARCH_LIBS,
since the information is already available in shell vars.
Paul Eggert [Thu, 5 Oct 2023 18:43:37 +0000 (11:43 -0700)]
totalorderl: minor porting fixes
* lib/totalorderl.c (LDBL_SIGNBIT_WORD): Define to -1 if not defined.
(totalorderl): Avoid unused local zu by preferring ‘if’ to ‘ifdef’.
Don’t assume sizeof (unsigned long long) == 2 * sizeof (unsigned).
Bruno Haible [Wed, 4 Oct 2023 11:12:53 +0000 (13:12 +0200)]
totalorderl: Optimize.
* modules/totalorderl (Files): Add m4/signbit.m4.
* m4/totalorder.m4 (gl_FUNC_TOTALORDERL): Invoke
gl_LONG_DOUBLE_SIGN_LOCATION.
* lib/totalorderl.c (totalorderl): If LDBL_SIGNBIT_WORD is known,
use it, so that 'bigendian' becomes a constant.
Bruno Haible [Tue, 3 Oct 2023 14:42:59 +0000 (16:42 +0200)]
euidaccess: Add tests.
* tests/test-access.h: New file, extracted from tests/test-access.c.
* tests/test-access.c: Moved most code to tests/test-access.h.
Include test-access.h.
(main): Invoke test_access.
* tests/test-euidaccess.c: New file, based on tests/test-access.c.
* modules/access-tests (Files): Add tests/test-access.h.
* modules/euidaccess-tests: New file, based on modules/access-tests.
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’.