From: Paul Eggert Date: Fri, 17 May 2002 07:08:41 +0000 (+0000) Subject: (_AC_FUNC_FNMATCH): New macro. X-Git-Tag: AUTOCONF-2.53b~80 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a64dba738cec3f1131b604e8feb1ffdb57ceac3f;p=thirdparty%2Fautoconf.git (_AC_FUNC_FNMATCH): New macro. (AC_FUNC_FNMATCH): Use it. Test only for POSIX conformance, not for GNU extensions; this undoes part of the 2000-11-03 change, reverting to 2.13-compatible behavior. Add new optional argument DIR. (AC_FUNC_FNMATCH_GNU): New macro. --- diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 3abda5945..0ea4a90e1 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -342,31 +342,71 @@ fi AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE]) -# AC_FUNC_FNMATCH -# --------------- -# We look for fnmatch.h to avoid that the test fails in C++. +# _AC_FUNC_FNMATCH([DIR], STANDARD, SHELL_VAR, VARIABLE) +# --------------------------------------------- +AC_DEFUN([_AC_FUNC_FNMATCH], +[m4_ifval([$1], + [AC_REQUIRE([AC_C_CONST]) + AC_REQUIRE([AC_FUNC_ALLOCA]) + AC_REQUIRE([AC_MBSTATE_T])]) + AC_CACHE_CHECK( + [for working $2 fnmatch], + [$3], + # Some versions of Solaris, SCO, and the GNU C Library + # have a broken or incompatible fnmatch. + # So we run a test program. If we are cross-compiling, take no chance. + # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test. + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [#include +# define y(a, b, c) (fnmatch (a, b, c) == 0) +# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)], + [exit + (!(y ("a*", "abc", 0) + && n ("d*/*1", "d/s/1", FNM_PATHNAME) + && y ("a\\\\bc", "abc", 0) + && n ("a\\\\bc", "abc", FNM_NOESCAPE) + && y ("*x", ".x", 0) + && n ("*x", ".x", FNM_PERIOD) + && m4_if([$2], [GNU], + [y ("xxXX", "xXxX", FNM_CASEFOLD) + && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH) + && n ("d*/*1", "d/s/1", FNM_FILE_NAME) + && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) + && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) + && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)], + 1)));])], + [$3=yes], + [$3=no], + [$3=cross])]) + if test $$3 = yes; then + m4_ifval([$1], [rm -f $1/fnmatch.h]) + AC_DEFINE([$4], 1, + [Define to 1 if your system has a working $2 `fnmatch' function.]) + else + m4_ifval([$1], + [AC_CHECK_DECLS([getenv]) + AC_CHECK_FUNCS(mbsrtowcs mempcpy wmempcpy) + AC_CHECK_HEADERS(wchar.h wctype.h) + AC_LIBOBJ(fnmatch) + AC_CONFIG_LINKS([$1/fnmatch.h:$1/fnmatch_.h]) + AC_DEFINE(fnmatch, rpl_fnmatch, + [Define to rpl_fnmatch if the replacement function should be used.]) + ], + [:]) + fi +])# _AC_FUNC_FNMATCH + +# AC_FUNC_FNMATCH([DIR]) +# ---------------------- AC_DEFUN([AC_FUNC_FNMATCH], -[AC_CACHE_CHECK([for working GNU-style fnmatch], - [ac_cv_func_fnmatch_works], -# Some versions of Solaris, SCO, and the GNU C Library -# have a broken or incompatible fnmatch. -# So we run a test program. If we are cross-compiling, take no chance. -# Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test. -[AC_RUN_IFELSE([AC_LANG_PROGRAM([@%:@include ], - [exit (fnmatch ("a*", "abc", 0) != 0 - || fnmatch ("d*/*1", "d/s/1", FNM_FILE_NAME) != FNM_NOMATCH - || fnmatch ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0 - || fnmatch ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) != 0 - || fnmatch ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR) != 0);])], - [ac_cv_func_fnmatch_works=yes], - [ac_cv_func_fnmatch_works=no], - [ac_cv_func_fnmatch_works=no])]) -if test $ac_cv_func_fnmatch_works = yes; then - AC_DEFINE(HAVE_FNMATCH, 1, - [Define to 1 if your system has a working `fnmatch' function.]) -fi -])# AC_FUNC_FNMATCH +[_AC_FUNC_FNMATCH([$1], [POSIX], [ac_cv_func_fnmatch_works], [HAVE_FNMATCH])]) +# AC_FUNC_FNMATCH_GNU([DIR]) +# -------------------------- +AC_DEFUN([AC_FUNC_FNMATCH_GNU], +[AC_REQUIRE([AC_GNU_SOURCE]) + _AC_FUNC_FNMATCH([$1], [GNU], [ac_cv_func_fnmatch_gnu], [HAVE_FNMATCH_GNU])]) # AU::AM_FUNC_FNMATCH # AU::fp_FUNC_FNMATCH