3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent.
10 # New applications should use the macros below instead.
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 ("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_FUNC_ALLOCA])dnl
65 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
66 AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
67 AC_CHECK_FUNCS([btowc iswctype mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
68 AC_CHECK_HEADERS([wctype.h])
71 ])# _AC_LIBOBJ_FNMATCH
74 AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
77 _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix],
78 [rm -f lib/fnmatch.h],
80 if test $ac_cv_func_fnmatch_posix != yes; then
81 dnl We must choose a different name for our function, since on ELF systems
82 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
83 dnl compiled into a shared library.
84 AC_DEFINE([fnmatch], [posix_fnmatch],
85 [Define to a replacement function name for fnmatch().])
91 AC_DEFUN([gl_FUNC_FNMATCH_GNU],
93 dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
94 AC_REQUIRE([AC_GNU_SOURCE])
97 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
98 [rm -f lib/fnmatch.h],
100 if test $ac_cv_func_fnmatch_gnu != yes; then
101 dnl We must choose a different name for our function, since on ELF systems
102 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
103 dnl compiled into a shared library.
104 AC_DEFINE([fnmatch], [gnu_fnmatch],
105 [Define to a replacement function name for fnmatch().])
107 AC_SUBST([FNMATCH_H])