Commits (88)
  • Bruno Haible's avatar
    lock tests: Skip test when no multithreading is enabled. · fdff8bd0
    Bruno Haible authored
    * tests/test-rwlock1.c: Skip the test when no multithreading is enabled.
    fdff8bd0
  • Bruno Haible's avatar
    setlocale-null: New module. · 567591f3
    Bruno Haible authored
    * 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.
    567591f3
  • Bruno Haible's avatar
    setlocale-null: Add tests. · 4110c01c
    Bruno Haible authored
    * 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.
    4110c01c
  • Bruno Haible's avatar
    duplocale: Fix multithread-safety bug on AIX. · 3a2a6ea2
    Bruno Haible authored
    * 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).
    3a2a6ea2
  • Paul Eggert's avatar
    localeinfo: record whether locale is simple · 74324f05
    Paul Eggert authored
    * 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’.
    74324f05
  • Paul Eggert's avatar
    dfa: make dfasyntax thread-safe · ecb700c1
    Paul Eggert authored
    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.
    ecb700c1
  • Bruno Haible's avatar
    setlocale-null: Remove need for -lpthread on musl libc, *BSD, Haiku. · 6be28624
    Bruno Haible authored
    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.
    6be28624
  • Paul Eggert's avatar
    dfa: remove struct lexer_state.cur_mb_len · 99969d03
    Paul Eggert authored
    * 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.
    99969d03
  • Paul Eggert's avatar
    dfa: remove one dependency on MB_CUR_MAX · 23c8b490
    Paul Eggert authored
    * lib/dfa.c (dfamust): No need to refer to MB_CUR_MAX here.
    23c8b490
  • Paul Eggert's avatar
    dfa: port _GL_ATTRIBUTE_MALLOC to Gawk · 10ad4d2a
    Paul Eggert authored
    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.
    10ad4d2a
  • Paul Eggert's avatar
    dfa: new function dfacopysyntax · 83e9cc89
    Paul Eggert authored
    * lib/dfa.c (struct dfa): Move syntax member later so
    that dfacopysyntax can easily clear earlier members.
    (dfacopysyntax): New function, used by Gawk.
    83e9cc89
  • Paul Eggert's avatar
    xalloc: tune xzalloc for fresh allocations · f1a80e85
    Paul Eggert authored
    * 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.
    f1a80e85
  • Bruno Haible's avatar
    glob: Avoid warning on mingw. · 29033183
    Bruno Haible authored
    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.
    29033183
  • Bruno Haible's avatar
    mbsinit: Fix compilation error in mingw-w64 7.0 with _UCRT defined. · f61573ab
    Bruno Haible authored
    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.
    f61573ab
  • Bruno Haible's avatar
    langinfo: Document more details. · 9accf385
    Bruno Haible authored
    * doc/posix-headers/langinfo.texi: List platform details.
    * doc/posix-functions/nl_langinfo.texi: Likewise.
    9accf385
  • Bruno Haible's avatar
    nl_langinfo: Fix multithread-safety bug on mingw and MSVC. · 5dbb9992
    Bruno Haible authored
    * 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.
    5dbb9992
  • Bruno Haible's avatar
    nl_langinfo: Fix multithread-safety bug on OpenBSD 3.8. · f2b52247
    Bruno Haible authored
    * 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.
    f2b52247
  • Bruno Haible's avatar
    localcharset: Optimize code for native Windows. · de1e233d
    Bruno Haible authored
    * lib/localcharset.c (locale_charset): Don't both calling
    setlocale (LC_ALL, NULL) since we're not interested in its result.
    de1e233d
  • Bruno Haible's avatar
    localcharset: Fix multithread-safety bug on Windows and OS/2. · e36f79ba
    Bruno Haible authored
    * 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.
    e36f79ba
  • Paul Eggert's avatar
    dfa: tune via xzalloc · d19dc900
    Paul Eggert authored
    * lib/dfa.c (dfaoptimize): Prefer xzalloc to xmalloc + memset.
    d19dc900
  • Paul Eggert's avatar
    fts: tune via calloc · 56d8bdcb
    Paul Eggert authored
    * lib/fts.c (fts_open): Prefer calloc to malloc + memset.
    56d8bdcb
  • Paul Eggert's avatar
    dfa: simplify charclass by assuming C99 · 8df5ec4b
    Paul Eggert authored
    * 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.
    8df5ec4b
  • Paul Eggert's avatar
    dfa: do not match invalid UTF-8 · 1219c343
    Paul Eggert authored
    * 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.
    1219c343
  • Bruno Haible's avatar
    hard-locale: Add test. · 2d1b7501
    Bruno Haible authored
    * tests/test-hard-locale.c: New file.
    * tests/locale.c: New file.
    * modules/hard-locale-tests: New file.
    2d1b7501
  • Bruno Haible's avatar
    setlocale-null: Handle NULL result from setlocale. · e144ded4
    Bruno Haible authored
    * lib/locale.in.h (setlocale_null): Document EINVAL return value.
    * lib/setlocale_null.c (setlocale_null_unlocked): Handle NULL result
    from setlocale or _wsetlocale.
    e144ded4
  • Bruno Haible's avatar
    hard-locale: Avoid test failure on Haiku. · 9b3418df
    Bruno Haible authored
    * tests/test-hard-locale.c (test_one): Treat Haiku like recent OpenBSD.
    9b3418df
  • Bruno Haible's avatar
    hard-locale: Make multithread-safe. · 25d476a2
    Bruno Haible authored
    * 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).
    25d476a2
  • Bruno Haible's avatar
    setlocale: Make calls with NULL argument multithread-safe. · 505092c2
    Bruno Haible authored
    * 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'.
    505092c2
  • Bruno Haible's avatar
    localename: Optimize code for native Windows. · f7efd84e
    Bruno Haible authored
    * lib/localename.c (gl_locale_name_posix): Remove handling of LC_ALL
    category (not allowed here).
    f7efd84e
  • Bruno Haible's avatar
    setlocale-null: Make API more useful. · 3a310962
    Bruno Haible authored
    * 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.
    3a310962
  • Bruno Haible's avatar
    localename: Ensure multithread-safety in future changes. · b7e45cc1
    Bruno Haible authored
    * 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.
    b7e45cc1
  • Bruno Haible's avatar
    wchar: Fix test failures on AIX and MSVC (regression from 2019-12-07). · c99e1067
    Bruno Haible authored
    * lib/wchar.in.h (GNULIB_defined_mbstate_t): Do define on AIX and MSVC.
    c99e1067
  • Paul Eggert's avatar
    Improve port of AC_C_RESTRICT to Oracle C++ · 5ab3622a
    Paul Eggert authored
    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.
    5ab3622a
  • Bruno Haible's avatar
    localename: Fix test failure on AIX 7.2. · d02c5c2d
    Bruno Haible authored
    * 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.
    d02c5c2d
  • Bruno Haible's avatar
    iconv tests: Test canonicalized, not system-dependent, encoding names. · 994dc96e
    Bruno Haible authored
    * tests/test-iconv.c (main): Revert part of the 2016-08-17 patch.
    994dc96e
  • Bruno Haible's avatar
    iconv tests: Test canonicalized, not system-dependent, encoding names. · d66379ef
    Bruno Haible authored
    * modules/iconv-tests (Depends-on): Add iconv_open.
    d66379ef
  • Paul Eggert's avatar
    dfa: fast->small for array elements · 5b570e9c
    Paul Eggert authored
    * 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.
    5b570e9c
  • Paul Eggert's avatar
    dfa: struct dfamust now uses flexible array · 6dabeec0
    Paul Eggert authored
    * 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.
    6dabeec0
  • Jim Meyering's avatar
    nstrftime: avoid a shadowing warning · 009b4fbe
    Jim Meyering authored
    * lib/nstrftime.c (libc_hidden_def): Rename inner "i" to "j",
    to avoid shadowing an "i" declared hundreds of lines above.
    009b4fbe
  • Bruno Haible's avatar
    localename, gettext: Fix host_os value for z/OS. · 1888ae22
    Bruno Haible authored
    * m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Fix host_os value in
    cross-configuration code.
    1888ae22
  • Bruno Haible's avatar
    doc: Document the problem of the per-thread locale functions on z/OS. · 064d8f91
    Bruno Haible authored
    * 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.
    064d8f91
  • Bruno Haible's avatar
    iconv_open: Add support for z/OS encoding names. · 49e78fca
    Bruno Haible authored
    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.
    49e78fca
  • Bruno Haible's avatar
    localcharset: Add support for z/OS encoding names. · 3f7d8da2
    Bruno Haible authored
    * lib/localcharset.h: Mention which encodings are used as locale
    encodings on z/OS.
    3f7d8da2
  • Bruno Haible's avatar
    memcmp tests: Work around the clang bug. · 80d13fd5
    Bruno Haible authored
    * tests/test-memcmp.c (main): Use a volatile function pointer to disable
    the clang optimization.
    80d13fd5
  • Bruno Haible's avatar
    pthread-thread, lock: On z/OS, use PTHREAD_RWLOCK_INITIALIZER_NP. · 49a0828d
    Bruno Haible authored
    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.
    49a0828d
  • Bruno Haible's avatar
    quotearg tests: Fix conflict with hard-locale tests. · fc3b2d42
    Bruno Haible authored
    * tests/testlocale: Renamed from tests/locale.
    * modules/quotearg-tests (Files): Update.
    * tests/test-quotearg.sh (LOCALEDIR): Likewise.
    fc3b2d42
  • Bruno Haible's avatar
    New convention for multithread-safety tests. · 8837821a
    Bruno Haible authored
    * 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.
    8837821a
  • Bruno Haible's avatar
    threadlib: Remove unused dependency (left over from 2019-07-06). · 25e53d31
    Bruno Haible authored
    * modules/threadlib (Depends-on): Remove havelib.
    25e53d31
  • Bruno Haible's avatar
    nl_langinfo tests: Fix link error (regression from 2019-12-18). · 4a18d227
    Bruno Haible authored
    * modules/nl_langinfo-tests (Makefile.am): Link also test-nl_langinfo
    with $(LIB_SETLOCALE).
    4a18d227
  • Bruno Haible's avatar
    threads-h: Don't depend on threadlib. · 44524a48
    Bruno Haible authored
    * modules/threads-h (configure.ac-early): Invoke gl_ANYTHREADLIB_EARLY,
    not gl_THREADLIB_EARLY.
    44524a48
  • Bruno Haible's avatar
    sched_yield: Don't depend on threadlib and yield. · 478535b0
    Bruno Haible authored
    * 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.
    478535b0
  • Bruno Haible's avatar
    threadlib: Fix LIBMULTITHREAD on FreeBSD with --enable-threads=isoc. · 15a10c15
    Bruno Haible authored
    * 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.
    15a10c15
  • Karl Berry's avatar
    autoupdate · 7ccef84b
    Karl Berry authored
    7ccef84b
  • Bruno Haible's avatar
    threadlib: Improve code structure. · 853609a2
    Bruno Haible authored
    * m4/threadlib.m4: Reorder macros. Add comments.
    853609a2
  • Bruno Haible's avatar
    pthread_sigmask: Avoid test failure on NetBSD 8.0. · 4d16a83b
    Bruno Haible authored
    * tests/test-pthread_sigmask2.c (main): Skip the error handling test on
    NetBSD.
    * doc/posix-functions/pthread_sigmask.texi: Mention the NetBSD problem.
    4d16a83b
  • Bruno Haible's avatar
    localcharset: Update support for OpenBSD. · 9ba36dd3
    Bruno Haible authored
    * lib/localcharset.c (alias_table): Map "US-ASCII" to "ASCII".
    9ba36dd3
  • Bruno Haible's avatar
    count-leading-zeros: Assume that the compiler supports 'long long'. · 0dfa3015
    Bruno Haible authored
    * 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.
    0dfa3015
  • Bruno Haible's avatar
    count-trailing-zeros: Assume that the compiler supports 'long long'. · 00b4820c
    Bruno Haible authored
    * 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.
    00b4820c
  • Bruno Haible's avatar
    count-one-bits: Assume that the compiler supports 'long long'. · 4069d425
    Bruno Haible authored
    * 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.
    4069d425
  • Bruno Haible's avatar
    integer_length*: Assume that the compiler supports 'long long'. · 3a5d13f4
    Bruno Haible authored
    * 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.
    3a5d13f4
  • Bruno Haible's avatar
    gethrxtime: Assume that the compiler supports 'long long'. · 896daf27
    Bruno Haible authored
    * 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.
    896daf27
  • Bruno Haible's avatar
    vasnprintf: Assume that the compiler supports 'long long'. · 5ceaccc0
    Bruno Haible authored
    * 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.
    5ceaccc0
  • Bruno Haible's avatar
    xstrtoll: Assume that the compiler supports 'long long'. · 5377e375
    Bruno Haible authored
    * lib/xstrtol.h (xstrtoll, xstrtoull): Declare unconditionally.
    * modules/xstrtoll (configure.ac): Don't invoke AC_TYPE_LONG_LONG_INT.
    5377e375
  • Bruno Haible's avatar
    strtoimax, strtoumax: Assume that the compiler supports 'long long'. · 1cf18f42
    Bruno Haible authored
    * 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.
    1cf18f42
  • Bruno Haible's avatar
    strtoull: Assume that the compiler supports 'long long'. · 04ac8d92
    Bruno Haible authored
    * m4/strtoull.m4 (gl_FUNC_STRTOULL): Don't require
    AC_TYPE_UNSIGNED_LONG_LONG_INT.
    * modules/strtoull (Files): Remove longlong.m4.
    04ac8d92
  • Bruno Haible's avatar
    strtoll: Assume that the compiler supports 'long long'. · 0b018e2c
    Bruno Haible authored
    * m4/strtoll.m4 (gl_FUNC_STRTOLL): Don't require AC_TYPE_LONG_LONG_INT.
    * modules/strtoll (Files): Remove longlong.m4.
    0b018e2c
  • Bruno Haible's avatar
    atoll: Assume that the compiler supports 'long long'. · 91b5a3c3
    Bruno Haible authored
    * m4/atoll.m4 (gl_FUNC_ATOLL): Don't require AC_TYPE_LONG_LONG_INT.
    * modules/atoll (Files): Remove longlong.m4.
    91b5a3c3
  • Bruno Haible's avatar
    malloca: Assume that the compiler supports 'long long'. · f181860d
    Bruno Haible authored
    * 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.
    f181860d
  • Bruno Haible's avatar
    inttypes-incomplete: Assume that the compiler supports 'long long'. · 818ca1bc
    Bruno Haible authored
    * 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.
    818ca1bc
  • Bruno Haible's avatar
    stdint: Assume that the compiler supports 'long long'. · be9dab63
    Bruno Haible authored
    * 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.
    be9dab63
  • Bruno Haible's avatar
    longlong: Mark module obsolete. · 35accbe6
    Bruno Haible authored
    * modules/longlong (Status, Notice): New sections.
    35accbe6
  • Bruno Haible's avatar
    Prefer lib_SOURCES to unconditional AC_LIBOBJ. · 129087db
    Bruno Haible authored
    * modules/at-internal: Prefer a lib_SOURCES augmentation to an
    unconditional AC_LIBOBJ.
    * modules/selinux-at: Likewise.
    * modules/xmemdup0: Likewise.
    * modules/xstrtoll: Likewise.
    129087db
  • Bruno Haible's avatar
    strfmon_l: Fix test failures on FreeBSD and Cygwin. · 74528fe2
    Bruno Haible authored
    * 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.
    74528fe2
  • Bruno Haible's avatar
    setlocale-null: Add standalone include file. · ab3c9473
    Bruno Haible authored
    * 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>.
    ab3c9473
  • Paul Eggert's avatar
    gethrxtime: remove incorrect overflow detection · f935bab8
    Paul Eggert authored
    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.
    f935bab8
  • Paul Eggert's avatar
    gethrxtime: fix rounding bug with negative args · 0da79aa8
    Paul Eggert authored
    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.
    0da79aa8
  • Bruno Haible's avatar
    setlocale-null: Export the lock function also on non-Windows platforms. · 2028f285
    Bruno Haible authored
    * 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.
    2028f285
  • Paul Eggert's avatar
    gethrxtime: improve xtime_sec performance · 6ad341ee
    Paul Eggert authored
    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.
    6ad341ee
  • Paul Eggert's avatar
    mktime: tweak division performance · 6bd09257
    Paul Eggert authored
    * config/srclist.txt: Do not sync mktime.c for now.
    * lib/mktime.c (shr, ydhms_diff):
    Redo with neither ‘%’ nor conditional branches.
    6bd09257
  • Paul Eggert's avatar
    nstrftime: tweak division performance · 99e080c2
    Paul Eggert authored
    * lib/nstrftime.c (SHR, tm_diff, __strftime_internal):
    Redo with neither ‘%’ nor conditional branches.
    99e080c2
  • Paul Eggert's avatar
    strptime: tweak division performance · 7d96c6af
    Paul Eggert authored
    * lib/strptime.c (day_of_the_week):
    Redo with neither ‘%’ nor conditional branches.
    7d96c6af
  • Bruno Haible's avatar
    setlocale-null: Make it easy to rely on the lock in another library. · 7f41a840
    Bruno Haible authored
    * lib/setlocale-lock.c: Do not define anything if OMIT_SETLOCALE_LOCK is
    defined.
    7f41a840
  • Paul Eggert's avatar
    strptime: fix typo in previous patch · 2a28e881
    Paul Eggert authored
    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.
    2a28e881
  • Bruno Haible's avatar
    lock tests: Fix link error on HP-UX/hppa (regression from 2019-12-21). · ab451627
    Bruno Haible authored
    * m4/semaphore.m4: New file.
    * modules/lock-tests (Files): Add it.
    (configure.ac): Require gl_SEMAPHORE.
    (Makefile.am): Link test-lock with $(LIB_SEMAPHORE).
    ab451627
  • Bruno Haible's avatar
    localcharset: Avoid referencing rpl_setlocale on native Windows. · be584c56
    Bruno Haible authored
    * lib/localcharset.c (setlocale): Undefine.
    be584c56
  • Paul Eggert's avatar
    mbrtowc: port better to narrow-wchar_t platforms · 6bc5c0e0
    Paul Eggert authored
    * 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.
    6bc5c0e0
  • Bruno Haible's avatar
    test-framework-sh: Avoid /bin/sh on AIX 7.2 due to its printf built-in. · a43a04ac
    Bruno Haible authored
    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.
    a43a04ac
  • Jim Meyering's avatar
    test-framework-sh: tighten an internal grep regexp · 575b0ecb
    Jim Meyering authored
    * tests/init.sh (gl_shell_test_script_): Tighten the grep regexp
    that helps test for a working printf.
    575b0ecb
