Ensure that 'glob' stays under LGPLv2+.
authorBruno Haible <bruno@clisp.org>
Mon, 31 Dec 2007 10:51:57 +0000 (11:51 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 31 Dec 2007 10:51:57 +0000 (11:51 +0100)
ChangeLog
lib/glob.c
m4/glob.m4
modules/glob

index 729dd3a..5d9655b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-12-25  Bruno Haible  <bruno@clisp.org>
+
+       Fixup after 2007-10-17 commit. Ensure that 'glob' stays under LGPLv2+.
+       * lib/glob.c: Don't include openat.h.
+       (link_exists2_p): Add back the code that deals with the
+       !GLOB_ALTDIRFUNC case.
+       (link_exists_p) [!_LIBC && !HAVE_FSTATAT]: Just call link_exists2_p and
+       let it do the filename concatenation.
+       * m4/glob.m4 (gl_PREREQ_GLOB): Add check for fstatat.
+       * modules/glob (Depends-on): Remove openat.
+
 2007-12-31  Bruno Haible  <bruno@clisp.org>
 
        * modules/dirfd (License): Change to LGPLv2+.
index bb8417f..0229dbd 100644 (file)
 
 #ifndef _LIBC
 # include "dirfd.h"
-# include "openat.h"
 #endif
 
 #ifdef _SC_GETPW_R_SIZE_MAX
@@ -1218,13 +1217,17 @@ weak_alias (__glob_pattern_p, glob_pattern_p)
 #endif /* !GLOB_ONLY_P */
 
 
+#if !defined _LIBC || !defined GLOB_ONLY_P
 /* We put this in a separate function mainly to allow the memory
    allocated with alloca to be recycled.  */
-#if !defined _LIBC || !defined GLOB_ONLY_P
 static int
 __attribute_noinline__
 link_exists2_p (const char *dir, size_t dirlen, const char *fname,
-               glob_t *pglob)
+               glob_t *pglob
+# if !defined _LIBC && !HAVE_FSTATAT
+               , int flags
+# endif
+               )
 {
   size_t fnamelen = strlen (fname);
   char *fullname = __alloca (dirlen + 1 + fnamelen + 1);
@@ -1233,6 +1236,13 @@ link_exists2_p (const char *dir, size_t dirlen, const char *fname,
   mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
           fname, fnamelen + 1);
 
+# if !defined _LIBC && !HAVE_FSTATAT
+  if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1))
+    {
+      struct_stat64 st64;
+      return __stat64 (fullname, &st64) == 0;
+    }
+# endif
   return (*pglob->gl_stat) (fullname, &st) == 0;
 }
 
@@ -1241,6 +1251,7 @@ static int
 link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
               glob_t *pglob, int flags)
 {
+# if defined _LIBC || HAVE_FSTATAT
   if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
     return link_exists2_p (dir, dirlen, fname, pglob);
   else
@@ -1248,6 +1259,9 @@ link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
       struct_stat64 st64;
       return __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0;
     }
+# else
+  return link_exists2_p (dir, dirlen, fname, pglob, flags);
+# endif
 }
 #endif
 
index 1b4c976..bc3e67c 100644 (file)
@@ -1,4 +1,4 @@
-# glob.m4 serial 9
+# glob.m4 serial 10
 dnl Copyright (C) 2005-2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -82,5 +82,5 @@ AC_DEFUN([gl_PREREQ_GLOB],
     HAVE_SYS_CDEFS_H=0
   fi
   AC_SUBST([HAVE_SYS_CDEFS_H])
-  AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
+  AC_CHECK_FUNCS_ONCE([fstatat getlogin_r getpwnam_r])dnl
 ])
index dcdf752..4086a99 100644 (file)
@@ -16,7 +16,6 @@ extensions
 fnmatch
 getlogin_r
 mempcpy
-openat
 strdup
 sys_stat
 unistd