From 67306f600fe6a3bcf3fbb6d8bf4b8953b74a8fb7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 31 May 2020 10:14:41 -0700 Subject: fnmatch: merge from glibc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, merge in Gnulib’s more-recent methods of making it easier to share between Gnulib and glibc. * lib/fnmatch.c: Reorder includes to match glibc better. Include libc-config.h instead of config.h. Include alloca.h only if _LIBC || HAVE_ALLOCA. Do not include "../locale/elem-hash.h" if _LIBC. Define macros for btowc, etc. if _LIBC. All uses simplified. Define FALLTHROUGH if _LIBC, instead of including attribute.h. Include intprops.h, since glibc has it now. (SIZE_MAX): Remove; use (size_t) -1 instead. Omit the "Comment out all this code" ifdef, since Gnulib has never really needed it. (STREQ): Remove; no longer used. (__libc_use_alloca, alloca, alloca_account): Define as needed if !_LIBC. (ISWCTYPE): Remove; all uses replaced by iswctype. (HANDLE_MULTIBYTE): Remove. All uses removed by assuming true. (internal_function): Remove. All uses removed. (STRUCT): New macro. (WIDE_CHAR_VERSION): Define to 0 instead of leaving undefined. (WMEMCMP): New macro. (FINDIDX): Define if _LIBC, and include and . (fnmatch): Prefer __glibc_likely and __glibc_unlikely to __builtin_expect. Check for integer overflow more systematically. Account for alloca storage better when recursive. Use strnlen instead of strlen for efficiency. * lib/fnmatch_loop.c: Include stdint.h if _LIBC, for int32_t etc. (struct STRUCT): New type. (FCT, EXT): New ENDS and ALLOCA_USED args. All callers changed. (FCT): Prefer __glibc_unlikely to __builtin_expect. Simplify by assuming WIDE_CHAR_SUPPORT. Copy _LIBC code from glibc without worrying Gnulib compatibility. Cast cold to UCHAR to avoid signedness warning. (END): Check for invalid pattern. (EXT): Improve alloca/malloc checking (taken from glibc), and improve it some more by using intprops.h and checking for integer overflow and using bool for booleans. * lib/libc-config.h (compat_symbol): New macro. (versioned_symbol): Make it ‘extern int dummy’ so that it’s acceptable to non-GCC when a trailing semicolon is added. * modules/fnmatch (Depends-on): Add alloca-opt, intprops, libc-config, strnlen. Remove alloca. --- modules/fnmatch | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules/fnmatch') diff --git a/modules/fnmatch b/modules/fnmatch index 4fc5a3b6af..f547670214 100644 --- a/modules/fnmatch +++ b/modules/fnmatch @@ -9,14 +9,17 @@ m4/fnmatch.m4 Depends-on: fnmatch-h -alloca [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] +alloca-opt [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] attribute [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] btowc [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] builtin-expect [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] flexmember [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] +intprops [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] isblank [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] iswctype [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] +libc-config [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] stdbool [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] +strnlen [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] wchar [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] wctype-h [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] wmemchr [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] -- cgit v1.2.1