0c7b6a
From 193f1e81edd6b1b56b0eb0ff8aa4b41c7b4257b4 Mon Sep 17 00:00:00 2001
0c7b6a
From: Paul Eggert <eggert@cs.ucla.edu>
0c7b6a
Date: Sun, 24 Sep 2017 09:12:58 -0400
0c7b6a
Subject: glob: Do not assume glibc glob internals.
0c7b6a
0c7b6a
It has been proposed that glibc glob start using gl_lstat,
0c7b6a
which the API allows it to do.  GNU 'make' should not get in
0c7b6a
the way of this.  See:
0c7b6a
https://sourceware.org/ml/libc-alpha/2017-09/msg00409.html
0c7b6a
0c7b6a
* dir.c (local_lstat): New function, like local_stat.
0c7b6a
(dir_setup_glob): Use it to initialize gl_lstat too, as the API
0c7b6a
requires.
0c7b6a
---
0c7b6a
 dir.c | 29 +++++++++++++++++++++++++++--
0c7b6a
 1 file changed, 27 insertions(+), 2 deletions(-)
0c7b6a
0c7b6a
diff --git a/dir.c b/dir.c
0c7b6a
index adbb8a9..c343e4c 100644
0c7b6a
--- a/dir.c
0c7b6a
+++ b/dir.c
0c7b6a
@@ -1299,15 +1299,40 @@ local_stat (const char *path, struct stat *buf)
0c7b6a
 }
0c7b6a
 #endif
0c7b6a
 
0c7b6a
+/* Similarly for lstat.  */
0c7b6a
+#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
0c7b6a
+# ifndef VMS
0c7b6a
+#  ifndef HAVE_SYS_STAT_H
0c7b6a
+int lstat (const char *path, struct stat *sbuf);
0c7b6a
+#  endif
0c7b6a
+# else
0c7b6a
+    /* We are done with the fake lstat.  Go back to the real lstat */
0c7b6a
+#   ifdef lstat
0c7b6a
+#     undef lstat
0c7b6a
+#   endif
0c7b6a
+# endif
0c7b6a
+# define local_lstat lstat
0c7b6a
+#elif defined(WINDOWS32)
0c7b6a
+/* Windows doesn't support lstat().  */
0c7b6a
+# define local_lstat local_stat
0c7b6a
+#else
0c7b6a
+static int
0c7b6a
+local_lstat (const char *path, struct stat *buf)
0c7b6a
+{
0c7b6a
+  int e;
0c7b6a
+  EINTRLOOP (e, lstat (path, buf));
0c7b6a
+  return e;
0c7b6a
+}
0c7b6a
+#endif
0c7b6a
+
0c7b6a
 void
0c7b6a
 dir_setup_glob (glob_t *gl)
0c7b6a
 {
0c7b6a
   gl->gl_opendir = open_dirstream;
0c7b6a
   gl->gl_readdir = read_dirstream;
0c7b6a
   gl->gl_closedir = free;
0c7b6a
+  gl->gl_lstat = local_lstat;
0c7b6a
   gl->gl_stat = local_stat;
0c7b6a
-  /* We don't bother setting gl_lstat, since glob never calls it.
0c7b6a
-     The slot is only there for compatibility with 4.4 BSD.  */
0c7b6a
 }
0c7b6a
 
0c7b6a
 void
0c7b6a
-- 
0c7b6a
cgit v1.0-41-gc330
0c7b6a