changeset 39771:9fdbd340bb73

fnmatch-h: New module. * lib/fnmatch.in.h: Use the usual gnulib idioms for header file replacements. (FNM_*): Don't redefine if fnmatch exists and we are not overriding it. (fnmatch): Use the usual gnulib idiom for function declarations. Enable 'posixcheck' warning. * m4/fnmatch_h.m4: New file. * m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Require gl_FNMATCH_H. Remove code that is moved to fnmatch_h.m4. When fnmatch does not exist, don't bother testing whether it is working. Set HAVE_FNMATCH, REPLACE_FNMATCH as appropriate. * modules/fnmatch-h: New file. * modules/fnmatch (Files): Remove lib/fnmatch.in.h. (Dependencies): Add fnmatch-h. Remove extensions, snippet/*. Change conditions. (configure.ac): Test HAVE_FNMATCH and REPLACE_FNMATCH. Set module indicator. (Makefile.am): Remove code that is moved to fnmatch-h. * modules/fnmatch-gnu (configure.ac): Test HAVE_FNMATCH and REPLACE_FNMATCH. * doc/posix-headers/fnmatch.texi: Mention the 'fnmatch-h' module. * modules/posixcheck (Depends-on): Add fnmatch-h.
author Bruno Haible <bruno@clisp.org>
date Mon, 06 Aug 2018 15:00:38 +0200
parents 2b0180199742
children 297c8dbf38b2
files ChangeLog doc/posix-headers/fnmatch.texi lib/fnmatch.in.h m4/fnmatch.m4 m4/fnmatch_h.m4 modules/fnmatch modules/fnmatch-gnu modules/fnmatch-h modules/posixcheck
diffstat 9 files changed, 322 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 06 14:29:57 2018 +0200
+++ b/ChangeLog	Mon Aug 06 15:00:38 2018 +0200
@@ -1,3 +1,28 @@
+2018-08-06  Bruno Haible  <bruno@clisp.org>
+
+	fnmatch-h: New module.
+	* lib/fnmatch.in.h: Use the usual gnulib idioms for header file
+	replacements.
+	(FNM_*): Don't redefine if fnmatch exists and we are not overriding it.
+	(fnmatch): Use the usual gnulib idiom for function declarations. Enable
+	'posixcheck' warning.
+	* m4/fnmatch_h.m4: New file.
+	* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Require gl_FNMATCH_H. Remove
+	code that is moved to fnmatch_h.m4. When fnmatch does not exist, don't
+	bother testing whether it is working. Set HAVE_FNMATCH, REPLACE_FNMATCH
+	as appropriate.
+	* modules/fnmatch-h: New file.
+	* modules/fnmatch (Files): Remove lib/fnmatch.in.h.
+	(Dependencies): Add fnmatch-h. Remove extensions, snippet/*. Change
+	conditions.
+	(configure.ac): Test HAVE_FNMATCH and REPLACE_FNMATCH. Set module
+	indicator.
+	(Makefile.am): Remove code that is moved to fnmatch-h.
+	* modules/fnmatch-gnu (configure.ac): Test HAVE_FNMATCH and
+	REPLACE_FNMATCH.
+	* doc/posix-headers/fnmatch.texi: Mention the 'fnmatch-h' module.
+	* modules/posixcheck (Depends-on): Add fnmatch-h.
+
 2018-08-06  Bruno Haible  <bruno@clisp.org>
 
 	Enable more C++ tests.
--- a/doc/posix-headers/fnmatch.texi	Mon Aug 06 14:29:57 2018 +0200
+++ b/doc/posix-headers/fnmatch.texi	Mon Aug 06 15:00:38 2018 +0200
@@ -3,7 +3,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/basedefs/fnmatch.h.html}
 
-Gnulib module: fnmatch-posix or fnmatch-gnu
+Gnulib module: fnmatch-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/lib/fnmatch.in.h	Mon Aug 06 14:29:57 2018 +0200
+++ b/lib/fnmatch.in.h	Mon Aug 06 15:00:38 2018 +0200
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2018 Free
+/* Substitute for and wrapper around <fnmatch.h>.
+   Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2018 Free
    Software Foundation, Inc.
 
    This file is part of the GNU C Library.
@@ -16,14 +17,28 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
 
-#ifndef _FNMATCH_H
-#define _FNMATCH_H      1
+#ifndef _@GUARD_PREFIX@_FNMATCH_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_FNMATCH_H@
+# @INCLUDE_NEXT@ @NEXT_FNMATCH_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_FNMATCH_H
+#define _@GUARD_PREFIX@_FNMATCH_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+#if !@HAVE_FNMATCH@ || @REPLACE_FNMATCH@
 
 /* We #undef these before defining them because some losing systems
    (HP-UX A.08.07 for example) define these in <unistd.h>.  */
