Gisle Vanem wrote:
But maybe this should be:
   # ifdef HAVE_OPENDIR
   #  undef opendir
   # endif
   # ifdef HAVE_CLOSEDIR
   #  undef closedir
   # endif

Yes, I like this better.  Does the attached patch work for you?

This brings up my confusion I have with stuff like
what value REPLACE_CLOSEDIR etc. should have.

Sorry, I didn't quite follow that part of your email.  It is a confusing 
area....
>From 42402278d2e5ea9839e9eee79fdafa53e1d57079 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 21 Jan 2015 17:56:34 -0800
Subject: [PATCH] getcwd, glob, scandir: port to MSVC

Problem reported by Gisle Vanem in:
http://lists.gnu.org/archive/html/bug-gnulib/2015-01/msg00066.html
* lib/getcwd.c, lib/glob.c, lib/scandir.c:
Do not #undef opendir and closedir if !HAVE_OPENDIR.
---
 ChangeLog     | 8 ++++++++
 lib/getcwd.c  | 7 +++++--
 lib/glob.c    | 6 ++++--
 lib/scandir.c | 6 ++++--
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0c12d3..8839306 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-01-21  Paul Eggert  <egg...@cs.ucla.edu>
+
+	getcwd, glob, scandir: port to MSVC
+	Problem reported by Gisle Vanem in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2015-01/msg00066.html
+	* lib/getcwd.c, lib/glob.c, lib/scandir.c:
+	Do not #undef opendir and closedir if !HAVE_OPENDIR.
+
 2015-01-20  Daiki Ueno  <u...@gnu.org>
 
 	libunistring: bump version of unitypes dependants
diff --git a/lib/getcwd.c b/lib/getcwd.c
index 20efabd..9eedc9d 100644
--- a/lib/getcwd.c
+++ b/lib/getcwd.c
@@ -93,8 +93,11 @@
    FIXME - if the kernel ever adds support for multi-thread safety for
    avoiding standard fds, then we should use opendir_safer and
    openat_safer.  */
-#undef opendir
-#undef closedir
+#if HAVE_OPENDIR
+# undef opendir
+# undef closedir
+#endif
+
 
 /* Get the name of the current working directory, and put it in SIZE
    bytes of BUF.  Returns NULL if the directory couldn't be determined or
diff --git a/lib/glob.c b/lib/glob.c
index f13cb8a..6353862 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -188,8 +188,10 @@ static const char *next_brace_sub (const char *begin, int flags) __THROWNL;
    therefore save some unnecessary recursion in fchdir.c and opendir_safer.c.
    FIXME - if the kernel ever adds support for multi-thread safety for
    avoiding standard fds, then we should use opendir_safer.  */
-# undef opendir
-# undef closedir
+# if HAVE_OPENDIR
+#  undef opendir
+#  undef closedir
+# endif
 
 # if HAVE_ALLOCA
 /* The OS usually guarantees only one guard page at the bottom of the stack,
diff --git a/lib/scandir.c b/lib/scandir.c
index 3ea755e..45ce473 100644
--- a/lib/scandir.c
+++ b/lib/scandir.c
@@ -58,8 +58,10 @@
    therefore save some unnecessary recursion in fchdir.c and opendir_safer.c.
    FIXME - if the kernel ever adds support for multi-thread safety for
    avoiding standard fds, then we should use opendir_safer.  */
-# undef opendir
-# undef closedir
+# if HAVE_OPENDIR
+#  undef opendir
+#  undef closedir
+# endif
 #endif
 
 #ifndef SCANDIR_CANCEL
-- 
2.1.0

Reply via email to