Jim Meyering [Thu, 26 Dec 2019 23:59:11 +0000 (15:59 -0800)]
test-framework-sh: tighten an internal grep regexp
* tests/init.sh (gl_shell_test_script_): Tighten the grep regexp
that helps test for a working printf.
Bruno Haible [Thu, 26 Dec 2019 11:29:20 +0000 (12:29 +0100)]
test-framework-sh: Avoid /bin/sh on AIX 7.2 due to its printf built-in.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/grep-devel/2019-12/msg00020.html>.
Simplification by Jim Meyering.
* tests/init.sh (gl_shell_test_script_): Add a test of printf of an
octal escape sequence in a UTF-8 locale.
Paul Eggert [Thu, 26 Dec 2019 08:50:12 +0000 (00:50 -0800)]
mbrtowc: port better to narrow-wchar_t platforms
* lib/mbrtowc.c (mbrtowc): On platforms like AIX 7.2, where
wchar_t is too narrow to represent all the Unicode characters,
consider a byte sequence for an out-of-wchar_t-range character to
be an encoding error. This fixes grep’s surrogate-pair test
failure on AIX 7.2.
Bruno Haible [Tue, 24 Dec 2019 23:00:44 +0000 (00:00 +0100)]
localcharset: Avoid referencing rpl_setlocale on native Windows.
* lib/localcharset.c (setlocale): Undefine.
Bruno Haible [Tue, 24 Dec 2019 20:27:36 +0000 (21:27 +0100)]
lock tests: Fix link error on HP-UX/hppa (regression from 2019-12-21).
* m4/semaphore.m4: New file.
* modules/lock-tests (Files): Add it.
(configure.ac): Require gl_SEMAPHORE.
(Makefile.am): Link test-lock with $(LIB_SEMAPHORE).
Paul Eggert [Tue, 24 Dec 2019 18:31:42 +0000 (10:31 -0800)]
strptime: fix typo in previous patch
Problem and fix reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00202.html
* lib/strptime.c (day_of_the_week): Fix paren bug.
Bruno Haible [Tue, 24 Dec 2019 16:23:23 +0000 (17:23 +0100)]
setlocale-null: Make it easy to rely on the lock in another library.
* lib/setlocale-lock.c: Do not define anything if OMIT_SETLOCALE_LOCK is
defined.
Paul Eggert [Tue, 24 Dec 2019 07:53:23 +0000 (23:53 -0800)]
strptime: tweak division performance
* lib/strptime.c (day_of_the_week):
Redo with neither ‘%’ nor conditional branches.
Paul Eggert [Tue, 24 Dec 2019 07:48:35 +0000 (23:48 -0800)]
nstrftime: tweak division performance
* lib/nstrftime.c (SHR, tm_diff, __strftime_internal):
Redo with neither ‘%’ nor conditional branches.
Paul Eggert [Tue, 24 Dec 2019 07:47:37 +0000 (23:47 -0800)]
mktime: tweak division performance
* config/srclist.txt: Do not sync mktime.c for now.
* lib/mktime.c (shr, ydhms_diff):
Redo with neither ‘%’ nor conditional branches.
Paul Eggert [Tue, 24 Dec 2019 03:04:50 +0000 (19:04 -0800)]
gethrxtime: improve xtime_sec performance
Performanced analyzed by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00200.html
* lib/xtime.h (xtime_sec): Redo with neither ‘%’ nor conditional
branches.
Bruno Haible [Mon, 23 Dec 2019 07:55:35 +0000 (08:55 +0100)]
setlocale-null: Export the lock function also on non-Windows platforms.
* lib/setlocale-lock.c (DLL_EXPORTED): New macro.
(gl_get_setlocale_null_lock): Declare as DLL_EXPORTED.
* m4/setlocale_null.m4 (gl_PREREQ_SETLOCALE_LOCK): New macro.
* modules/setlocale-null (configure.ac): Invoke it.
(Files): Add m4/visibility.m4.
Paul Eggert [Sun, 22 Dec 2019 20:32:31 +0000 (12:32 -0800)]
gethrxtime: fix rounding bug with negative args
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00192.html
* lib/xtime.h (xtime_sec): Simplify calculation and correct bug
with negative rounding. Common platforms can compute / and % with
a single instruction, so the simplified code should be shorter and
faster on these platforms anyway.
Paul Eggert [Sun, 22 Dec 2019 20:38:22 +0000 (12:38 -0800)]
gethrxtime: remove incorrect overflow detection
This is part of a patch written by Bruno Haible:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00192.html
* lib/xtime.h (xtime_make): Remove attempt to prevent internal
integer overflow, as it didn’t suffice. This reverts the xtime.h
part of 2018-10-12T04:46:09Z!akim.demaille@gmail.com, which I
cannot now see the need for anyway (even in cases where it works),
as the patch is helpful only when the signs of S and NS disagree,
and all callers pass nonnegative values for S and NS.
Instead, add a comment saying args should be nonnegative.
Bruno Haible [Sun, 22 Dec 2019 18:34:41 +0000 (19:34 +0100)]
setlocale-null: Add standalone include file.
* lib/setlocale_null.h: New file, extracted from lib/locale.in.h.
* lib/locale.in.h: Include setlocale_null.h.
(SETLOCALE_NULL_MAX, SETLOCALE_NULL_ALL_MAX, setlocale_null_r,
setlocale_null): Remove declarations.
* lib/setlocale_null.c: Include setlocale_null.h.
* lib/localename.c: Likewise.
* modules/setlocale-null (Files): Add lib/setlocale_null.h.
(Depends-on): Add snippet/arg-nonnull.
(Include): Allow either "setlocale_null.h" or <locale.h>.
Bruno Haible [Sun, 22 Dec 2019 15:55:27 +0000 (16:55 +0100)]
strfmon_l: Fix test failures on FreeBSD and Cygwin.
* m4/strfmon_l.m4 (gl_FUNC_STRFMON_L): Require gt_LOCALE_FR_UTF8. Add an
AC_RUN_IFELSE test.
* modules/strfmon_l (Files): Add locale-fr.m4, codeset.m4.
* doc/posix-functions/strfmon_l.texi: Mention the FreeBSD and Cygwin
problem.
Bruno Haible [Sun, 22 Dec 2019 09:57:00 +0000 (10:57 +0100)]
Prefer lib_SOURCES to unconditional AC_LIBOBJ.
* modules/at-internal: Prefer a lib_SOURCES augmentation to an
unconditional AC_LIBOBJ.
* modules/selinux-at: Likewise.
* modules/xmemdup0: Likewise.
* modules/xstrtoll: Likewise.
Bruno Haible [Sun, 22 Dec 2019 09:21:37 +0000 (10:21 +0100)]
longlong: Mark module obsolete.
* modules/longlong (Status, Notice): New sections.
Bruno Haible [Sun, 22 Dec 2019 09:20:30 +0000 (10:20 +0100)]
stdint: Assume that the compiler supports 'long long'.
* lib/stdint.in.h (int64_t, uint64_t, intmax_t, uintmax_t, INT64_C,
UINT64_C, INTMAX_C, UINTMAX_C): Assume HAVE_LONG_LONG_INT and
HAVE_UNSIGNED_LONG_LONG_INT to be 1.
* m4/stdint.m4 (gl_STDINT_H): Don't require AC_TYPE_LONG_LONG_INT,
AC_TYPE_UNSIGNED_LONG_LONG_INT.
* modules/stdint (Files): Remove longlong.m4.
(Makefile.am): Don't substitute HAVE_LONG_LONG_INT,
HAVE_UNSIGNED_LONG_LONG_INT.
Bruno Haible [Sun, 22 Dec 2019 09:12:54 +0000 (10:12 +0100)]
inttypes-incomplete: Assume that the compiler supports 'long long'.
* lib/inttypes.in.h (_PRI64_PREFIX, _PRIu64_PREFIX, _SCN64_PREFIX,
_SCNu64_PREFIX): Assume HAVE_LONG_LONG_INT and
HAVE_UNSIGNED_LONG_LONG_INT to be 1.
* m4/inttypes.m4 (gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION): Assume
HAVE_LONG_LONG_INT to be 1.
* modules/inttypes-incomplete (Makefile.am): Don't substitute
HAVE_LONG_LONG_INT, HAVE_UNSIGNED_LONG_LONG_INT.
Bruno Haible [Sun, 22 Dec 2019 09:08:36 +0000 (10:08 +0100)]
malloca: Assume that the compiler supports 'long long'.
* lib/malloca.h: Assume HAVE_LONG_LONG_INT to be 1.
* m4/malloca.m4 (gl_MALLOCA): Don't require AC_TYPE_LONG_LONG_INT.
* modules/malloca (Files): Remove longlong.m4.
* modules/relocatable-prog-wrapper (Files): Likewise.
Bruno Haible [Sun, 22 Dec 2019 09:06:04 +0000 (10:06 +0100)]
atoll: Assume that the compiler supports 'long long'.
* m4/atoll.m4 (gl_FUNC_ATOLL): Don't require AC_TYPE_LONG_LONG_INT.
* modules/atoll (Files): Remove longlong.m4.
Bruno Haible [Sun, 22 Dec 2019 09:04:37 +0000 (10:04 +0100)]
strtoll: Assume that the compiler supports 'long long'.
* m4/strtoll.m4 (gl_FUNC_STRTOLL): Don't require AC_TYPE_LONG_LONG_INT.
* modules/strtoll (Files): Remove longlong.m4.
Bruno Haible [Sun, 22 Dec 2019 09:03:30 +0000 (10:03 +0100)]
strtoull: Assume that the compiler supports 'long long'.
* m4/strtoull.m4 (gl_FUNC_STRTOULL): Don't require
AC_TYPE_UNSIGNED_LONG_LONG_INT.
* modules/strtoull (Files): Remove longlong.m4.
Bruno Haible [Sun, 22 Dec 2019 08:59:49 +0000 (09:59 +0100)]
strtoimax, strtoumax: Assume that the compiler supports 'long long'.
* lib/strtoimax.c: Assume HAVE_LONG_LONG_INT and
HAVE_UNSIGNED_LONG_LONG_INT to be 1.
* m4/strtoimax.m4 (gl_PREREQ_STRTOIMAX): Don't require
AC_TYPE_LONG_LONG_INT.
* m4/strtoumax.m4 (gl_PREREQ_STRTOUMAX): Don't require
AC_TYPE_UNSIGNED_LONG_LONG_INT.
* modules/strtoimax (Files): Remove longlong.m4.
* modules/strtoumax (Files): Likewise.
Bruno Haible [Sun, 22 Dec 2019 08:57:17 +0000 (09:57 +0100)]
xstrtoll: Assume that the compiler supports 'long long'.
* lib/xstrtol.h (xstrtoll, xstrtoull): Declare unconditionally.
* modules/xstrtoll (configure.ac): Don't invoke AC_TYPE_LONG_LONG_INT.
Bruno Haible [Sun, 22 Dec 2019 08:55:04 +0000 (09:55 +0100)]
vasnprintf: Assume that the compiler supports 'long long'.
* lib/printf-args.h: Assume HAVE_LONG_LONG_INT to be 1.
* lib/printf-args.c (PRINTF_FETCHARGS): Likewise.
* lib/printf-parse.c (PRINTF_PARSE): Likewise.
* lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Likewise.
* m4/intmax_t.m4 (gl_AC_TYPE_INTMAX_T, gt_AC_TYPE_INTMAX_T): Don't
require AC_TYPE_LONG_LONG_INT.
* m4/vasnprintf.m4 (gl_PREREQ_PRINTF_ARGS, gl_PREREQ_PRINTF_PARSE,
gl_PREREQ_VASNPRINTF): Likewise.
* modules/vasnprintf (Files): Remove longlong.m4.
* modules/c-vasnprintf (Files): Likewise.
* modules/unistdio/u8-vasnprintf (Files): Likewise.
* modules/unistdio/u8-u8-vasnprintf (Files): Likewise.
* modules/unistdio/u16-vasnprintf (Files): Likewise.
* modules/unistdio/u16-u16-vasnprintf (Files): Likewise.
* modules/unistdio/u32-vasnprintf (Files): Likewise.
* modules/unistdio/u32-u32-vasnprintf (Files): Likewise.
* modules/unistdio/ulc-vasnprintf (Files): Likewise.
Bruno Haible [Sun, 22 Dec 2019 08:46:46 +0000 (09:46 +0100)]
gethrxtime: Assume that the compiler supports 'long long'.
* lib/xtime.h (xtime_t): Define to 'long long int' always.
(XTIME_PRECISION): Define to
1000000000 always.
(xtime_make, xtime_sec): Optimize accordingly.
* m4/gethrxtime.m4 (gl_XTIME): Don't require AC_TYPE_LONG_LONG_INT.
* modules/gethrxtime (Files): Remove longlong.m4.
Bruno Haible [Sun, 22 Dec 2019 08:43:25 +0000 (09:43 +0100)]
integer_length*: Assume that the compiler supports 'long long'.
* lib/integer_length.h (integer_length_ll): Declare unconditionally.
* modules/integer_length (Files): Remove longlong.m4.
(configure.ac): Don't require AC_TYPE_UNSIGNED_LONG_LONG_INT.
* modules/integer_length_l (Files): Remove longlong.m4.
(configure.ac): Don't require AC_TYPE_UNSIGNED_LONG_LONG_INT.
* modules/integer_length_ll (Files): Remove longlong.m4.
(configure.ac): Don't require AC_TYPE_UNSIGNED_LONG_LONG_INT.
Bruno Haible [Sun, 22 Dec 2019 08:34:06 +0000 (09:34 +0100)]
count-one-bits: Assume that the compiler supports 'long long'.
* lib/count-one-bits.h (count_one_bits_ll): Define unconditionally.
* m4/count-one-bits.m4: Remove file.
* modules/count-one-bits (Files): Remove it.
(configure.ac): Don't invoke gl_COUNT_ONE_BITS.
* tests/test-count-one-bits.c (main): Test count_one_bits_ll
unconditionally.
Bruno Haible [Sun, 22 Dec 2019 08:33:17 +0000 (09:33 +0100)]
count-trailing-zeros: Assume that the compiler supports 'long long'.
* lib/count-trailing-zeros.h (count_trailing_zeros_ll): Define
unconditionally.
* m4/count-trailing-zeros.m4: Remove file.
* modules/count-trailing-zeros (Files): Remove it.
(configure.ac): Don't invoke gl_COUNT_TRAILING_ZEROS.
* tests/test-count-trailing-zeros.c (main): Test count_trailing_zeros_ll
unconditionally.
Bruno Haible [Sun, 22 Dec 2019 08:32:07 +0000 (09:32 +0100)]
count-leading-zeros: Assume that the compiler supports 'long long'.
* lib/count-leading-zeros.h (count_leading_zeros_ll): Define
unconditionally.
* m4/count-leading-zeros.m4: Remove file.
* modules/count-leading-zeros (Files): Remove it.
(configure.ac): Don't invoke gl_COUNT_LEADING_ZEROS.
* tests/test-count-leading-zeros.c (main): Test count_leading_zeros_ll
unconditionally.
Bruno Haible [Sun, 22 Dec 2019 07:03:24 +0000 (08:03 +0100)]
localcharset: Update support for OpenBSD.
* lib/localcharset.c (alias_table): Map "US-ASCII" to "ASCII".
Bruno Haible [Sat, 21 Dec 2019 17:22:38 +0000 (18:22 +0100)]
pthread_sigmask: Avoid test failure on NetBSD 8.0.
* tests/test-pthread_sigmask2.c (main): Skip the error handling test on
NetBSD.
* doc/posix-functions/pthread_sigmask.texi: Mention the NetBSD problem.
Bruno Haible [Sat, 21 Dec 2019 16:56:26 +0000 (17:56 +0100)]
threadlib: Improve code structure.
* m4/threadlib.m4: Reorder macros. Add comments.
Karl Berry [Sat, 21 Dec 2019 16:46:35 +0000 (08:46 -0800)]
autoupdate
Bruno Haible [Sat, 21 Dec 2019 12:53:31 +0000 (13:53 +0100)]
threadlib: Fix LIBMULTITHREAD on FreeBSD with --enable-threads=isoc.
* m4/threadlib.m4 (gl_STDTHREADLIB_BODY): New macro (some code moved
here from m4/threads.m4).
(gl_THREADLIB_BODY): Don't test whether mtx_lock and cnd_timedwait exist
in libc. Instead, rely on gl_STDTHREADLIB_BODY.
(gl_STDTHREADLIB): New macro.
* m4/threads.m4 (gl_THREADS_H): Require gl_STDTHREADLIB instead of
gl_THREADLIB_BODY and gl_YIELD. Don't set LIBSTDTHREAD here.
Bruno Haible [Sat, 21 Dec 2019 12:36:03 +0000 (13:36 +0100)]
sched_yield: Don't depend on threadlib and yield.
* m4/threadlib.m4 (gl_PTHREADLIB): Document that it sets
LIB_SCHED_YIELD.
(gl_PTHREADLIB_BODY): Set LIB_SCHED_YIELD (code moved here from
m4/yield.m4).
* m4/sched_yield.m4 (gl_FUNC_SCHED_YIELD): Require gl_PTHREADLIB, not
gl_THREADLIB and gl_YIELD.
* m4/yield.m4 (gl_YIELD): Require gl_PTHREADLIB. Determine YIELD_LIB
based on $(LIB_SCHED_YIELD).
* m4/threads.m4 (gl_THREADS_H): Don't require gl_YIELD. Use
$(LIB_SCHED_YIELD), not $(YIELD_LIB).
* modules/sched_yield (Files): Remove yield.m4. Add threadlib.m4.
(Depends-on): Remove threadlib.
(Link): Mention $(LIB_SCHED_YIELD), not $(YIELD_LIB).
* modules/threads-h (Files): Remove m4/yield.m4.
* modules/pthread-cond-tests (Makefile.am): Link the programs against
$(LIB_SCHED_YIELD), not $(YIELD_LIB).
* modules/pthread-mutex-tests (Makefile.am): Likewise.
* modules/pthread-once-tests (Makefile.am): Likewise.
* modules/pthread-rwlock-tests (Makefile.am): Likewise.
* modules/pthread-tss-tests (Makefile.am): Likewise.
Bruno Haible [Sat, 21 Dec 2019 12:16:44 +0000 (13:16 +0100)]
threads-h: Don't depend on threadlib.
* modules/threads-h (configure.ac-early): Invoke gl_ANYTHREADLIB_EARLY,
not gl_THREADLIB_EARLY.
Bruno Haible [Sat, 21 Dec 2019 11:54:51 +0000 (12:54 +0100)]
nl_langinfo tests: Fix link error (regression from 2019-12-18).
* modules/nl_langinfo-tests (Makefile.am): Link also test-nl_langinfo
with $(LIB_SETLOCALE).
Bruno Haible [Sat, 21 Dec 2019 11:51:50 +0000 (12:51 +0100)]
threadlib: Remove unused dependency (left over from 2019-07-06).
* modules/threadlib (Depends-on): Remove havelib.
Bruno Haible [Sat, 21 Dec 2019 06:41:08 +0000 (07:41 +0100)]
New convention for multithread-safety tests.
* tests/test-setlocale_null-mt-one.c: Renamed from
tests/test-setlocale_null-one.c.
* tests/test-setlocale_null-mt-all.c: Renamed from
tests/test-setlocale_null-all.c.
* modules/setlocale-null-tests (Files, Makefile.am): Update.
Bruno Haible [Sat, 21 Dec 2019 06:32:12 +0000 (07:32 +0100)]
quotearg tests: Fix conflict with hard-locale tests.
* tests/testlocale: Renamed from tests/locale.
* modules/quotearg-tests (Files): Update.
* tests/test-quotearg.sh (LOCALEDIR): Likewise.
Bruno Haible [Sat, 21 Dec 2019 05:29:11 +0000 (06:29 +0100)]
pthread-thread, lock: On z/OS, use PTHREAD_RWLOCK_INITIALIZER_NP.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00001.html>
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00167.html>
* lib/pthread.in.h (PTHREAD_RWLOCK_INITIALIZER): Define to
PTHREAD_RWLOCK_INITIALIZER_NP when possible.
* lib/glthread/lock.h: Allow PTHREAD_RWLOCK_INITIALIZER_NP as an
alternative to PTHREAD_RWLOCK_INITIALIZER.
* lib/glthread/lock.c: Likewise.
Bruno Haible [Sat, 21 Dec 2019 04:42:11 +0000 (05:42 +0100)]
memcmp tests: Work around the clang bug.
* tests/test-memcmp.c (main): Use a volatile function pointer to disable
the clang optimization.
Bruno Haible [Fri, 20 Dec 2019 08:17:20 +0000 (09:17 +0100)]
localcharset: Add support for z/OS encoding names.
* lib/localcharset.h: Mention which encodings are used as locale
encodings on z/OS.
Bruno Haible [Fri, 20 Dec 2019 08:12:37 +0000 (09:12 +0100)]
iconv_open: Add support for z/OS encoding names.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00172.html>.
* lib/iconv_open-zos.gperf: New file.
* modules/iconv_open (Files): Add iconv_open-zos.gperf.
(Makefile.am): Add rules for generating iconv_open-zos.h from it.
* lib/iconv_open.c (ICONV_FLAVOR_ZOS): New macro.
* m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN): On z/OS, use ICONV_FLAVOR_ZOS.
* doc/posix-functions/iconv_open.texi: Mention z/OS.
Bruno Haible [Fri, 20 Dec 2019 06:42:28 +0000 (07:42 +0100)]
doc: Document the problem of the per-thread locale functions on z/OS.
* doc/posix-functions/uselocale.texi: Document the z/OS problem.
* doc/posix-functions/newlocale.texi: Likewise.
* doc/posix-functions/duplocale.texi: Likewise.
* doc/posix-functions/freelocale.texi: Likewise.
Bruno Haible [Fri, 20 Dec 2019 06:29:02 +0000 (07:29 +0100)]
localename, gettext: Fix host_os value for z/OS.
* m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Fix host_os value in
cross-configuration code.
Jim Meyering [Fri, 20 Dec 2019 04:17:27 +0000 (20:17 -0800)]
nstrftime: avoid a shadowing warning
* lib/nstrftime.c (libc_hidden_def): Rename inner "i" to "j",
to avoid shadowing an "i" declared hundreds of lines above.
Paul Eggert [Thu, 19 Dec 2019 22:35:59 +0000 (14:35 -0800)]
dfa: struct dfamust now uses flexible array
* lib/dfa.c: Include flexmember.h.
(dfamust, dfamustfree): Adjust to struct dfamust change.
This saves a call to malloc+free.
* lib/dfa.h (struct dfamust): Make the final member a
flexible array member.
* modules/dfa (Depends-on): Add flexmember.
Paul Eggert [Thu, 19 Dec 2019 21:37:45 +0000 (13:37 -0800)]
dfa: fast->small for array elements
* lib/dfa.c (charclass_word): Use uint_least64_t not uint_fast64_t,
since this type is used in arrays. This change is more for
documentation than for any practical effect, since the two types
are the same on all known platforms.
Bruno Haible [Thu, 19 Dec 2019 05:20:30 +0000 (06:20 +0100)]
iconv tests: Test canonicalized, not system-dependent, encoding names.
* modules/iconv-tests (Depends-on): Add iconv_open.
Bruno Haible [Thu, 19 Dec 2019 05:15:56 +0000 (06:15 +0100)]
iconv tests: Test canonicalized, not system-dependent, encoding names.
* tests/test-iconv.c (main): Revert part of the 2016-08-17 patch.
Bruno Haible [Thu, 19 Dec 2019 01:06:00 +0000 (02:06 +0100)]
localename: Fix test failure on AIX 7.2.
* m4/intl-thread-locale.m4 (gt_INTL_THREAD_LOCALE_NAME): Enable nameless
locales on AIX.
* lib/localename.c (gl_locale_name_thread_unsafe): Handle nameless
locales on AIX.
Paul Eggert [Thu, 19 Dec 2019 01:05:02 +0000 (17:05 -0800)]
Improve port of AC_C_RESTRICT to Oracle C++
Problem reported by Christian Biesinger in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00159.html
* m4/gnulib-common.m4 (AC_C_RESTRICT): Port better to
Oracle Developer Studio C++ 12.5 or later.
Bruno Haible [Wed, 18 Dec 2019 18:33:27 +0000 (19:33 +0100)]
wchar: Fix test failures on AIX and MSVC (regression from 2019-12-07).
* lib/wchar.in.h (GNULIB_defined_mbstate_t): Do define on AIX and MSVC.
Bruno Haible [Wed, 18 Dec 2019 16:03:42 +0000 (17:03 +0100)]
localename: Ensure multithread-safety in future changes.
* lib/localename.c (setlocale): Reference the system's setlocale().
(get_locale_t_name): Invoke setlocale_null instead of setlocale.
(gl_locale_name_posix): Likewise.
* modules/localename (Depends-on): Add setlocale-null.
Bruno Haible [Wed, 18 Dec 2019 15:30:09 +0000 (16:30 +0100)]
setlocale-null: Make API more useful.
* lib/locale.in.h (setlocale_null_r): Renamed from setlocale_null. All
callers changed.
(setlocale_null): New declaration.
* lib/setlocale_null.c (setlocale_null_androidfix): New function,
extracted from setlocale_null_unlocked.
(setlocale_null_unlocked): Invoke it.
(setlocale_null_r): Renamed from setlocale_null.
(setlocale_null): New function, extracted from setlocale_mtsafe in
setlocale.c.
* lib/setlocale.c: Don't include <errno.h>.
(setlocale_mtsafe): Invoke setlocale_null.
* lib/setlocale-lock.c: Update comments.
* doc/posix-functions/setlocale.texi: Mention both functions.
Bruno Haible [Wed, 18 Dec 2019 14:07:05 +0000 (15:07 +0100)]
localename: Optimize code for native Windows.
* lib/localename.c (gl_locale_name_posix): Remove handling of LC_ALL
category (not allowed here).
Bruno Haible [Wed, 18 Dec 2019 13:35:27 +0000 (14:35 +0100)]
setlocale: Make calls with NULL argument multithread-safe.
* lib/setlocale.c: Include <errno.h>.
(setlocale_mtsafe): New function.
(setlocale_unixlike): Invoke setlocale_mtsafe instead of setlocale.
(setlocale_improved): Renamed from rpl_setlocale.
* m4/setlocale.m4 (gl_FUNC_SETLOCALE): Require gl_FUNC_SETLOCALE_NULL.
Set and define NEED_SETLOCALE_IMPROVED and NEED_SETLOCALE_MTSAFE. Set
LIB_SETLOCALE.
* modules/setlocale (Depends-on): Add setlocale-null. Update conditions.
(Link): New section.
* tests/locale.c: Undefine setlocale.
* tests/test-setlocale_null-one.c: Likewise.
* tests/test-setlocale_null-all.c: Likewise.
* modules/setlocale-tests (Makefile.am): Link the test programs with
$(LIB_SETLOCALE).
* modules/astrxfrm-tests (Makefile.am): Likewise.
* modules/btowc-tests (Makefile.am): Likewise.
* modules/c-ctype-tests (Makefile.am): Likewise.
* modules/c-snprintf-tests (Makefile.am): Likewise.
* modules/c-strcase-tests (Makefile.am): Likewise.
* modules/c-vasprintf-tests (Makefile.am): Likewise.
* modules/c-vsnprintf-tests (Makefile.am): Likewise.
* modules/c-xvasprintf-tests (Makefile.am): Likewise.
* modules/dfa-tests (Makefile.am): Likewise.
* modules/duplocale-tests (Makefile.am): Likewise.
* modules/hard-locale-tests (Makefile.am): Likewise.
* modules/localcharset-tests (Makefile.am): Likewise.
* modules/localename-tests (Makefile.am): Likewise.
* modules/mbmemcasecmp-tests (Makefile.am): Likewise.
* modules/mbmemcasecoll-tests (Makefile.am): Likewise.
* modules/mbrtowc-tests (Makefile.am): Likewise.
* modules/mbscasecmp-tests (Makefile.am): Likewise.
* modules/mbscasestr-tests (Makefile.am): Likewise.
* modules/mbschr-tests (Makefile.am): Likewise.
* modules/mbscspn-tests (Makefile.am): Likewise.
* modules/mbsinit-tests (Makefile.am): Likewise.
* modules/mbsncasecmp-tests (Makefile.am): Likewise.
* modules/mbsnrtowcs-tests (Makefile.am): Likewise.
* modules/mbspbrk-tests (Makefile.am): Likewise.
* modules/mbspcasecmp-tests (Makefile.am): Likewise.
* modules/mbsrchr-tests (Makefile.am): Likewise.
* modules/mbsrtowcs-tests (Makefile.am): Likewise.
* modules/mbsspn-tests (Makefile.am): Likewise.
* modules/mbsstr-tests (Makefile.am): Likewise.
* modules/nl_langinfo-tests (Makefile.am): Likewise.
* modules/quotearg-tests (Makefile.am): Likewise.
* modules/regex-tests (Makefile.am): Likewise.
* modules/strfmon_l-tests (Makefile.am): Likewise.
* modules/strtod-tests (Makefile.am): Likewise.
* modules/strtold-tests (Makefile.am): Likewise.
* modules/unicase/locale-language-tests (Makefile.am): Likewise.
* modules/unicase/ulc-casecmp-tests (Makefile.am): Likewise.
* modules/unicase/ulc-casecoll-tests (Makefile.am): Likewise.
* modules/unigbrk/ulc-grapheme-breaks-tests (Makefile.am): Likewise.
* modules/unistdio/u8-vasnprintf-tests (Makefile.am): Likewise.
* modules/unistdio/u16-vasnprintf-tests (Makefile.am): Likewise.
* modules/unistdio/u32-vasnprintf-tests (Makefile.am): Likewise.
* modules/unistdio/ulc-vasnprintf-tests (Makefile.am): Likewise.
* modules/uniwbrk/ulc-wordbreaks-tests (Makefile.am): Likewise.
* modules/vasnprintf-posix-tests (Makefile.am): Likewise.
* modules/wcrtomb-tests (Makefile.am): Likewise.
* modules/wcsnrtombs-tests (Makefile.am): Likewise.
* modules/wcsrtombs-tests (Makefile.am): Likewise.
* modules/wcwidth-tests (Makefile.am): Likewise.
* doc/posix-functions/setlocale.texi: Mention that the multithread-
safety fix is also available in module 'setlocale'.
Bruno Haible [Wed, 18 Dec 2019 10:42:21 +0000 (11:42 +0100)]
hard-locale: Make multithread-safe.
* lib/hard-locale.h (hard_locale): Move documentation to here.
* lib/hard-locale.c: Don't include <stdlib.h>.
(GLIBC_VERSION): Remove macro.
(hard_locale): Assume that all systems name the "C" and "POSIX" locales
"C" or "POSIX". Invoke setlocale_null instead of setlocale.
* modules/hard-locale (Depends-on): Remove strdup. Add setlocale-null.
(configure.ac): Require gl_FUNC_SETLOCALE_NULL. Set LIB_HARD_LOCALE.
(Link): New section.
* modules/hard-locale-tests (Makefile.am): Link test-hard-locale against
$(LIB_HARD_LOCALE).
Bruno Haible [Wed, 18 Dec 2019 10:10:20 +0000 (11:10 +0100)]
hard-locale: Avoid test failure on Haiku.
* tests/test-hard-locale.c (test_one): Treat Haiku like recent OpenBSD.
Bruno Haible [Wed, 18 Dec 2019 09:49:44 +0000 (10:49 +0100)]
setlocale-null: Handle NULL result from setlocale.
* lib/locale.in.h (setlocale_null): Document EINVAL return value.
* lib/setlocale_null.c (setlocale_null_unlocked): Handle NULL result
from setlocale or _wsetlocale.
Bruno Haible [Wed, 18 Dec 2019 08:41:31 +0000 (09:41 +0100)]
hard-locale: Add test.
* tests/test-hard-locale.c: New file.
* tests/locale.c: New file.
* modules/hard-locale-tests: New file.
Paul Eggert [Wed, 18 Dec 2019 05:41:27 +0000 (21:41 -0800)]
dfa: do not match invalid UTF-8
* lib/dfa.c (struct dfa): Grow utf8_anychar_classes member array
from 5 to 9 tokens; this is needed due to the changes to
add_utf8_anychar.
(charclass_index): 2nd arg is now pointer-to-const.
(add_utf8_anychar): Match only valid UTF-8 byte sequences
instead of allowing overlong encodings or surrogate halves.
Paul Eggert [Tue, 17 Dec 2019 22:08:33 +0000 (14:08 -0800)]
dfa: simplify charclass by assuming C99
* lib/dfa.c (CHARCLASS_WORD_BITS): Now always 64.
(charclass_word): Now always uint_fast64_t.
(CHARCLASS_PAIR): Remove.
(CHARCLASS_INIT): Take 4 arguments instead of 8. All uses changed.
Paul Eggert [Tue, 17 Dec 2019 21:09:30 +0000 (13:09 -0800)]
fts: tune via calloc
* lib/fts.c (fts_open): Prefer calloc to malloc + memset.
Paul Eggert [Tue, 17 Dec 2019 21:07:15 +0000 (13:07 -0800)]
dfa: tune via xzalloc
* lib/dfa.c (dfaoptimize): Prefer xzalloc to xmalloc + memset.
Bruno Haible [Tue, 17 Dec 2019 14:29:15 +0000 (15:29 +0100)]
localcharset: Fix multithread-safety bug on Windows and OS/2.
* lib/localcharset.h (locale_charset): Clarify when the result becomes
invalid.
* lib/localcharset.c (locale_charset): Use a stack-allocated buffer to
assemble the result.
Bruno Haible [Tue, 17 Dec 2019 14:02:12 +0000 (15:02 +0100)]
localcharset: Optimize code for native Windows.
* lib/localcharset.c (locale_charset): Don't both calling
setlocale (LC_ALL, NULL) since we're not interested in its result.
Bruno Haible [Tue, 17 Dec 2019 13:10:45 +0000 (14:10 +0100)]
nl_langinfo: Fix multithread-safety bug on OpenBSD 3.8.
* lib/nl_langinfo.c (ctype_codeset): Invoke setlocale_null instead of
setlocale.
* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Require
gl_FUNC_SETLOCALE_NULL. Set LIB_NL_LANGINFO.
* modules/nl_langinfo (Depends-on): Add setlocale-null.
Bruno Haible [Tue, 17 Dec 2019 13:00:59 +0000 (14:00 +0100)]
nl_langinfo: Fix multithread-safety bug on mingw and MSVC.
* lib/nl_langinfo.c (ctype_codeset, rpl_nl_langinfo): Use a
stack-allocated buffer to assemble each result and different static
buffers to return it.
* tests/test-nl_langinfo-mt.c: New file.
* modules/nl_langinfo-tests (Files): Add it.
(Depends-on): Add thread, nanosleep.
(Makefile.am): Build test-nl_langinfo-mt test.
Bruno Haible [Tue, 17 Dec 2019 11:21:07 +0000 (12:21 +0100)]
langinfo: Document more details.
* doc/posix-headers/langinfo.texi: List platform details.
* doc/posix-functions/nl_langinfo.texi: Likewise.
Bruno Haible [Tue, 17 Dec 2019 09:35:05 +0000 (10:35 +0100)]
mbsinit: Fix compilation error in mingw-w64 7.0 with _UCRT defined.
Reported by Tom Kacvinsky <tom.kacvinsky@vector.com>
and Martin Storsjö <martin@martin.st>
in <https://savannah.gnu.org/bugs/?57406>.
* lib/mbsinit.c: Accommodate an MSVC-like mbstate_t definition with
mingw.
Bruno Haible [Tue, 17 Dec 2019 08:51:22 +0000 (09:51 +0100)]
glob: Avoid warning on mingw.
Reported by Christian Biesinger <cbiesinger@google.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00122.html>.
* lib/glob.c (__stat64): Undefine first.
Paul Eggert [Tue, 17 Dec 2019 08:49:54 +0000 (00:49 -0800)]
xalloc: tune xzalloc for fresh allocations
* lib/xmalloc.c (xzalloc): Use xcalloc rather than xmalloc+memset,
because when the memory is freshly allocated from the OS via sbrk
or mmap, calloc can avoid doing the memset.
Paul Eggert [Tue, 17 Dec 2019 08:20:53 +0000 (00:20 -0800)]
dfa: new function dfacopysyntax
* lib/dfa.c (struct dfa): Move syntax member later so
that dfacopysyntax can easily clear earlier members.
(dfacopysyntax): New function, used by Gawk.
Paul Eggert [Tue, 17 Dec 2019 01:02:31 +0000 (17:02 -0800)]
dfa: port _GL_ATTRIBUTE_MALLOC to Gawk
Gawk does not use Gnulib, and does not define _GL_ATTRIBUTE_MALLOC.
* lib/dfa.h (_GL_ATTRIBUTE_MALLOC): Define to empty
if not already defined.
Paul Eggert [Tue, 17 Dec 2019 01:00:18 +0000 (17:00 -0800)]
dfa: remove one dependency on MB_CUR_MAX
* lib/dfa.c (dfamust): No need to refer to MB_CUR_MAX here.
Paul Eggert [Mon, 16 Dec 2019 22:38:23 +0000 (14:38 -0800)]
dfa: remove struct lexer_state.cur_mb_len
* lib/dfa.c (struct lexer_state): Remove cur_mb_len member,
as it’s not needed and the code is simpler without it.
All uses removed.
Bruno Haible [Mon, 16 Dec 2019 09:38:37 +0000 (10:38 +0100)]
setlocale-null: Remove need for -lpthread on musl libc, *BSD, Haiku.
Reported by Arnold Robbins <arnold@skeeve.com>.
* lib/setlocale_null.c (c11_threads_in_use, pthread_in_use): New macros,
copied from lib/glthread/lock.h.
(pthread_mutex_lock, pthread_mutex_unlock): Mark as weak.
(setlocale_null_with_lock): If pthread_in_use() is false, use
setlocale_null_unlocked directly.
* m4/threadlib.m4 (gl_WEAK_SYMBOLS): New macro, extracted from
gl_THREADLIB_BODY. Define HAVE_WEAK_SYMBOLS.
(gl_THREADLIB_BODY): Invoke gl_WEAK_SYMBOLS.
* m4/setlocale_null.m4 (gl_FUNC_SETLOCALE_NULL): Invoke gl_WEAK_SYMBOLS.
Set LIB_SETLOCALE_NULL to empty if weak symbols are supported.
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Add comment.
Paul Eggert [Mon, 16 Dec 2019 08:32:01 +0000 (00:32 -0800)]
dfa: make dfasyntax thread-safe
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00099.html
* lib/dfa.c: Do not include locale.h.
(struct dfa): Remove simple_locale member.
All uses replaced by localeinfo.simple.
(using_simple_locale): Remove; now present (with some
changes) in localeinfo.c.
(dfasyntax): No need to initialize removed member.
Paul Eggert [Mon, 16 Dec 2019 08:27:15 +0000 (00:27 -0800)]
localeinfo: record whether locale is simple
* lib/localeinfo.c (using_simple_locale): New function,
copied here from lib/dfa.c but with a change: it uses
strcoll for its heuristic, instead of using setlocale.
This lets it be thread-safe.
* lib/localeinfo.h (struct localeinfo): New member ‘simple’.
Bruno Haible [Sun, 15 Dec 2019 22:07:28 +0000 (23:07 +0100)]
duplocale: Fix multithread-safety bug on AIX.
* lib/duplocale.c: Don't include <stdlib.h>.
(rpl_duplocale): Invoke setlocale_null instead of setlocale.
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Require gl_FUNC_SETLOCALE_NULL.
Set LIB_DUPLOCALE.
* modules/duplocale (Depends-on): Add setlocale-null.
(Link): New section.
* modules/duplocale-tests (Makefile.am): Link test-duplocale with
$(LIB_DUPLOCALE).
Bruno Haible [Sun, 15 Dec 2019 20:48:05 +0000 (21:48 +0100)]
setlocale-null: Add tests.
* tests/test-setlocale_null.c: New file.
* tests/test-setlocale_null-one.c: New file.
* tests/test-setlocale_null-all.c: New file.
* modules/setlocale-null-tests: New file.
Bruno Haible [Sun, 15 Dec 2019 20:39:55 +0000 (21:39 +0100)]
setlocale-null: New module.
* lib/locale.in.h (SETLOCALE_NULL_MAX, SETLOCALE_NULL_ALL_MAX,
setlocale_null): New declarations.
* lib/setlocale_null.c: New file.
* lib/setlocale-lock.c: New file.
* m4/threadlib.m4 (gl_PTHREADLIB_BODY): Define C macro HAVE_PTHREAD_API.
* m4/setlocale_null.m4: New file.
* m4/locale_h.m4 (gl_LOCALE_H_DEFAULTS): Initialize
GNULIB_SETLOCALE_NULL.
* modules/locale (Makefile.am): Substitute GNULIB_SETLOCALE_NULL.
* modules/setlocale-null: New file.
* doc/posix-functions/setlocale.texi: Mention the new module.
Bruno Haible [Sun, 15 Dec 2019 19:05:24 +0000 (20:05 +0100)]
lock tests: Skip test when no multithreading is enabled.
* tests/test-rwlock1.c: Skip the test when no multithreading is enabled.
Bruno Haible [Sat, 14 Dec 2019 13:33:14 +0000 (14:33 +0100)]
locale, duplocale, localename: Fix last patch.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00093.html>.
* lib/locale.in.h (HAVE_WORKING_NEWLOCALE, HAVE_WORKING_DUPLOCALE):
Don't define if locale_t does not exist.
Bruno Haible [Fri, 13 Dec 2019 10:28:54 +0000 (11:28 +0100)]
locale, duplocale, localename: Fix errors if locale_t does not exist.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00078.html>.
* lib/locale.in.h (HAVE_WORKING_NEWLOCALE, HAVE_WORKING_DUPLOCALE): New
macros.
* tests/test-locale.c: Test HAVE_WORKING_NEWLOCALE instead of
HAVE_NEWLOCALE.
* tests/test-localename.c: Likewise.
* tests/test-duplocale.c: Test HAVE_WORKING_DUPLOCALE instead of
HAVE_DUPLOCALE.
* tests/test-locale-c++.cc: Likewise.
Bruno Haible [Fri, 13 Dec 2019 07:51:11 +0000 (08:51 +0100)]
wcstok: Fix test failure on HP-UX.
* m4/wcstok.m4 (gl_FUNC_WCSTOK): Set REPLACE_WCSTOK to 1 on HP-UX.
* doc/posix-functions/wcstok.texi: Mention the HP-UX bug.
Bruno Haible [Thu, 12 Dec 2019 23:19:56 +0000 (00:19 +0100)]
strtod, strtold tests: Avoid test failure on AIX 7.2.
* tests/test-strtod1.c (main): Allow implementations in which ',' and
'.' both are radix characters.
* tests/test-strtold1.c (main): Likewise.
Paul Eggert [Thu, 12 Dec 2019 22:11:06 +0000 (14:11 -0800)]
dfa: prefer ptrdiff_t for API, too
Also, use ‘idx_t’ for ptrdiff_t values that must be nonnegative,
but do this only for internal use for now.
* NEWS: Mention the API change.
* lib/dfa.c (idx_t, IDX_MAX): New type and max value, for internal
use for now. Use them instead of ptrdiff_t and PTRDIFF_MAX for
values known to be nonnegative.
(dfaparse, dfaexec_mb, dfaexec_sb, dfaexec_noop, dfaexec):
Prefer idx_t or ptrdiff_t to size_t for API.
* lib/dfa.h (dfaparse, dfacomp, dfaexec):
Prefer ptrdiff_t to size_t for API.
Paul Eggert [Thu, 12 Dec 2019 18:16:13 +0000 (10:16 -0800)]
stdalign: port to xlclang 16.01
Problem reportd by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00064.html
* lib/stdalign.in.h (_Alignas): Do not use __attribute__
((__aligned__ (...))) with xlclang, as a top-level
‘char __attribute__ ((__aligned__ (8))) c;’ does not work with
xlclang version 16.01.0000.0001; the alignment directive is ignored.
Bruno Haible [Thu, 12 Dec 2019 16:52:50 +0000 (17:52 +0100)]
duplocale: Fix test failure on AIX 7.2 with xlclang.
* lib/duplocale.c: Include <stdlib.h>.
(rpl_duplocale): Use a heap-allocated copy of the first setlocale return
value.
Bruno Haible [Thu, 12 Dec 2019 16:04:02 +0000 (17:04 +0100)]
stddef: Document the AIX xlc issue.
* doc/posix-headers/stddef.texi: Document the NULL issue with AIX xlc.
Bruno Haible [Thu, 12 Dec 2019 12:52:50 +0000 (13:52 +0100)]
duplocale: Don't attempt to override if locale_t does not exist.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00039.html>.
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): If locale_t does not exist, set
HAVE_DUPLOCALE to 0.
Bruno Haible [Thu, 12 Dec 2019 12:02:28 +0000 (13:02 +0100)]
wcwidth: Avoid test failure on AIX 7.2.
* tests/test-wcwidth.c (main): Don't fail if wcwidth(0x200B) is
negative.
* doc/posix-functions/wcwidth.texi: Mention the AIX issue.
Bruno Haible [Thu, 12 Dec 2019 11:38:40 +0000 (12:38 +0100)]
ilogbl: Work around Cygwin bug.
* m4/ilogbl.m4 (gl_FUNC_ILOGBL_WORKS): Test whether ilogbl(0.0L) is
correct.
* doc/posix-functions/ilogbl.texi: Mention the Cygwin bug.
Bruno Haible [Thu, 12 Dec 2019 10:07:49 +0000 (11:07 +0100)]
strtold: Work around Cygwin bug.
* m4/strtold.m4 (gl_FUNC_STRTOLD): Add test for the underflow problem.
If it is present, define STRTOLD_HAS_UNDERFLOW_BUG.
* lib/strtod.c (HAVE_UNDERLYING_STRTOD): Set to 0 if
STRTOLD_HAS_UNDERFLOW_BUG is defined.
* doc/posix-functions/strtold.texi: Mention the Cygwin bug.