]> Savannah Git Hosting - gnulib.git/commitdiff
fnmatch: Rely on more gnulib modules.
authorBruno Haible <bruno@clisp.org>
Fri, 29 May 2020 12:01:54 +0000 (14:01 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 29 May 2020 23:25:59 +0000 (01:25 +0200)
* modules/fnmatch (Depends-on): Add btowc, isblank, iswctype, wmemchr,
wmempcpy, mempcpy.
* lib/fnmatch.c: Assume that HAVE_WCTYPE_H, HAVE_BTOWC, HAVE_ISWCTYPE,
HAVE_WMEMCHR, HAVE_WMEMPCPY, HAVE_ISBLANK, HAVE_DECL_ISBLANK,
HAVE_MEMPCPY are all 1.
* m4/fnmatch.m4 (gl_PREREQ_FNMATCH): Don't test for btowc, isblank,
iswctype, mempcpy, wmemchr, wmemcpy, wmempcpy, <wctype.h>.

ChangeLog
lib/fnmatch.c
m4/fnmatch.m4
modules/fnmatch

index 532f99a20085b03cac5dd7320350bf89810dffbd..d43fa874d42ef8efeb95fdffcf1cc369576fdde3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-05-29  Bruno Haible  <bruno@clisp.org>
+
+       fnmatch: Rely on more gnulib modules.
+       * modules/fnmatch (Depends-on): Add btowc, isblank, iswctype, wmemchr,
+       wmempcpy, mempcpy.
+       * lib/fnmatch.c: Assume that HAVE_WCTYPE_H, HAVE_BTOWC, HAVE_ISWCTYPE,
+       HAVE_WMEMCHR, HAVE_WMEMPCPY, HAVE_ISBLANK, HAVE_DECL_ISBLANK,
+       HAVE_MEMPCPY are all 1.
+       * m4/fnmatch.m4 (gl_PREREQ_FNMATCH): Don't test for btowc, isblank,
+       iswctype, mempcpy, wmemchr, wmemcpy, wmempcpy, <wctype.h>.
+
 2020-05-29  Bruno Haible  <bruno@clisp.org>
 
        Avoid dynamic lookup of Windows API functions when possible.
index 224512d8cebcbd09f4b7ed93cfa8255f998d99e9..db4da5e6a63497bd55acb43ba0bef865d92ca8b8 100644 (file)
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
-
-#define WIDE_CHAR_SUPPORT \
-  (HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \
-   && HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY))
-
-/* For platform which support the ISO C amendment 1 functionality we
-   support user defined character classes.  */
-#if defined _LIBC || WIDE_CHAR_SUPPORT
-# include <wctype.h>
-# include <wchar.h>
-#endif
+#include <wchar.h>
+#include <wctype.h>
 
 /* We need some of the locale data (the collation sequence information)
    but there is no interface to get this information in general.  Therefore
@@ -82,50 +73,33 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
 #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
 
 
-# if ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
-#  define isblank(c) ((c) == ' ' || (c) == '\t')
-# endif
-
 # define STREQ(s1, s2) (strcmp (s1, s2) == 0)
 
-# if defined _LIBC || WIDE_CHAR_SUPPORT
-/* The GNU C library provides support for user-defined character classes
-   and the functions from ISO C amendment 1.  */
-#  ifdef CHARCLASS_NAME_MAX
-#   define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
-#  else
+/* Provide support for user-defined character classes, based on the functions
+   from ISO C 90 amendment 1.  */
+# ifdef CHARCLASS_NAME_MAX
+#  define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
+# else
 /* This shouldn't happen but some implementation might still have this
    problem.  Use a reasonable default value.  */
-#   define CHAR_CLASS_MAX_LENGTH 256
-#  endif
+#  define CHAR_CLASS_MAX_LENGTH 256
+# endif
 
-#  ifdef _LIBC
-#   define IS_CHAR_CLASS(string) __wctype (string)
-#  else
-#   define IS_CHAR_CLASS(string) wctype (string)
-#  endif
+# ifdef _LIBC
+#  define IS_CHAR_CLASS(string) __wctype (string)
+# else
+#  define IS_CHAR_CLASS(string) wctype (string)
+# endif
 
