]> Savannah Git Hosting - gnulib.git/commitdiff
glob: merge from glibc
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 6 Aug 2021 22:08:27 +0000 (15:08 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 6 Aug 2021 22:08:59 +0000 (15:08 -0700)
* lib/glob-libc.h, lib/glob.c: Merge changes from glibc 2.34.
The result should be copyable directly into glibc.
* modules/glob-h (glob-libc.gl.h): Also omit __THROWNL.

ChangeLog
lib/glob-libc.h
lib/glob.c
modules/glob-h

index cb65d202bd188364b8d1d792b28fd26cb4e4c534..e8a1f53fb5ad104d1eabe6e768206212e8f2714a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-08-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+       glob: merge from glibc
+       * lib/glob-libc.h, lib/glob.c: Merge changes from glibc 2.34.
+       The result should be copyable directly into glibc.
+       * modules/glob-h (glob-libc.gl.h): Also omit __THROWNL.
+
 2021-08-03  Simon Josefsson  <simon@josefsson.org>
 
        announce-gen: Print SHA1/B64(SHA256) instead of MD5/SHA1.
index b3a48d37732805a58e633f1506c076e8566cf41b..98b95d9ea3974b9e7612d4221640164f02e0a4e1 100644 (file)
@@ -46,14 +46,14 @@ __BEGIN_DECLS
 # define GLOB_ONLYDIR    (1 << 13)/* Match only directories.  */
 # define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
                                       if the user name is not available.  */
-# define __GLOB_FLAGS   (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
-                         GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
-                         GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE|     \
-                         GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
+# define __GLOB_FLAGS   (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS  \
+                         |GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND     \
+                         |GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE     \
+                         |GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
 #else
-# define __GLOB_FLAGS   (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
-                         GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
-                         GLOB_PERIOD)
+# define __GLOB_FLAGS   (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS  \
+                         |GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND     \
+                         |GLOB_PERIOD)
 #endif
 
 /* Error returns from 'glob'.  */
@@ -137,25 +137,47 @@ typedef struct
 #if !defined __USE_FILE_OFFSET64 || defined __GLOB_GNULIB
 extern int glob (const char *__restrict __pattern, int __flags,
                  int (*__errfunc) (const char *, int),
-                 glob_t *__restrict __pglob) __THROW;
+                 glob_t *__restrict __pglob) __THROWNL;
 
 /* Free storage allocated in PGLOB by a previous 'glob' call.  */
 extern void globfree (glob_t *__pglob) __THROW;
 #else
-extern int __REDIRECT_NTH (glob, (const char *__restrict __pattern,
-                                  int __flags,
-                                  int (*__errfunc) (const char *, int),
-                                  glob_t *__restrict __pglob), glob64);
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTHNL (glob, (const char *__restrict __pattern,
+                                   int __flags,
+                                   int (*__errfunc) (const char *, int),
+                                   glob_t *__restrict __pglob),
+                            __glob64_time64);
+
+extern void __REDIRECT_NTH (globfree, (glob_t *__pglob),
+                           __globfree64_time64);
+# else
+extern int __REDIRECT_NTHNL (glob, (const char *__restrict __pattern,
+                                    int __flags,
+                                    int (*__errfunc) (const char *, int),
+                                    glob_t *__restrict __pglob), glob64);
 
 extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
+# endif
 #endif
 
 #ifdef __USE_LARGEFILE64
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTHNL (glob64, (const char *__restrict __pattern,
+                                     int __flags,
+                                     int (*__errfunc) (const char *, int),
+                                     glob64_t *__restrict __pglob),
+                            __glob64_time64);
+
+extern void __REDIRECT_NTH (globfree64, (glob64_t *__pglob),
+                           __globfree64_time64);
+# else
 extern int glob64 (const char *__restrict __pattern, int __flags,
                    int (*__errfunc) (const char *, int),
-                   glob64_t *__restrict __pglob) __THROW;
+                   glob64_t *__restrict __pglob) __THROWNL;
 
 extern void globfree64 (glob64_t *__pglob) __THROW;
+# endif
 #endif
 
 
