On 4/21/22 00:41, Benno Schulenberg wrote:
glob.c:1361:21: error: request for member ‘dd_fd’ in something not a structure
or
union
Thanks for reporting that. That's due to a bug in NetBSD 9.2's
implementation of dirfd. It's not implemented as a function (which is a
bug in and of itself; POSIX says it must work even if you #undef it),
and its macro doesn't work with a void * argument (where a function
would work).
A good way to fix this would be to modify the dirfd module to work
around the NetBSD bugs. I took the easy way out, though, and simply
documented the bugs and modified glob to not run afoul of the bugs, by
installing the attached patch into Gnulib.diff --git a/ChangeLog b/ChangeLog
index ddd4826bcf..3ce3d85884 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-04-26 Paul Eggert <egg...@cs.ucla.edu>
+
+ glob: port to NetBSD 9.2
+ Problem reported by Benno Schulenberg in:
+ https://lists.gnu.org/r/bug-gnulib/2022-04/msg00052.html
+ * doc/posix-functions/dirfd.texi: Document NetBSD 9.2 portability
+ bugs. Remove an old comment about errno that is no longer true
+ of POSIX 2018.
+ * lib/glob.c (glob_in_dir): Convert dirfd arg from void *
+ to DIR * before passing it to dirfd.
+
2022-04-21 Paul Eggert <egg...@cs.ucla.edu>
regex: match [...---...] like V7 grep
diff --git a/doc/posix-functions/dirfd.texi b/doc/posix-functions/dirfd.texi
index 46ad5fe7d4..d0f6c8cdcd 100644
--- a/doc/posix-functions/dirfd.texi
+++ b/doc/posix-functions/dirfd.texi
@@ -18,8 +18,9 @@ Portability problems not fixed by Gnulib:
@item
This function always fails on some platforms:
mingw.
-@end itemize
-With the @code{dirfd} module, this functions always sets @code{errno} when it
-fails. (POSIX does not require that @code{dirfd} sets @code{errno} when it
-fails.)
+@item
+There is a @code{dirfd} macro but no function, and the macro does not
+work with an argument of type @code{void *}, as a function would:
+NetBSD 9.2.
+@end itemize
diff --git a/lib/glob.c b/lib/glob.c
index f6993a3706..57cb3bd1d1 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -1357,7 +1357,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
}
else
{
- int dfd = dirfd (stream);
+ DIR *dirp = stream;
+ int dfd = dirfd (dirp);
int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
| ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0));
flags |= GLOB_MAGCHAR;