bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] fnmatch patch to assume C89 or better


From: Paul Eggert
Subject: [Bug-gnulib] fnmatch patch to assume C89 or better
Date: 08 Sep 2003 23:52:25 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I installed this:

2003-09-08  Paul Eggert  <address@hidden>

        * lib/fnmatch.h (__P): Remove.  All uses changed to assume
        prototypes.
        * lib/fnmatch.c: Include fnmatch.h first, to test interface.
        Include <string.h>, <stddef.h>, <stdlib.h> unconditionally.
        (getenv): Remove decl.
        (fnmatch): Define using a prototype.
        * lib/fnmatch_loop.c (FCT): Remove forward decl; no longer needed.
        (FCT): Define using a prototype.
        * m4/fnmatch.m4 (gl_PREREQ_FNMATCH_EXTRA): Remove.  All uses removed.

Index: lib/fnmatch_.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/fnmatch_.h,v
retrieving revision 1.2
diff -p -u -r1.2 fnmatch_.h
--- lib/fnmatch_.h      4 Aug 2003 23:22:47 -0000       1.2
+++ lib/fnmatch_.h      9 Sep 2003 06:44:48 -0000
@@ -22,19 +22,6 @@
 extern "C" {
 # endif
 
-# if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
-#  if !defined __GLIBC__ || !defined __P
-#   undef      __P
-#   define __P(protos) protos
-#  endif
-# else /* Not C++ or ANSI C.  */
-#  undef       __P
-#  define __P(protos)  ()
-/* We can get away without defining `const' here only because in this file
-   it is used only inside the prototype for `fnmatch', which is elided in
-   non-ANSI C where `const' is problematical.  */
-# endif /* C++ or ANSI C.  */
-
 /* We #undef these before defining them because some losing systems
    (HP-UX A.08.07 for example) define these in <unistd.h>.  */
 # undef        FNM_PATHNAME
@@ -66,8 +53,8 @@ extern "C" {
 
 /* Match NAME against the filename pattern PATTERN,
    returning zero if it matches, FNM_NOMATCH if not.  */
-extern int fnmatch __P ((const char *__pattern, const char *__name,
-                        int __flags));
+extern int fnmatch (const char *__pattern, const char *__name,
+                   int __flags);
 
 # ifdef        __cplusplus
 }
Index: lib/fnmatch.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/fnmatch.c,v
retrieving revision 1.23
diff -p -u -r1.23 fnmatch.c
--- lib/fnmatch.c       26 Jun 2002 06:17:35 -0000      1.23
+++ lib/fnmatch.c       9 Sep 2003 06:44:48 -0000
@@ -1,5 +1,5 @@
 /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002 Free Software Foundation, Inc.
+   2002, 2003 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
@@ -45,23 +45,14 @@ char *alloca ();
 # define __builtin_expect(expr, expected) (expr)
 #endif
 
-#include <assert.h>
-#include <errno.h>
 #include <fnmatch.h>
-#include <ctype.h>
-
-#if HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# if HAVE_STRINGS_H
-#  include <strings.h>
-# endif
-#endif
 
-#if defined STDC_HEADERS || defined _LIBC
-# include <stddef.h>
-# include <stdlib.h>
-#endif
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC)
 
@@ -178,10 +169,6 @@ extern int fnmatch (const char *pattern,
 /* Avoid depending on library functions or files
    whose names are inconsistent.  */
 
-# if !defined _LIBC && !defined getenv && !HAVE_DECL_GETENV
-extern char *getenv ();
-# endif
-
 # ifndef errno
 extern int errno;
 # endif
@@ -328,10 +315,7 @@ is_char_class (const wchar_t *wcs)
 
 
 int
-fnmatch (pattern, string, flags)
-     const char *pattern;
-     const char *string;
-     int flags;
+fnmatch (const char *pattern, const char *string, int flags)
 {
 # if HANDLE_MULTIBYTE
   if (__builtin_expect (MB_CUR_MAX, 1) != 1)
Index: lib/fnmatch_loop.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/fnmatch_loop.c,v
retrieving revision 1.3
diff -p -u -r1.3 fnmatch_loop.c
--- lib/fnmatch_loop.c  4 Aug 2003 23:23:27 -0000       1.3
+++ lib/fnmatch_loop.c  9 Sep 2003 06:44:49 -0000
@@ -17,9 +17,6 @@
 
 /* Match STRING against the filename pattern PATTERN, returning zero if
    it matches, nonzero if not.  */
-static int FCT (const CHAR *pattern, const CHAR *string,
-               const CHAR *string_end, int no_leading_period, int flags)
-     internal_function;
 static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
                const CHAR *string_end, int no_leading_period, int flags)
      internal_function;
@@ -27,12 +24,8 @@ static const CHAR *END (const CHAR *patt
 
 static int
 internal_function
-FCT (pattern, string, string_end, no_leading_period, flags)
-     const CHAR *pattern;
-     const CHAR *string;
-     const CHAR *string_end;
-     int no_leading_period;
-     int flags;
+FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
+     int no_leading_period, int flags)
 {
   register const CHAR *p = pattern, *n = string;
   register UCHAR c;
Index: m4/fnmatch.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/fnmatch.m4,v
retrieving revision 1.14
diff -p -u -r1.14 fnmatch.m4
--- m4/fnmatch.m4       28 Aug 2003 19:38:48 -0000      1.14
+++ m4/fnmatch.m4       9 Sep 2003 06:44:49 -0000
@@ -77,14 +77,6 @@ FNMATCH_H=fnmatch.h
 ])# _AC_LIBOBJ_FNMATCH
 
 
-# Additional prerequisites of lib/fnmatch.c, not part of _AC_LIBOBJ_FNMATCH.
-AC_DEFUN([gl_PREREQ_FNMATCH_EXTRA],
-[
-  AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_HEADERS_ONCE(string.h strings.h)
-])
-
-
 AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
 [
   FNMATCH_H=
@@ -92,7 +84,6 @@ AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
                       [rm -f lib/fnmatch.h],
                       [_AC_LIBOBJ_FNMATCH])
   if test $ac_cv_func_fnmatch_posix != yes; then
-    gl_PREREQ_FNMATCH_EXTRA
     dnl We must choose a different name for our function, since on ELF systems
     dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
     dnl compiled into a shared library.
@@ -113,7 +104,6 @@ AC_DEFUN([gl_FUNC_FNMATCH_GNU],
                       [rm -f lib/fnmatch.h],
                       [_AC_LIBOBJ_FNMATCH])
   if test $ac_cv_func_fnmatch_gnu != yes; then
-    gl_PREREQ_FNMATCH_EXTRA
     dnl We must choose a different name for our function, since on ELF systems
     dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
     dnl compiled into a shared library.




reply via email to

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