@@ -54,14 +69,40 @@
 # define FNM_NOSYS      (-1)
 #endif
 
+#endif
+
+
+#if @GNULIB_FNMATCH@
 /* Match NAME against the file name pattern PATTERN,
    returning zero if it matches, FNM_NOMATCH if not.  */
-extern int fnmatch (const char *__pattern, const char *__name,
-                    int __flags)
-     _GL_ARG_NONNULL ((1, 2));
-
-#ifdef __cplusplus
-}
+# if @REPLACE_FNMATCH@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define fnmatch rpl_fnmatch
+#  endif
+_GL_FUNCDECL_RPL (fnmatch, int,
+                  (const char *pattern, const char *name, int flags)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fnmatch, int,
+                  (const char *pattern, const char *name, int flags));
+# else
+#  if !@HAVE_FNMATCH@
+_GL_FUNCDECL_SYS (fnmatch, int,
+                  (const char *pattern, const char *name, int flags)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (fnmatch, int,
+                  (const char *pattern, const char *name, int flags));
+# endif
+_GL_CXXALIASWARN (fnmatch);
+#elif defined GNULIB_POSIXCHECK
+# undef fnmatch
+# if HAVE_RAW_DECL_FNMATCH
+_GL_WARN_ON_USE (fnmatch,
+                 "fnmatch does not portably work - "
+                 "use gnulib module fnmatch for portability or gnulib module fnmatch-gnu for a glibc compatible implementation");
+# endif
 #endif
 
-#endif /* fnmatch.h */
+
+#endif /* _@GUARD_PREFIX@_FNMATCH_H */
+#endif /* _@GUARD_PREFIX@_FNMATCH_H */
--- a/m4/fnmatch.m4	Mon Aug 06 14:29:57 2018 +0200
+++ b/m4/fnmatch.m4	Mon Aug 06 15:00:38 2018 +0200
@@ -1,4 +1,4 @@
-# Check for fnmatch - serial 9.  -*- coding: utf-8 -*-
+# Check for fnmatch - serial 10.  -*- coding: utf-8 -*-
 
 # Copyright (C) 2000-2007, 2009-2018 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -13,124 +13,121 @@
 [
   m4_divert_text([DEFAULTS], [gl_fnmatch_required=POSIX])
 
-  dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
-  dnl This is only needed if gl_fnmatch_required = GNU. It would be possible
-  dnl to avoid this dependency for gl_FUNC_FNMATCH_POSIX by putting
-  dnl gl_FUNC_FNMATCH_GNU into a separate .m4 file.
-  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-
-  FNMATCH_H=
+  AC_REQUIRE([gl_FNMATCH_H])
   gl_fnmatch_required_lowercase=`
     echo $gl_fnmatch_required | LC_ALL=C tr '[[A-Z]]' '[[a-z]]'
   `
-  gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}"
-  AC_CACHE_CHECK([for working $gl_fnmatch_required fnmatch],
-    [$gl_fnmatch_cache_var],
-    [dnl Some versions of Solaris, SCO, and the GNU C Library
-     dnl have a broken or incompatible fnmatch.
-     dnl So we run a test program.  If we are cross-compiling, take no chance.
-     dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this
-     dnl test.
-     if test $gl_fnmatch_required = GNU; then
-       gl_fnmatch_gnu_start=
-       gl_fnmatch_gnu_end=
-     else
-       gl_fnmatch_gnu_start='#if 0'
-       gl_fnmatch_gnu_end='#endif'
-     fi
-     AC_RUN_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <fnmatch.h>
-            static int
-            y (char const *pattern, char const *string, int flags)
-            {
-              return fnmatch (pattern, string, flags) == 0;
-            }
-            static int
-            n (char const *pattern, char const *string, int flags)
-            {
-              return fnmatch (pattern, string, flags) == FNM_NOMATCH;
-            }
-          ]],
-          [[char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]";
-            char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]";
-            static char const A_1[] = { 'A' - 1, 0 };
-            static char const A01[] = { 'A' + 1, 0 };
-            static char const a_1[] = { 'a' - 1, 0 };
-            static char const a01[] = { 'a' + 1, 0 };
-            static char const bs_1[] = { '\\\\' - 1, 0 };
-            static char const bs01[] = { '\\\\' + 1, 0 };
-            int result = 0;
-            if (!n ("a*", "", 0))
-              return 1;
-            if (!y ("a*", "abc", 0))
-              return 1;
-            if (!y ("[/b", "[/b", 0)) /*"]]"*/ /* glibc Bugzilla bug 12378 */
-              return 1;
-            if (!n ("d*/*1", "d/s/1", FNM_PATHNAME))
-              return 2;
-            if (!y ("a\\\\bc", "abc", 0))
-              return 3;
-            if (!n ("a\\\\bc", "abc", FNM_NOESCAPE))
-              return 3;
-            if (!y ("*x", ".x", 0))
-              return 4;
-            if (!n ("*x", ".x", FNM_PERIOD))
-              return 4;
-            if (!y (Apat, "\\\\", 0))
-              return 5;
-            if (!y (Apat, "A", 0))
-              return 5;
-            if (!y (apat, "\\\\", 0))
-              return 5;
-            if (!y (apat, "a", 0))
-              return 5;
-            if (!(n (Apat, A_1, 0) == ('A' < '\\\\')))
-              return 5;
-            if (!(n (apat, a_1, 0) == ('a' < '\\\\')))
-              return 5;
-            if (!(y (Apat, A01, 0) == ('A' < '\\\\')))
-              return 5;
-            if (!(y (apat, a01, 0) == ('a' < '\\\\')))
-              return 5;
-            if (!(y (Apat, bs_1, 0) == ('A' < '\\\\')))
-              return 5;
-            if (!(y (apat, bs_1, 0) == ('a' < '\\\\')))
-              return 5;
-            if (!(n (Apat, bs01, 0) == ('A' < '\\\\')))
-              return 5;
-            if (!(n (apat, bs01, 0) == ('a' < '\\\\')))
-              return 5;
-            $gl_fnmatch_gnu_start
-            if (!y ("xxXX", "xXxX", FNM_CASEFOLD))
-              result |= 8;
-            if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH))
-              result |= 16;
-            if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME))
-              result |= 32;
-            if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR))
-              result |= 64;
-            if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR))
-              result |= 64;
-            if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR))
-              result |= 64;
-            $gl_fnmatch_gnu_end
-            return result;
-          ]])],
-       [eval "$gl_fnmatch_cache_var=yes"],
-       [eval "$gl_fnmatch_cache_var=no"],
-       [eval "$gl_fnmatch_cache_var=\"guessing no\""])
-    ])
-  eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\""
-  if test "$gl_fnmatch_result" = yes; then
-    dnl Not strictly necessary. Only to avoid spurious leftover files if people
-    dnl don't do "make distclean".
-    rm -f "$gl_source_base/fnmatch.h"
+  AC_CHECK_FUNCS_ONCE([fnmatch])
+  if test $ac_cv_func_fnmatch = no; then
+    HAVE_FNMATCH=0
   else