2019-12-26 Jim Meyering <meyering@fb.com>
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.
2019-12-26 Bruno Haible <bruno@clisp.org>
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.
2019-12-26 Paul Eggert <eggert@cs.ucla.edu>
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.
2019-12-24 Bruno Haible <bruno@clisp.org>
localcharset: Avoid referencing rpl_setlocale on native Windows.
* lib/localcharset.c (setlocale): Undefine.
2019-12-24 Bruno Haible <bruno@clisp.org>
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).
2019-12-24 Paul Eggert <eggert@cs.ucla.edu>
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.
2019-12-24 Bruno Haible <bruno@clisp.org>
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.
2019-12-23 Paul Eggert <eggert@cs.ucla.edu>
gethrxtime, mktime, nstrftime, strptime: tweak division performance
Performanced analyzed by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00200.html
* config/srclist.txt: Do not sync mktime.c for now.
* lib/mktime.c (shr, ydhms_diff):
* lib/nstrftime.c (SHR, tm_diff, __strftime_internal):
* lib/strptime.c (day_of_the_week):
* lib/xtime.h (xtime_sec):
Redo with neither ‘%’ nor conditional branches.
2019-12-23 Bruno Haible <bruno@clisp.org>
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.
2019-12-22 Paul Eggert <eggert@cs.ucla.edu>
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.
2019-12-22 Bruno Haible <bruno@clisp.org>
gethrxtime: remove incorrect overflow detection
* 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.
2019-12-22 Bruno Haible <bruno@clisp.org>
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>.
2019-12-22 Bruno Haible <bruno@clisp.org>
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.
2019-12-22 Bruno Haible <bruno@clisp.org>
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.
2019-12-22 Bruno Haible <bruno@clisp.org>
longlong: Mark module obsolete.
* modules/longlong (Status, Notice): New sections.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
2019-12-22 Bruno Haible <bruno@clisp.org>
localcharset: Update support for OpenBSD.
* lib/localcharset.c (alias_table): Map "US-ASCII" to "ASCII".
2019-12-21 Bruno Haible <bruno@clisp.org>
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.
2019-12-21 Bruno Haible <bruno@clisp.org>
threadlib: Improve code structure.
* m4/threadlib.m4: Reorder macros. Add comments.
2019-12-21 Bruno Haible <bruno@clisp.org>
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.
2019-12-21 Bruno Haible <bruno@clisp.org>
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.
2019-12-21 Bruno Haible <bruno@clisp.org>
threads-h: Don't depend on threadlib.
* modules/threads-h (configure.ac-early): Invoke gl_ANYTHREADLIB_EARLY,
not gl_THREADLIB_EARLY.
2019-12-21 Bruno Haible <bruno@clisp.org>
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).
2019-12-21 Bruno Haible <bruno@clisp.org>
threadlib: Remove unused dependency (left over from 2019-07-06).
* modules/threadlib (Depends-on): Remove havelib.
2019-12-21 Bruno Haible <bruno@clisp.org>
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.
2019-12-21 Bruno Haible <bruno@clisp.org>
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.
2019-12-21 Bruno Haible <bruno@clisp.org>
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.
2019-12-21 Bruno Haible <bruno@clisp.org>
memcmp tests: Work around the clang bug.
* tests/test-memcmp.c (main): Use a volatile function pointer to disable
the clang optimization.
2019-12-20 Bruno Haible <bruno@clisp.org>
localcharset: Add support for z/OS encoding names.
* lib/localcharset.h: Mention which encodings are used as locale
encodings on z/OS.
2019-12-20 Bruno Haible <bruno@clisp.org>
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.
2019-12-20 Bruno Haible <bruno@clisp.org>
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.
2019-12-20 Bruno Haible <bruno@clisp.org>
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.
2019-12-19 Jim Meyering <meyering@fb.com>
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.
2019-12-19 Paul Eggert <eggert@cs.ucla.edu>
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.
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.
2019-12-19 Bruno Haible <bruno@clisp.org>
iconv tests: Test canonicalized, not system-dependent, encoding names.
* tests/test-iconv.c (main): Revert part of the 2016-08-17 patch.
* modules/iconv-tests (Depends-on): Add iconv_open.
2019-12-18 Bruno Haible <bruno@clisp.org>
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.
2019-12-18 Paul Eggert <eggert@cs.ucla.edu>
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.
2019-12-18 Bruno Haible <bruno@clisp.org>
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.
2019-12-18 Bruno Haible <bruno@clisp.org>
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.
2019-12-18 Bruno Haible <bruno@clisp.org>
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.
2019-12-18 Bruno Haible <bruno@clisp.org>
localename: Optimize code for native Windows.
* lib/localename.c (gl_locale_name_posix): Remove handling of LC_ALL
category (not allowed here).
2019-12-18 Bruno Haible <bruno@clisp.org>
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'.
2019-12-18 Bruno Haible <bruno@clisp.org>
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).
2019-12-18 Bruno Haible <bruno@clisp.org>
hard-locale: Avoid test failure on Haiku.
* tests/test-hard-locale.c (test_one): Treat Haiku like recent OpenBSD.
2019-12-18 Bruno Haible <bruno@clisp.org>
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.
2019-12-18 Bruno Haible <bruno@clisp.org>
hard-locale: Add test.
* tests/test-hard-locale.c: New file.
* tests/locale.c: New file.
* modules/hard-locale-tests: New file.
2019-12-17 Paul Eggert <eggert@cs.ucla.edu>
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.
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.
fts: tune via calloc
* lib/fts.c (fts_open): Prefer calloc to malloc + memset.
dfa: tune via xzalloc
* lib/dfa.c (dfaoptimize): Prefer xzalloc to xmalloc + memset.
2019-12-17 Bruno Haible <bruno@clisp.org>
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.
2019-12-17 Bruno Haible <bruno@clisp.org>
localcharset: Optimize code for native Windows.
* lib/localcharset.c (locale_charset): Don't bother calling
setlocale (LC_ALL, NULL) since we're not interested in its result.
2019-12-17 Bruno Haible <bruno@clisp.org>
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.
2019-12-17 Bruno Haible <bruno@clisp.org>
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.
2019-12-17 Bruno Haible <bruno@clisp.org>
langinfo: Document more details.
* doc/posix-headers/langinfo.texi: List platform details.
* doc/posix-functions/nl_langinfo.texi: Likewise.
2019-12-17 Bruno Haible <bruno@clisp.org>
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.
2019-12-17 Bruno Haible <bruno@clisp.org>
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.
2019-12-17 Paul Eggert <eggert@cs.ucla.edu>
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.
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.
2019-12-16 Paul Eggert <eggert@cs.ucla.edu>
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.
dfa: remove one dependency on MB_CUR_MAX
* lib/dfa.c (dfamust): No need to refer to MB_CUR_MAX here.
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.
2019-12-16 Bruno Haible <bruno@clisp.org>
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.
2019-12-16 Paul Eggert <eggert@cs.ucla.edu>
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.
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’.
2019-12-15 Bruno Haible <bruno@clisp.org>
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).
2019-12-15 Bruno Haible <bruno@clisp.org>
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.
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.
2019-12-15 Bruno Haible <bruno@clisp.org>
lock tests: Skip test when no multithreading is enabled.
* tests/test-rwlock1.c: Skip the test when no multithreading is enabled.
2019-12-14 Bruno Haible <bruno@clisp.org>
 