-#  ifdef _LIBC
-#   define ISWCTYPE(WC, WT)     __iswctype (WC, WT)
-#  else
-#   define ISWCTYPE(WC, WT)     iswctype (WC, WT)
-#  endif
+# ifdef _LIBC
+#  define ISWCTYPE(WC, WT)     __iswctype (WC, WT)
+# else
+#  define ISWCTYPE(WC, WT)     iswctype (WC, WT)
+# endif
 
-#  if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
+# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
 /* In this case we are implementing the multibyte character handling.  */
-#   define HANDLE_MULTIBYTE     1
-#  endif
-
-# else
-#  define CHAR_CLASS_MAX_LENGTH  6 /* Namely, 'xdigit'.  */
-
-#  define IS_CHAR_CLASS(string)                                               \
-   (STREQ (string, "alpha") || STREQ (string, "upper")                        \
-    || STREQ (string, "lower") || STREQ (string, "digit")                     \
-    || STREQ (string, "alnum") || STREQ (string, "xdigit")                    \
-    || STREQ (string, "space") || STREQ (string, "print")                     \
-    || STREQ (string, "punct") || STREQ (string, "graph")                     \
-    || STREQ (string, "cntrl") || STREQ (string, "blank"))
+#  define HANDLE_MULTIBYTE     1
 # endif
 
 /* Avoid depending on library functions or files
@@ -159,11 +133,7 @@ static int posixly_correct;
 # ifdef _LIBC
 #  define MEMPCPY(D, S, N) __mempcpy (D, S, N)
 # else
-#  if HAVE_MEMPCPY
-#   define MEMPCPY(D, S, N) mempcpy (D, S, N)
-#  else
-#   define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
-#  endif
+#  define MEMPCPY(D, S, N) mempcpy (D, S, N)
 # endif
 # define MEMCHR(S, C, N) memchr (S, C, N)
 # include "fnmatch_loop.c"
@@ -186,11 +156,7 @@ static int posixly_correct;
 #  else
 #   define STRLEN(S) wcslen (S)
 #   define STRCAT(D, S) wcscat (D, S)
-#   if HAVE_WMEMPCPY
-#    define MEMPCPY(D, S, N) wmempcpy (D, S, N)
-#   else
-#    define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N))
-#   endif
+#   define MEMPCPY(D, S, N) wmempcpy (D, S, N)
 #  endif
 #  define MEMCHR(S, C, N) wmemchr (S, C, N)
 #  define WIDE_CHAR_VERSION 1
index 0f41f8c7ac2385ed7c908264686e17dfe95f65d0..2f8e4a8f1b24755e9fb504b50a48a96cd7855dfa 100644 (file)
@@ -1,4 +1,4 @@
-# Check for fnmatch - serial 14.  -*- coding: utf-8 -*-
+# Check for fnmatch - serial 15.  -*- coding: utf-8 -*-
 
 # Copyright (C) 2000-2007, 2009-2020 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -149,7 +149,5 @@ AC_DEFUN([gl_PREREQ_FNMATCH],
 [
   dnl Prerequisites of lib/fnmatch.c.
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
-  AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
-  AC_CHECK_FUNCS_ONCE([btowc isblank iswctype mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
-  AC_CHECK_HEADERS_ONCE([wctype.h])
+  AC_CHECK_FUNCS_ONCE([mbsrtowcs])
 ])
index c7977b4fb3dbdd529bbea12c1c6c8ba18f94e2f0..4fc5a3b6af6020a08ea8c1de85a11c3e566d807b 100644 (file)
@@ -11,13 +11,19 @@ Depends-on:
 fnmatch-h
 alloca          [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]
+isblank         [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
+iswctype        [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
 stdbool         [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]
+wmempcpy        [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
 memchr          [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
 memcmp          [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
+mempcpy         [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
 mbsrtowcs       [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
 mbsinit         [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]