-    FNMATCH_H=fnmatch.h
+    gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}"
+    AC_CACHE_CHECK([for working $gl_fnmatch_required fnmatch],
+      [$gl_fnmatch_cache_var],
+      [dnl Some versions of Solaris, SCO, and the GNU C Library
+       dnl have a broken or incompatible fnmatch.
+       dnl So we run a test program.  If we are cross-compiling, take no chance.
+       dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this
+       dnl test.
+       if test $gl_fnmatch_required = GNU; then
+         gl_fnmatch_gnu_start=
+         gl_fnmatch_gnu_end=
+       else
+         gl_fnmatch_gnu_start='#if 0'
+         gl_fnmatch_gnu_end='#endif'
+       fi
+       AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <fnmatch.h>
+              static int
+              y (char const *pattern, char const *string, int flags)
+              {
+                return fnmatch (pattern, string, flags) == 0;
+              }
+              static int
+              n (char const *pattern, char const *string, int flags)
+              {
+                return fnmatch (pattern, string, flags) == FNM_NOMATCH;
+              }
+            ]],
+            [[char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]";
+              char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]";
+              static char const A_1[] = { 'A' - 1, 0 };
+              static char const A01[] = { 'A' + 1, 0 };
+              static char const a_1[] = { 'a' - 1, 0 };
+              static char const a01[] = { 'a' + 1, 0 };
+              static char const bs_1[] = { '\\\\' - 1, 0 };
+              static char const bs01[] = { '\\\\' + 1, 0 };
+              int result = 0;
+              if (!n ("a*", "", 0))
+                return 1;
+              if (!y ("a*", "abc", 0))
+                return 1;
+              if (!y ("[/b", "[/b", 0)) /*"]]"*/ /* glibc Bugzilla bug 12378 */
+                return 1;
+              if (!n ("d*/*1", "d/s/1", FNM_PATHNAME))
+                return 2;
+              if (!y ("a\\\\bc", "abc", 0))
+                return 3;
+              if (!n ("a\\\\bc", "abc", FNM_NOESCAPE))
+                return 3;
+              if (!y ("*x", ".x", 0))
+                return 4;
+              if (!n ("*x", ".x", FNM_PERIOD))
+                return 4;
+              if (!y (Apat, "\\\\", 0))
+                return 5;
+              if (!y (Apat, "A", 0))
+                return 5;
+              if (!y (apat, "\\\\", 0))
+                return 5;
+              if (!y (apat, "a", 0))
+                return 5;
+              if (!(n (Apat, A_1, 0) == ('A' < '\\\\')))
+                return 5;
+              if (!(n (apat, a_1, 0) == ('a' < '\\\\')))
+                return 5;
+              if (!(y (Apat, A01, 0) == ('A' < '\\\\')))
+                return 5;
+              if (!(y (apat, a01, 0) == ('a' < '\\\\')))
+                return 5;
+              if (!(y (Apat, bs_1, 0) == ('A' < '\\\\')))
+                return 5;
+              if (!(y (apat, bs_1, 0) == ('a' < '\\\\')))
+                return 5;
+              if (!(n (Apat, bs01, 0) == ('A' < '\\\\')))
+                return 5;
+              if (!(n (apat, bs01, 0) == ('a' < '\\\\')))
+                return 5;
+              $gl_fnmatch_gnu_start
+              if (!y ("xxXX", "xXxX", FNM_CASEFOLD))
+                result |= 8;
+              if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH))
+                result |= 16;
+              if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME))
+                result |= 32;
+              if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR))
+                result |= 64;
+              if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR))
+                result |= 64;
+              if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR))
+                result |= 64;
+              $gl_fnmatch_gnu_end
+              return result;
+            ]])],
+         [eval "$gl_fnmatch_cache_var=yes"],
+         [eval "$gl_fnmatch_cache_var=no"],
+         [eval "$gl_fnmatch_cache_var=\"guessing no\""])
+      ])
+    eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\""
+    if test "$gl_fnmatch_result" != yes; then
+      REPLACE_FNMATCH=1
+    fi
   fi
