autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AC_FUNC_FNMATCH jamboree patch


From: Paul Eggert
Subject: AC_FUNC_FNMATCH jamboree patch
Date: Fri, 17 May 2002 00:20:48 -0700 (PDT)

In an attempt to cut down on all the AC_FUNC_FNMATCH variants in the
GNU utilities, gettext, etc., I've added their functionality to
Autoconf proper, as follows.  I plan to use this macro in the next
Diffutils release.  For best results this patch will need a few
portability-related changes to the fnmatch implementation in the GNU C
library, which I'll submit for glibc review soon.  But the patch
should work even without these changes.

2002-05-16  Paul Eggert  <address@hidden>

        AC_FUNC_FNMATCH now tests only for POSIX compatibility.
        AC_FUNC_FNMATCH_GNU also tests for GNU extensions.
        Both macros now accept an optional source-dir arg.
        New macro AC_GNU_SOURCE to define _GNU_SOURCE.
        
        * NEWS: Document this.
        * doc/autoconf.texi (Particular Functions, UNIX Variants): Likewise.
        
        * lib/autoconf/functions.m4 (_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.

        * lib/autoconf/specific.m4 (AC_GNU_SOURCE): New macro.

diff -pru autoconf/NEWS autoconf-fnmatch/NEWS
--- autoconf/NEWS       2002-05-13 12:45:16.179204000 -0700
+++ autoconf-fnmatch/NEWS       2002-05-17 00:13:10.043081000 -0700
@@ -11,10 +11,15 @@
 
 ** Macros
 
+- AC_FUNC_FNMATCH now tests only for POSIX compatibility, reverting to
+  Autoconf 2.13 behavior.  The new macro AC_FUNC_FNMATCH_GNU also tests for
+  GNU extensions to fnmatch.  Both macros now accept an optional argument
+  specifying the directory that contains the replacement fnmatch source code.
 - AC_FUNC_GETLOADAVG now has an optional argument specifying the directory
   that contains getloadavg.c, and it tests whether getloadavg.c exists.
 - AC_FUNC_SETVBUF_REVERSED no longer fails when cross-compiling.
 - AC_PROG_CC_STDC is integrated into AC_PROG_CC.
+- New macro: AC_GNU_SOURCE.
 
 ** Bug fixes
 
diff -pru autoconf/doc/autoconf.texi autoconf-fnmatch/doc/autoconf.texi
--- autoconf/doc/autoconf.texi  2002-05-12 21:44:08.906207000 -0700
+++ autoconf-fnmatch/doc/autoconf.texi  2002-05-17 00:11:04.000000000 -0700
@@ -1,5 +1,5 @@
 \input texinfo @c -*-texinfo-*-
address@hidden $Id: autoconf.texi,v 1.623 2002/05/08 22:30:14 eggert Exp $
address@hidden $Id: autoconf.texi,v 1.624 2002/05/17 07:11:04 eggert Exp $
 @comment %**start of header
 @setfilename autoconf.info
 @include version.texi
@@ -3527,12 +3527,29 @@ If the @code{error_at_line} function is 
 @code{AC_LIBOBJ} replacement of @samp{error}.
 @end defmac
 
address@hidden AC_FUNC_FNMATCH
address@hidden AC_FUNC_FNMATCH (@ovar{dir})
 @acindex FUNC_FNMATCH
 @c @fuindex fnmatch
 @prindex @code{fnmatch}
-If the @code{fnmatch} function is available and works (unlike the one on
-Solaris 2.4), define @code{HAVE_FNMATCH}.
+If the @code{fnmatch} function conforms to @acronym{POSIX}, define
address@hidden  Detect common implementation bugs, for example,
+the bugs in Solaris 2.4.  If @var{dir} is nonempty, the files
address@hidden, @file{fnmatch_loop.c}, and @file{fnmatch_.h} in the
+directory @var{dor} are assumed to contain a copy of the source code
+of @acronym{GNU} @code{fnmatch}.  If necessary, this source code is
+compiled as an @code{AC_LIBOBJ} replacement, and the @file{fnmatch_.h}
+file is linked to @file{fnmatch.h} so that it can be included in place
+of the system @code{<fnmatch.h>}.
address@hidden defmac
+
address@hidden AC_FUNC_FNMATCH_GNU (@ovar{dir})
address@hidden FUNC_FNMATCH_GNU
address@hidden @fuindex fnmatch
address@hidden @code{fnmatch}
+Behave like @code{AC_FUNC_FNMATCH(@var{dir})}, but also test whether
address@hidden supports @acronym{GNU} extensions.  Detect common
+implementation bugs, for example, the bugs in the @acronym{GNU} C
+Library 2.1.
 @end defmac
 
 @defmac AC_FUNC_FORK
@@ -5348,6 +5365,14 @@ If on AIX, define @code{_ALL_SOURCE}.  A
 functions.  Should be called before any macros that run the C compiler.
 @end defmac
 
address@hidden AC_GNU_SOURCE
address@hidden GNU_SOURCE
address@hidden _GNU_SOURCE
+If using the GNU C library, define @code{_GNU_SOURCE}.  Allows the use
+of some @acronym{GNU} functions.  Should be called before any macros
+that run the C compiler.
address@hidden defmac
+
 @defmac AC_ISC_POSIX
 @acindex ISC_POSIX
 @ovindex LIBS
diff -pru autoconf/lib/autoconf/functions.m4 
autoconf-fnmatch/lib/autoconf/functions.m4
--- autoconf/lib/autoconf/functions.m4  2002-05-12 21:44:09.127201000 -0700
+++ autoconf-fnmatch/lib/autoconf/functions.m4  2002-05-16 19:47:05.736121000 
-0700
@@ -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 <fnmatch.h>
+#         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(address@hidden:@include <fnmatch.h>],
- [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
diff -pru autoconf/lib/autoconf/specific.m4 
autoconf-fnmatch/lib/autoconf/specific.m4
--- autoconf/lib/autoconf/specific.m4   2001-11-12 08:08:53.000000000 -0800
+++ autoconf-fnmatch/lib/autoconf/specific.m4   2002-05-14 09:16:06.006121000 
-0700
@@ -1,7 +1,8 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Macros that test for specific, unclassified, features.
-# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -340,6 +341,20 @@ AC_DEFUN([AC_SYS_POSIX_TERMIOS],
 ## ------------------------------------ ##
 
 
+# AC_GNU_SOURCE
+# --------------
+AC_DEFUN([AC_GNU_SOURCE],
+[AH_VERBATIM([_GNU_SOURCE],
+[/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif])dnl
+AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
+AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
+AC_DEFINE([_GNU_SOURCE])
+])
+
+
 # AC_CYGWIN
 # ---------
 # Check for Cygwin.  This is a way to set the right value for



reply via email to

[Prev in Thread] Current Thread [Next in Thread]