summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-08-06 15:08:27 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-08-06 15:08:59 -0700
commit2533aa89db0f7d6e4ece0d5246ddad63c8be628a (patch)
tree9d6164dd39d33ed92e090d823bb1e201f7992ba7
parent81852598aa3cd82cc8d3e594bc155cfa0190db1c (diff)
downloadgnulib-2533aa89db0f7d6e4ece0d5246ddad63c8be628a.tar.gz
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.
-rw-r--r--ChangeLog7
-rw-r--r--lib/glob-libc.h48
-rw-r--r--lib/glob.c46
-rw-r--r--modules/glob-h1
4 files changed, 68 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index cb65d202bd..e8a1f53fb5 100644
--- 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.
diff --git a/lib/glob-libc.h b/lib/glob-libc.h
index b3a48d3773..98b95d9ea3 100644
--- a/lib/glob-libc.h
+++ b/lib/glob-libc.h
@@ -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
diff --git a/lib/glob.c b/lib/glob.c
index e148f8d761..22c4595741 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -59,25 +59,37 @@
# 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. */
diff --git a/modules/glob-h b/modules/glob-h
index 64ad0ded86..c48c91c486 100644
--- a/modules/glob-h
+++ b/modules/glob-h
@@ -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|' \