From edc30dad9e689aae4e6f5c291791d3630233b318 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 26 Apr 2022 14:54:26 -0700 Subject: [PATCH] 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 common 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. --- ChangeLog | 11 +++++++++++ doc/posix-functions/dirfd.texi | 9 +++++---- lib/glob.c | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e99fb51397..76e6b02a6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2022-04-26 Paul Eggert + + 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 common 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-20 Paul Eggert backupfile: fix bug when renaming simple backups 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 52c79b4cd8..5754ae2bae 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -1358,7 +1358,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; -- 2.39.5