-  AC_SUBST([FNMATCH_H])
-  AM_CONDITIONAL([GL_GENERATE_FNMATCH_H], [test -n "$FNMATCH_H"])
+  if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then
+    FNMATCH_H=fnmatch.h
+    AM_CONDITIONAL([GL_GENERATE_FNMATCH_H], [test -n "$FNMATCH_H"])
+  fi
 ])
 
 # Request a POSIX compliant fnmatch function with GNU extensions.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/fnmatch_h.m4	Mon Aug 06 15:00:38 2018 +0200
@@ -0,0 +1,61 @@
+# fnmatch_h.m4 serial 1
+dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_FNMATCH_H],
+[
+  AC_REQUIRE([gl_FNMATCH_H_DEFAULTS])
+  AC_CHECK_HEADERS_ONCE([fnmatch.h])
+  gl_CHECK_NEXT_HEADERS([fnmatch.h])
+
+  dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
+  dnl This is only needed if gl_fnmatch_required = GNU. It would be possible
+  dnl to avoid this dependency for gl_FUNC_FNMATCH_POSIX by putting
+  dnl gl_FUNC_FNMATCH_GNU into a separate .m4 file.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  if test $ac_cv_header_fnmatch_h = yes; then
+    HAVE_FNMATCH_H=1
+  else
+    HAVE_FNMATCH_H=0
+  fi
+  AC_SUBST([HAVE_FNMATCH_H])
+
+  m4_ifdef([gl_POSIXCHECK],
+    [FNMATCH_H=fnmatch.h],
+    [FNMATCH_H=''
+     if test $ac_cv_header_fnmatch_h != yes; then
+       dnl Provide a substitute <fnmatch.h> file.
+       FNMATCH_H=fnmatch.h
+     fi
+    ])
+  AC_SUBST([FNMATCH_H])
+  AM_CONDITIONAL([GL_GENERATE_FNMATCH_H], [test -n "$FNMATCH_H"])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use.
+  gl_WARN_ON_USE_PREPARE([[#include <fnmatch.h>
+    ]],
+    [fnmatch])
+])
+
+AC_DEFUN([gl_FNMATCH_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_FNMATCH_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_FNMATCH_H_DEFAULTS],
+[
+  GNULIB_FNMATCH=0;          AC_SUBST([GNULIB_FNMATCH])
+  dnl Assume POSIX behavior unless another module says otherwise.
+  HAVE_FNMATCH=1;            AC_SUBST([HAVE_FNMATCH])
+  REPLACE_FNMATCH=0;         AC_SUBST([REPLACE_FNMATCH])
+])
--- a/modules/fnmatch	Mon Aug 06 14:29:57 2018 +0200
+++ b/modules/fnmatch	Mon Aug 06 15:00:38 2018 +0200
@@ -2,51 +2,33 @@
 fnmatch() function: wildcard matching.
 
 Files:
