3 # This is a modified version of autoconf's AC_FUNC_FNMATCH.
4 # This file should be simplified after Autoconf 2.57 is required.
6 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
8 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
12 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
13 # -------------------------------------------------------------------------
14 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
15 # IF-FALSE. Use CACHE_VAR.
16 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
18 [for working $1 fnmatch],
20 [dnl Some versions of Solaris, SCO, and the GNU C Library
21 dnl have a broken or incompatible fnmatch.
22 dnl So we run a test program. If we are cross-compiling, take no chance.
23 dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this test.
29 # define y(a, b, c) (fnmatch (a, b, c) == 0)
30 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
32 fnm (char const *pattern, char const *string, int flags)
34 return fnmatch (pattern, string, flags);
38 (!((fnm ? fnm : fnmatch) ("a*", "", 0) == FNM_NOMATCH
40 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
41 && y ("a\\\\bc", "abc", 0)
42 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
44 && n ("*x", ".x", FNM_PERIOD)
46 [y ("xxXX", "xXxX", FNM_CASEFOLD)
47 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
48 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
49 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
50 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
51 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
56 AS_IF([test $$2 = yes], [$3], [$4])
57 ])# _AC_FUNC_FNMATCH_IF
62 # Prepare the replacement of fnmatch.
63 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
64 [AC_REQUIRE([AC_C_CONST])dnl
65 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
66 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
67 AC_CHECK_DECLS([getenv])
68 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
69 AC_CHECK_HEADERS([wchar.h wctype.h])
72 ])# _AC_LIBOBJ_FNMATCH
75 AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
78 _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix],
79 [rm -f lib/fnmatch.h],
81 if test $ac_cv_func_fnmatch_posix != yes; then
82 dnl We must choose a different name for our function, since on ELF systems
83 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
84 dnl compiled into a shared library.
85 AC_DEFINE([fnmatch], [posix_fnmatch],
86 [Define to a replacement function name for fnmatch().])
92 AC_DEFUN([gl_FUNC_FNMATCH_GNU],
94 dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
95 AC_REQUIRE([AC_GNU_SOURCE])
98 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
99 [rm -f lib/fnmatch.h],
100 [_AC_LIBOBJ_FNMATCH])
101 if test $ac_cv_func_fnmatch_gnu != yes; then
102 dnl We must choose a different name for our function, since on ELF systems
103 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
104 dnl compiled into a shared library.
105 AC_DEFINE([fnmatch], [gnu_fnmatch],
106 [Define to a replacement function name for fnmatch().])
108 AC_SUBST([FNMATCH_H])