locale, duplocale, localename: Fix last patch.
......@@ -2,7 +2,7 @@
# Attempt to guess a canonical system name.
# Copyright 1992-2019 Free Software Foundation, Inc.
timestamp='2019-09-10'
timestamp='2019-12-21'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
......@@ -99,6 +99,8 @@ tmp=
trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
set_cc_for_build() {
# prevent multiple calls if $tmp is already set
test "$tmp" && return 0
: "${TMPDIR=/tmp}"
# shellcheck disable=SC2039
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
......@@ -924,7 +926,7 @@ EOF
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
......
......@@ -59,7 +59,7 @@ $LIBCSRC posix/regex_internal.c lib
$LIBCSRC posix/regex_internal.h lib
$LIBCSRC posix/regexec.c lib
$LIBCSRC time/timegm.c lib
$LIBCSRC time/mktime.c lib
#$LIBCSRC time/mktime.c lib
$LIBCSRC time/mktime-internal.h lib
#
......
......@@ -22,4 +22,8 @@ Portability problems not fixed by Gnulib:
@item
This function is missing on many platforms:
FreeBSD 9.0, NetBSD 5.0, OpenBSD 6.1, Minix 3.1.8, AIX 6.1, HP-UX 11, IRIX 6.5, Solaris 11.3, Cygwin 2.5.x, mingw, MSVC 14, Android 4.4.
@item
This function is useless because the @code{locale_t} type is not defined
on some platforms:
z/OS.
@end itemize
......@@ -15,4 +15,8 @@ Portability problems not fixed by Gnulib:
@item
This function is missing on many platforms:
FreeBSD 9.0, NetBSD 5.0, OpenBSD 6.1, Minix 3.1.8, AIX 6.1, HP-UX 11, IRIX 6.5, Solaris 11.3, Cygwin 2.5.x, mingw, MSVC 14, Android 4.4.
@item
This function is useless because the @code{locale_t} type is not defined
on some platforms:
z/OS.
@end itemize
......@@ -20,7 +20,7 @@ Portability problems fixed by Gnulib module @code{iconv_open}:
@item
This function recognizes only non-standard aliases for many encodings (not
the IANA registered encoding names) on many platforms:
AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 11 2010-11.
AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 11 2010-11, z/OS.
@end itemize
Portability problems fixed by Gnulib module @code{iconv_open-utf}:
......
......@@ -16,6 +16,10 @@ Portability problems not fixed by Gnulib:
This function is missing on many platforms:
FreeBSD 9.0, NetBSD 5.0, OpenBSD 6.1, Minix 3.1.8, AIX 6.1, HP-UX 11, IRIX 6.5, Solaris 11.3, Cygwin 2.5.x, mingw, MSVC 14, Android 4.4.
@item
This function is useless because the @code{locale_t} type is not defined
on some platforms:
z/OS.
@item
This function is useless because the @code{locale_t} type contains basically
no information on some platforms:
OpenBSD 6.3.
......
......@@ -17,7 +17,7 @@ OpenBSD 3.8.
@item
The constants @code{ALTMON_1} to @code{ALTMON_12} are not defined on some
platforms:
glibc 2.26 and many others.
glibc 2.26, musl libc, Mac OS X 10.13, NetBSD 8.0, OpenBSD 6.5, AIX 7.2, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Haiku, Cygwin 2.9.
@item
The constants @code{ERA}, @code{ERA_D_FMT}, @code{ERA_D_T_FMT},
@code{ERA_T_FMT}, @code{ALT_DIGITS} are not supported on some platforms:
......
......@@ -34,4 +34,7 @@ Portability problems not fixed by Gnulib:
@item
On platforms that do not natively support this function,
it has unspecified behavior in a multi-threaded process.
@item
This function may not fail when the first argument is invalid on some platforms:
NetBSD 8.0.
@end itemize
......@@ -4,9 +4,9 @@
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/setlocale.html}
Gnulib module: setlocale
Gnulib module: setlocale, setlocale-null
Portability problems fixed by Gnulib:
Portability problems fixed by Gnulib module @code{setlocale}:
@itemize
@item
On Windows platforms (excluding Cygwin), @code{setlocale(@var{category},NULL)}
......@@ -26,6 +26,17 @@ always fails. The replacement, however, supports only the locale names
@code{"C"} and @code{"POSIX"}.
@end itemize
Portability problems fixed by Gnulib module @code{setlocale} or @code{setlocale-null}:
@itemize
@item
Invocations of @code{setlocale (..., NULL)} are not multithread-safe on some
platforms:
musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
To make these invocations multithread-safe, you need the Gnulib module
@code{setlocale}, or you need to change the code to invoke @code{setlocale_null}
or @code{setlocale_null_r} instead.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
......
......@@ -9,6 +9,9 @@ Gnulib module: strfmon_l
Portability problems fixed by Gnulib:
@itemize
@item
This function ignores the locale argument on some platforms:
FreeBSD 12.0, Cygwin 2.9.
@item
This function uses a wrong locale for the numbers on some platforms:
glibc 2.23.
@end itemize
......
......@@ -20,6 +20,10 @@ This function is not documented and leads to crashes in subsequent
@code{setlocale} invocations on some platforms:
AIX 7.2.
@item
This function is useless because the @code{locale_t} type is not defined
on some platforms:
z/OS.
@item
This function is useless because the @code{locale_t} type contains basically
no information on some platforms:
OpenBSD 6.3.
......
......@@ -16,7 +16,7 @@ OpenBSD 3.8.
@item
The constants @code{ALTMON_1} to @code{ALTMON_12} are not defined on some
platforms:
glibc 2.26 and many others.
glibc 2.26, musl libc, Mac OS X 10.13, NetBSD 8.0, OpenBSD 6.5, AIX 7.2, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Haiku, Cygwin 2.9.
@item
The constants @code{ERA}, @code{ERA_D_FMT}, @code{ERA_D_T_FMT},
@code{ERA_T_FMT}, @code{ALT_DIGITS} are not defined on some platforms:
......
......@@ -100,7 +100,6 @@ count_leading_zeros_l (unsigned long int x)
COUNT_LEADING_ZEROS (__builtin_clzl, _BitScanReverse, unsigned long int);
}
#if HAVE_UNSIGNED_LONG_LONG_INT
/* Compute and return the number of leading zeros in X. */
COUNT_LEADING_ZEROS_INLINE int
count_leading_zeros_ll (unsigned long long int x)
......@@ -108,7 +107,6 @@ count_leading_zeros_ll (unsigned long long int x)
COUNT_LEADING_ZEROS (__builtin_clzll, _BitScanReverse64,
unsigned long long int);
}
#endif
_GL_INLINE_HEADER_END
......
......@@ -122,14 +122,12 @@ count_one_bits_l (unsigned long int x)
COUNT_ONE_BITS (__builtin_popcountl, __popcnt, unsigned long int);
}
#if HAVE_UNSIGNED_LONG_LONG_INT
/* Compute and return the number of 1-bits set in X. */
COUNT_ONE_BITS_INLINE int
count_one_bits_ll (unsigned long long int x)
{
COUNT_ONE_BITS (__builtin_popcountll, __popcnt64, unsigned long long int);
}
#endif
_GL_INLINE_HEADER_END
......
......@@ -92,7 +92,6 @@ count_trailing_zeros_l (unsigned long int x)
COUNT_TRAILING_ZEROS (__builtin_ctzl, _BitScanForward, unsigned long int);
}
#if HAVE_UNSIGNED_LONG_LONG_INT
/* Compute and return the number of trailing zeros in X. */
COUNT_TRAILING_ZEROS_INLINE int
count_trailing_zeros_ll (unsigned long long int x)
......@@ -100,7 +99,6 @@ count_trailing_zeros_ll (unsigned long long int x)
COUNT_TRAILING_ZEROS (__builtin_ctzll, _BitScanForward64,
unsigned long long int);
}
#endif
_GL_INLINE_HEADER_END
......
......@@ -24,6 +24,8 @@
#include "dfa.h"
#include "flexmember.h"
#include <assert.h>
#include <ctype.h>
#include <stdint.h>
......@@ -31,7 +33,6 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <locale.h>
/* Another name for ptrdiff_t, for sizes of objects and nonnegative
indexes into objects. It is signed to help catch integer overflow.
......@@ -83,28 +84,15 @@ isasciidigit (char c)
/* First integer value that is greater than any character code. */
enum { NOTCHAR = 1 << CHAR_BIT };
/* Number of bits used in a charclass word. */
enum { CHARCLASS_WORD_BITS = 64 };
/* This represents part of a character class. It must be unsigned and
at least CHARCLASS_WORD_BITS wide. Any excess bits are zero. */
typedef unsigned long int charclass_word;
/* CHARCLASS_WORD_BITS is the number of bits used in a charclass word.
CHARCLASS_PAIR (LO, HI) is part of a charclass initializer, and
represents 64 bits' worth of a charclass, where LO and HI are the
low and high-order 32 bits of the 64-bit quantity. */
#if ULONG_MAX >> 31 >> 31 < 3
enum { CHARCLASS_WORD_BITS = 32 };
# define CHARCLASS_PAIR(lo, hi) lo, hi
#else
enum { CHARCLASS_WORD_BITS = 64 };
# define CHARCLASS_PAIR(lo, hi) (((charclass_word) (hi) << 32) + (lo))
#endif
typedef uint_least64_t charclass_word;
/* An initializer for a charclass whose 32-bit words are A through H. */
#define CHARCLASS_INIT(a, b, c, d, e, f, g, h) \
{{ \
CHARCLASS_PAIR (a, b), CHARCLASS_PAIR (c, d), \
CHARCLASS_PAIR (e, f), CHARCLASS_PAIR (g, h) \
}}
/* An initializer for a charclass whose 64-bit words are A through D. */
#define CHARCLASS_INIT(a, b, c, d) {{a, b, c, d}}
/* The maximum useful value of a charclass_word; all used bits are 1. */
static charclass_word const CHARCLASS_WORD_MASK
......@@ -423,9 +411,6 @@ struct lexer_state
MB_CUR_MAX > 1. */
wint_t wctok;
/* Length of the multibyte representation of wctok. */
int cur_mb_len;
/* The most recently analyzed multibyte bracket expression. */
struct mb_char_classes brack;
......@@ -448,9 +433,6 @@ struct parser_state
/* A compiled regular expression. */
struct dfa
{
/* Syntax configuration */
struct regex_syntax syntax;
/* Fields filled by the scanner. */
charclass *charclasses; /* Array of character sets for CSET tokens. */
idx_t cindex; /* Index for adding new charclasses. */
......@@ -474,7 +456,7 @@ struct dfa
idx_t nregexps; /* Count of parallel regexps being built
with dfaparse. */
bool fast; /* The DFA is fast. */
token utf8_anychar_classes[5]; /* To lower ANYCHAR in UTF-8 locales. */
token utf8_anychar_classes[9]; /* To lower ANYCHAR in UTF-8 locales. */
mbstate_t mbs; /* Multibyte conversion state. */
/* The following are valid only if MB_CUR_MAX > 1. */
......@@ -566,6 +548,10 @@ struct dfa
state_num mb_trcount; /* Number of transition tables for states with
ANYCHAR that have actually been built. */
/* Syntax configuration. This is near the end so that dfacopysyntax
can memset up to here. */
struct regex_syntax syntax;
/* Information derived from the locale. This is at the end so that
a quick memset need not clear it specially. */
......@@ -573,12 +559,6 @@ struct dfa
char *(*dfaexec) (struct dfa *, char const *, char *,
bool, ptrdiff_t *, bool *);
/* The locale is simple, like the C locale. These locales can be
processed more efficiently, as they are single-byte, their native
character set is in collating-sequence order, and they do not
have multi-character collating elements. */
bool simple_locale;
/* Other cached information derived from the locale. */
struct localeinfo localeinfo;
};
......@@ -860,7 +840,7 @@ maybe_realloc (void *pa, idx_t i, idx_t *nitems,
/* In DFA D, find the index of charclass S, or allocate a new one. */
static idx_t
charclass_index (struct dfa *d, charclass *s)
charclass_index (struct dfa *d, charclass const *s)
{
idx_t i;
......@@ -917,38 +897,6 @@ setbit_case_fold_c (int b, charclass *c)
setbit (i, c);
}
/* Return true if the locale compatible with the C locale. */
static bool
using_simple_locale (bool multibyte)
{
/* The native character set is known to be compatible with
the C locale. The following test isn't perfect, but it's good
enough in practice, as only ASCII and EBCDIC are in common use
and this test correctly accepts ASCII and rejects EBCDIC. */
enum { native_c_charset =
('\b' == 8 && '\t' == 9 && '\n' == 10 && '\v' == 11 && '\f' == 12
&& '\r' == 13 && ' ' == 32 && '!' == 33 && '"' == 34 && '#' == 35
&& '%' == 37 && '&' == 38 && '\'' == 39 && '(' == 40 && ')' == 41
&& '*' == 42 && '+' == 43 && ',' == 44 && '-' == 45 && '.' == 46
&& '/' == 47 && '0' == 48 && '9' == 57 && ':' == 58 && ';' == 59
&& '<' == 60 && '=' == 61 && '>' == 62 && '?' == 63 && 'A' == 65
&& 'Z' == 90 && '[' == 91 && '\\' == 92 && ']' == 93 && '^' == 94
&& '_' == 95 && 'a' == 97 && 'z' == 122 && '{' == 123 && '|' == 124
&& '}' == 125 && '~' == 126)
};
if (!native_c_charset || multibyte)
return false;
else
{
/* Treat C and POSIX locales as being compatible. Also, treat
errors as compatible, as these are invariably from stubs. */
char const *loc = setlocale (LC_ALL, NULL);
return !loc || streq (loc, "C") || streq (loc, "POSIX");
}
}
/* Fetch the next lexical input character from the pattern. There
must at least one byte of pattern input. Set DFA->lex.wctok to the
value of the character or to WEOF depending on whether the input is
......@@ -960,7 +908,6 @@ fetch_wc (struct dfa *dfa)
{
int nbytes = mbs_to_wchar (&dfa->lex.wctok, dfa->lex.ptr, dfa->lex.left,
dfa);
dfa->lex.cur_mb_len = nbytes;
int c = nbytes == 1 ? to_uchar (dfa->lex.ptr[0]) : EOF;
dfa->lex.ptr += nbytes;
dfa->lex.left -= nbytes;
......@@ -1039,7 +986,7 @@ parse_bracket_exp (struct dfa *dfa)
if (invert)
{
c = bracket_fetch_wc (dfa);
known_bracket_exp = dfa->simple_locale;
known_bracket_exp = dfa->localeinfo.simple;
}
wint_t wc = dfa->lex.wctok;
int c1;
......@@ -1150,8 +1097,8 @@ parse_bracket_exp (struct dfa *dfa)
{
/* In the case [x-], the - is an ordinary hyphen,
which is left in c1, the lookahead character. */
dfa->lex.ptr -= dfa->lex.cur_mb_len;
dfa->lex.left += dfa->lex.cur_mb_len;
dfa->lex.ptr--;
dfa->lex.left++;
}
else
{
......@@ -1169,7 +1116,7 @@ parse_bracket_exp (struct dfa *dfa)
/* Treat [x-y] as a range if x != y. */
if (wc != wc2 || wc == WEOF)
{
if (dfa->simple_locale
if (dfa->localeinfo.simple
|| (isasciidigit (c) & isasciidigit (c2)))
{
for (int ci = c; ci <= c2; ci++)
......@@ -1701,21 +1648,22 @@ addtok_wc (struct dfa *dfa, wint_t wc)
unsigned char buf[MB_LEN_MAX];
mbstate_t s = { 0 };
size_t stored_bytes = wcrtomb ((char *) buf, wc, &s);
int buflen;
if (stored_bytes != (size_t) -1)
dfa->lex.cur_mb_len = stored_bytes;
buflen = stored_bytes;
else
{
/* This is merely stop-gap. buf[0] is undefined, yet skipping
the addtok_mb call altogether can corrupt the heap. */
dfa->lex.cur_mb_len = 1;
buflen = 1;
buf[0] = 0;
}
addtok_mb (dfa, buf[0], dfa->lex.cur_mb_len == 1 ? 3 : 1);
for (int i = 1; i < dfa->lex.cur_mb_len; i++)
addtok_mb (dfa, buf[0], buflen == 1 ? 3 : 1);
for (int i = 1; i < buflen; i++)
{
addtok_mb (dfa, buf[i], i == dfa->lex.cur_mb_len - 1 ? 2 : 0);
addtok_mb (dfa, buf[i], i == buflen - 1 ? 2 : 0);
addtok (dfa, CAT);
}
}
......@@ -1723,55 +1671,111 @@ addtok_wc (struct dfa *dfa, wint_t wc)
static void
add_utf8_anychar (struct dfa *dfa)
{
static charclass const utf8_classes[5] = {
/* 80-bf: non-leading bytes. */
CHARCLASS_INIT (0, 0, 0, 0, 0xffffffff, 0xffffffff, 0, 0),
/* Since the Unicode Standard Version 4.0.0 (2003), a well-formed
UTF-8 byte sequence has been defined as follows:
/* 00-7f: 1-byte sequence. */
CHARCLASS_INIT (0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0, 0, 0, 0),
([\x00-\x7f]
|[\xc2-\xdf][\x80-\xbf]
|[\xe0][\xa0-\xbf][\x80-\xbf]
|[\xe1-\xec\xee-\xef][\x80-\xbf][\x80-\xbf]
|[\xed][\x80-\x9f][\x80-\xbf]
|[\xf0][\x90-\xbf][\x80-\xbf][\x80-\xbf])
|[\xf1-\xf3][\x80-\xbf][\x80-\xbf][\x80-\xbf]
|[\xf4][\x80-\x8f][\x80-\xbf][\x80-\xbf])
/* c2-df: 2-byte sequence. */
CHARCLASS_INIT (0, 0, 0, 0, 0, 0, 0xfffffffc, 0),
which I'll write more concisely "A|BC|DEC|FCC|GHC|IJCC|KCCC|LMCC",
where A = [\x00-\x7f], B = [\xc2-\xdf], C = [\x80-\xbf],
D = [\xe0], E = [\xa0-\xbf], F = [\xe1-\xec\xee-\xef], G = [\xed],
H = [\x80-\x9f], I = [\xf0],
J = [\x90-\xbf], K = [\xf1-\xf3], L = [\xf4], M = [\x80-\x8f].
/* e0-ef: 3-byte sequence. */
CHARCLASS_INIT (0, 0, 0, 0, 0, 0, 0, 0xffff),
This can be refactored to "A|(B|DE|GH|(F|IJ|LM|KC)C)C". */
/* f0-f7: 4-byte sequence. */
CHARCLASS_INIT (0, 0, 0, 0, 0, 0, 0, 0xff0000)
};
int n = sizeof utf8_classes / sizeof *utf8_classes;
/* Mnemonics for classes containing two or more bytes. */
enum { A, B, C, E, F, H, J, K, M };
/* Define the five character classes that are needed below. */
if (dfa->utf8_anychar_classes[0] == 0)
for (int i = 0; i < n; i++)
{
charclass c = utf8_classes[i];
if (i == 1)
{
if (!(dfa->syntax.syntax_bits & RE_DOT_NEWLINE))
clrbit ('\n', &c);
if (dfa->syntax.syntax_bits & RE_DOT_NOT_NULL)
clrbit ('\0', &c);
}
dfa->utf8_anychar_classes[i] = CSET + charclass_index (dfa, &c);
}
/* Mnemonics for single-byte tokens. */
enum { D_token = 0xe0, G_token = 0xed, I_token = 0xf0, L_token = 0xf4 };
static charclass const utf8_classes[] = {
/* A. 00-7f: 1-byte sequence. */
CHARCLASS_INIT (0xffffffffffffffff, 0xffffffffffffffff, 0, 0),
/* B. c2-df: 1st byte of a 2-byte sequence. */
CHARCLASS_INIT (0, 0, 0, 0x00000000fffffffc),
/* C. 80-bf: non-leading bytes. */
CHARCLASS_INIT (0, 0, 0xffffffffffffffff, 0),
/* D. e0 (just a token). */
/* E. a0-bf: 2nd byte of a "DEC" sequence. */
CHARCLASS_INIT (0, 0, 0xffffffff00000000, 0),
/* A valid UTF-8 character is
/* F. e1-ec + ee-ef: 1st byte of an "FCC" sequence. */
CHARCLASS_INIT (0, 0, 0, 0x0000dffe00000000),
([0x00-0x7f]
|[0xc2-0xdf][0x80-0xbf]
|[0xe0-0xef[0x80-0xbf][0x80-0xbf]
|[0xf0-f7][0x80-0xbf][0x80-0xbf][0x80-0xbf])
/* G. ed (just a token). */
which I'll write more concisely "B|CA|DAA|EAAA". Factor the [0x00-0x7f]
and you get "B|(C|(D|EA)A)A". And since the token buffer is in reverse
Polish notation, you get "B C D E A CAT OR A CAT OR A CAT OR". */
int i;
for (i = 1; i < n; i++)
addtok (dfa, dfa->utf8_anychar_classes[i]);
while (--i > 1)
/* H. 80-9f: 2nd byte of a "GHC" sequence. */
CHARCLASS_INIT (0, 0, 0x000000000000ffff, 0),
/* I. f0 (just a token). */
/* J. 90-bf: 2nd byte of an "IJCC" sequence. */
CHARCLASS_INIT (0, 0, 0xffffffffffff0000, 0),
/* K. f1-f3: 1st byte of a "KCCC" sequence. */
CHARCLASS_INIT (0, 0, 0, 0x000e000000000000),
/* L. f4 (just a token). */
/* M. 80-8f: 2nd byte of a "LMCC" sequence. */
CHARCLASS_INIT (0, 0, 0x00000000000000ff, 0),
};