-lib/fnmatch.in.h
 lib/fnmatch.c
 lib/fnmatch_loop.c
 m4/mbstate_t.m4
 m4/fnmatch.m4
 
 Depends-on:
-extensions
-snippet/arg-nonnull
-alloca          [test -n "$FNMATCH_H"]
-builtin-expect  [test -n "$FNMATCH_H"]
-flexmember      [test -n "$FNMATCH_H"]
-stdbool         [test -n "$FNMATCH_H"]
-wchar           [test -n "$FNMATCH_H"]
-wctype-h        [test -n "$FNMATCH_H"]
-memchr          [test -n "$FNMATCH_H"]
-memcmp          [test -n "$FNMATCH_H"]
-mbsrtowcs       [test -n "$FNMATCH_H"]
-mbsinit         [test -n "$FNMATCH_H"]
+fnmatch-h
+alloca          [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]
+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]
+memchr          [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
+memcmp          [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]
 
 configure.ac:
 gl_FUNC_FNMATCH_POSIX
-if test -n "$FNMATCH_H"; then
+if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then
   AC_LIBOBJ([fnmatch])
   gl_PREREQ_FNMATCH
 fi
+gl_FNMATCH_MODULE_INDICATOR([fnmatch])
 
 Makefile.am:
-BUILT_SOURCES += $(FNMATCH_H)
-
-# We need the following in order to create <fnmatch.h> when the system
-# doesn't have one that supports the required API.
-if GL_GENERATE_FNMATCH_H
-fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-	      < $(srcdir)/fnmatch.in.h; \
-	} > $@-t && \
-	mv -f $@-t $@
-else
-fnmatch.h: $(top_builddir)/config.status
-	rm -f $@
-endif
-MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
 
 Include:
 <fnmatch.h>
--- a/modules/fnmatch-gnu	Mon Aug 06 14:29:57 2018 +0200
+++ b/modules/fnmatch-gnu	Mon Aug 06 15:00:38 2018 +0200
@@ -8,7 +8,7 @@
 
 configure.ac:
 gl_FUNC_FNMATCH_GNU
-if test -n "$FNMATCH_H"; then
+if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then
   AC_LIBOBJ([fnmatch])
   gl_PREREQ_FNMATCH
 fi
@@ -16,7 +16,7 @@
 Makefile.am:
 
 Include:
-"fnmatch.h"
+<fnmatch.h>
 
 License:
 LGPLv2+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/fnmatch-h	Mon Aug 06 15:00:38 2018 +0200
@@ -0,0 +1,54 @@
+Description:
+A <fnmatch.h> that conforms to POSIX.
+
+Files:
+lib/fnmatch.in.h
+m4/fnmatch_h.m4
+
+Depends-on:
+extensions
+include_next
+snippet/arg-nonnull
+snippet/c++defs
+snippet/warn-on-use
+
+configure.ac:
+gl_FNMATCH_H
+
+Makefile.am:
+BUILT_SOURCES += $(FNMATCH_H)
+
+# We need the following in order to create <fnmatch.h>.
+if GL_GENERATE_FNMATCH_H
+fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+	  sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
+	      -e 's|@''HAVE_FNMATCH_H''@|$(HAVE_FNMATCH_H)|g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+	      -e 's|@''NEXT_FNMATCH_H''@|$(NEXT_FNMATCH_H)|g' \
+	      -e 's/@''GNULIB_FNMATCH''@/$(GNULIB_FNMATCH)/g' \
+	      -e 's|@''HAVE_FNMATCH''@|$(HAVE_FNMATCH)|g' \
+	      -e 's|@''REPLACE_FNMATCH''@|$(REPLACE_FNMATCH)|g' \
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+	      < $(srcdir)/fnmatch.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+else
+fnmatch.h: $(top_builddir)/config.status
+	rm -f $@
+endif
+MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
+
+Include:
+<fnmatch.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all, glibc
--- a/modules/posixcheck	Mon Aug 06 14:29:57 2018 +0200
+++ b/modules/posixcheck	Mon Aug 06 15:00:38 2018 +0200
@@ -11,6 +11,7 @@
 ctype
 dirent
 fcntl-h
+fnmatch-h
 iconv-h
 inttypes-incomplete
 langinfo