index e148f8d761d8012dd8be3c22eac93b1ae6c96b08..22c4595741fc0249c83ba0f68aad9d084a98fc92 100644 (file)
 # define readdir(str) __readdir64 (str)
 # define getpwnam_r(name, bufp, buf, len, res) \
     __getpwnam_r (name, bufp, buf, len, res)
-# define struct_stat64          struct stat64
 # define FLEXIBLE_ARRAY_MEMBER
+# ifndef struct_stat
+#  define struct_stat           struct stat
+# endif
+# ifndef struct_stat64
+#  define struct_stat64         struct stat64
+# endif
+# ifndef GLOB_LSTAT
+#  define GLOB_LSTAT            gl_lstat
+# endif
+# ifndef GLOB_STAT64
+#  define GLOB_STAT64           __stat64
+# endif
+# ifndef GLOB_LSTAT64
+#  define GLOB_LSTAT64          __lstat64
+# endif
 # include <shlib-compat.h>
 #else /* !_LIBC */
 # define __glob                 glob
 # define __getlogin_r(buf, len) getlogin_r (buf, len)
-# define __lstat64(fname, buf)  lstat (fname, buf)
-# if defined _WIN32 && !defined __CYGWIN__
-   /* Avoid GCC or clang warning.  The original __stat64 macro is unused.  */
-#  undef __stat64
-# endif
-# define __stat64(fname, buf)   stat (fname, buf)
 # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
-# define struct_stat64          struct stat
 # ifndef __MVS__
 #  define __alloca              alloca
 # endif
 # define __readdir              readdir
 # define COMPILE_GLOB64
+# define struct_stat            struct stat
+# define struct_stat64          struct stat
+# define GLOB_LSTAT             gl_lstat
+# define GLOB_STAT64            stat
+# define GLOB_LSTAT64           lstat
 #endif /* _LIBC */
 
 #include <fnmatch.h>
@@ -196,22 +208,14 @@ glob_lstat (glob_t *pglob, int flags, const char *fullname)
 {
 /* Use on glob-lstat-compat.c to provide a compat symbol which does not
    use lstat / gl_lstat.  */
-#ifdef GLOB_NO_LSTAT
-# define GL_LSTAT gl_stat
-# define LSTAT64 __stat64
-#else
-# define GL_LSTAT gl_lstat
-# define LSTAT64 __lstat64
-#endif
-
   union
   {
-    struct stat st;
+    struct_stat st;
     struct_stat64 st64;
   } ust;
   return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)
-          ? pglob->GL_LSTAT (fullname, &ust.st)
-          : LSTAT64 (fullname, &ust.st64));
+          ? pglob->GLOB_LSTAT (fullname, &ust.st)
+          : GLOB_LSTAT64 (fullname, &ust.st64));
 }
 
 /* Set *R = A + B.  Return true if the answer is mathematically
@@ -249,11 +253,11 @@ static int collated_compare (const void *, const void *) __THROWNL;
 static bool
 is_dir (char const *filename, int flags, glob_t const *pglob)
 {
-  struct stat st;
+  struct_stat st;
   struct_stat64 st64;
   return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)
           ? pglob->gl_stat (filename, &st) == 0 && S_ISDIR (st.st_mode)
-          : __stat64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));
+          : GLOB_STAT64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));
 }
 
 /* Find the end of the sub-pattern in a brace expression.  */
index 64ad0ded865771e3eff1c5d2b38eb3bc131c1b6d..c48c91c486949a1edca064d76ffc75b9d9c03f67 100644 (file)
@@ -58,6 +58,7 @@ glob-libc.gl.h: glob-libc.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e '/__BEGIN_DECLS/{ s/__BEGIN_DECLS/#ifdef __cplusplus%extern "C" {%#endif/; y/%/\n/; }' \
              -e '/__END_DECLS/{ s/__END_DECLS/#ifdef __cplusplus%}%#endif/; y/%/\n/; }' \
+             -e 's|__THROWNL||g' \
              -e 's|__THROW||g' \
              -e 's|__restrict|restrict|g' \
              -e 's|defined __USE_MISC|1|' \