summaryrefslogtreecommitdiff
path: root/src/remove.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-05-16 20:28:53 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-05-16 20:28:53 +0000
commit002c26a1539c60a99353a189c59cd1689c9d42d1 (patch)
tree400223bc4009865ba53a21c3ee7a700fd4fbc990 /src/remove.c
parentd3ea604602ca622da2c5f2e0da88a95e5cb65002 (diff)
downloadcoreutils-002c26a1539c60a99353a189c59cd1689c9d42d1.tar.xz
Fix Cygwin porting problem reported by Eric Blake.
(DT_IS_DIR): Remove. (DT_IS_KNOWN, DT_MUST_BE): New macros. (remove_entry): Use them.
Diffstat (limited to 'src/remove.c')
-rw-r--r--src/remove.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/remove.c b/src/remove.c
index 7ff550729..083641dff 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -664,10 +664,16 @@ prompt (Dirstack_state const *ds, char const *filename,
}
#if HAVE_STRUCT_DIRENT_D_TYPE
-# define DT_IS_DIR(D) ((D)->d_type == DT_DIR)
+
+/* True if the type of the directory entry D is known. */
+# define DT_IS_KNOWN(d) ((d)->d_type != DT_UNKNOWN)
+
+/* True if the type of the directory entry D must be T. */
+# define DT_MUST_BE(d, t) ((d)->d_type == (t))
+
#else
-/* Use this only if the member exists -- i.e., don't return 0. */
-# define DT_IS_DIR(D) do_not_use_this_macro
+# define DT_IS_KNOWN(d) false
+# define DT_MUST_BE(d, t) false
#endif
#define DO_UNLINK(Filename, X) \
@@ -755,7 +761,7 @@ remove_entry (Dirstack_state const *ds, char const *filename,
unlink call. If FILENAME is a command-line argument, then dp is NULL,
so we'll first try to unlink it. Using unlink here is ok, because it
cannot remove a directory. */
- if ((dp && DT_IS_DIR (dp)) || is_dir == T_YES)
+ if ((dp && DT_MUST_BE (dp, DT_DIR)) || is_dir == T_YES)
return RM_NONEMPTY_DIR;
DO_UNLINK (filename, x);
@@ -777,11 +783,9 @@ remove_entry (Dirstack_state const *ds, char const *filename,
Then, if it's a non-directory, we can use unlink on it. */
if (is_dir == T_UNKNOWN)
{
-#if HAVE_STRUCT_DIRENT_D_TYPE
- if (dp && dp->d_type != DT_UNKNOWN)
- is_dir = DT_IS_DIR (dp) ? T_YES : T_NO;
+ if (dp && DT_IS_KNOWN (dp))
+ is_dir = DT_MUST_BE (dp, DT_DIR) ? T_YES : T_NO;
else
-#endif
{
struct stat sbuf;
if (lstat (filename, &sbuf))