Bruno Haible [Fri, 3 Jan 2020 13:27:29 +0000 (14:27 +0100)]
getopt-posix: Fix compilation failure in testdirs.
* lib/unistd.in.h: Include <getopt-cdefs.h> and <getopt-pfx-core.h> only
when the gnulib module 'getopt-posix' is enabled.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETOPT_POSIX.
* modules/getopt-posix (configure.ac): Set GNULIB_GETOPT_POSIX as a
module indicator.
* modules/unistd (Makefile.am): Substitute GNULIB_GETOPT_POSIX.
Bruno Haible [Fri, 3 Jan 2020 13:19:15 +0000 (14:19 +0100)]
doc: Mention the 64-bit inode number problem.
* m4/largefile.m4 (AC_SYS_LARGEFILE): Mention that this macro fixes the
64-bit inode number problem.
* doc/posix-functions/stat.texi: Mention that this module fixes the
64-bit inode number problem.
* doc/posix-functions/lstat.texi: Likewise.
* doc/posix-functions/fstat.texi: Likewise.
* doc/posix-functions/readdir.texi: Add more details.
* doc/posix-functions/readdir_r.texi: Likewise.
Bruno Haible [Fri, 3 Jan 2020 00:26:10 +0000 (01:26 +0100)]
wcrtomb: Add more tests.
* tests/test-wcrtomb-w32.c: Include localcharset.h.
(test_one_locale): For the GB18030 and UTF-8 tests, verify that
locale_charset() returns the expected value; otherwise, skip the test.
* tests/test-wcrtomb-w32-6.sh: Remove old comment.
* tests/test-wcrtomb-w32-7.sh: Likewise.
* modules/wcrtomb-tests (Files): Add these files.
(Depends-on): Add localcharset.
(TESTS): Add test-wcrtomb-w32-6.sh, test-wcrtomb-w32-7.sh.
Bruno Haible [Fri, 3 Jan 2020 00:23:24 +0000 (01:23 +0100)]
mbrtowc: Add more tests.
* tests/test-mbrtowc-w32.c: Include localcharset.h.
(test_one_locale): For the GB18030 and UTF-8 tests, verify that
locale_charset() returns the expected value; otherwise, skip the test.
* tests/test-mbrtowc-w32-6.sh: Remove old comment.
* tests/test-mbrtowc-w32-7.sh: Likewise.
* modules/mbrtowc-tests (Files): Add these files.
(Depends-on): Add localcharset.
(TESTS): Add test-mbrtowc-w32-6.sh, test-mbrtowc-w32-7.sh.
Bruno Haible [Thu, 2 Jan 2020 17:36:29 +0000 (18:36 +0100)]
mbrtowc: Don't replace mbstate_t on MSVC.
* m4/mbrtowc.m4 (gl_MBSTATE_T_BROKEN): Require AC_CANONICAL_HOST. Ignore
a missing mbsinit function on native Windows.
* m4/wcrtomb.m4 (gl_FUNC_WCRTOMB): Strengthen the test, to detect an
MSVC bug.
* doc/posix-functions/wcrtomb.texi: Mention the MSVC bug.
Pádraig Brady [Wed, 1 Jan 2020 17:36:20 +0000 (17:36 +0000)]
md5, sha1, sha256, sha512: support --with-openssl=auto-gpl-compat
* m4/gl-openssl.m4: Add a new "auto-gpl-compat" mode,
which will auto enable use of openssl, only for >= version 3,
which is newly licensed under the Apache Software License.
This will be used from coreutils for example by adding
gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat]) to configure.ac.
Even though "auto-gpl-compat" is less aggressive than "auto",
we leave the default at "no" so projects can opt in to the
extra dependency.
Bruno Haible [Wed, 1 Jan 2020 21:04:47 +0000 (22:04 +0100)]
mbrtowc: Include function name in macro names.
* m4/mbrtowc.m4 (gl_FUNC_MBRTOWC): Define
MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ, not C_LOCALE_MAYBE_EILSEQ.
(gl_MBRTOWC_C_LOCALE): Change cache variable name to
gl_cv_func_mbrtowc_C_locale_sans_EILSEQ.
* lib/mbrtowc.c: Test MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ, not
C_LOCALE_MAYBE_EILSEQ.
Bruno Haible [Wed, 1 Jan 2020 16:01:54 +0000 (17:01 +0100)]
c32tob: New module.
* lib/uchar.in.h (_GL_LARGE_CHAR32_T): New macro.
(c32tob): New declaration.
* lib/c32tob.c: New file.
* m4/uchar.m4 (gl_UCHAR_MODULE_INDICATOR, gl_UCHAR_H_DEFAULTS): New
macros.
(gl_UCHAR_H): Require gl_UCHAR_H_DEFAULTS.
* modules/uchar (Depends-on): Add snippet/c++defs.
(Makefile.am): Include c++defs.h and substitute GNULIB_C32TOB in
uchar.h.
* modules/c32tob: New file.
* tests/test-uchar.c: Verify that _GL_LARGE_CHAR32_T is correctly
defined.
* tests/test-uchar-c++.cc: Include signature.h. Test the signature of
c32tob.
* modules/uchar-c++-tests (Files): Add tests/signature.h.
* doc/posix-functions/wctob.texi: Mention the new module.
Paul Eggert [Wed, 1 Jan 2020 01:33:19 +0000 (17:33 -0800)]
maint: update copyright notices
Before doing the following changes done by hand, I also ran ‘make
update-copyright’ and ‘config/srclist-update <config/srclist.txt’
to do most of the copyright years automatically. A few upstream
sources are still in 2019 but these should eventually be changed
automatically too.
* build-aux/declared.sh (func_version):
* build-aux/libtool-next-version (func_version):
* build-aux/run-test (func_version):
Update these notices by hand. Put just the last year
in output of programs, as per GNU coding standards.
Jim Meyering [Tue, 31 Dec 2019 07:23:42 +0000 (23:23 -0800)]
localeinfo: ->simple would be wrong for LC_ALL=C
That would lead to using unnecessary and expensive code paths in dfa.c.
* lib/localeinfo.c (using_simple_locale): Fix recently-introduced logic
error that would have made grep many times slower in the C locale.
With this change, and a file created like this:
yes 00 | head -10000000 > in
Running grep as follows becomes more than 40 times faster:
LC_ALL=C grep -Fw 0 in
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 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.
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.
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 [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 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 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 [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.
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.
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 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 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).
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.