From: Jim Meyering Date: Sun, 4 May 2003 07:10:21 +0000 (+0000) Subject: (HAVE_WORKING_READDIR): Define to 0 if not defined. X-Git-Tag: v5.0.1~602 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=87c13cce86896036b57ddada461219a32ff91c23;p=thirdparty%2Fcoreutils.git (HAVE_WORKING_READDIR): Define to 0 if not defined. (IF_READDIR_NEEDS_REWINDDIR): Remove. (remove_cwd_entries): Rewrite to avoid IF_READDIR_NEEDS_REWINDDIR, which was a bit weird because it couldn't be emulated by a function. --- diff --git a/src/remove.c b/src/remove.c index cf808dd21e..c5cba1e39c 100644 --- a/src/remove.c +++ b/src/remove.c @@ -55,10 +55,8 @@ # define ROOT_CAN_UNLINK_DIRS 1 #endif -#if HAVE_WORKING_READDIR -# define IF_READDIR_NEEDS_REWINDDIR(Code) /* empty */ -#else -# define IF_READDIR_NEEDS_REWINDDIR(Code) Code +#ifndef HAVE_WORKING_READDIR +# define HAVE_WORKING_READDIR 0 #endif enum Ternary @@ -810,7 +808,7 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb, DIR *dirp = opendir ("."); struct AD_ent *top = AD_stack_top (ds); enum RM_status status = top->status; - IF_READDIR_NEEDS_REWINDDIR (int performed_unlink_or_rmdir = 0); + bool need_rewinddir = false; assert (VALID_STATUS (status)); *subdir = NULL; @@ -846,18 +844,13 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb, /* Arrange to give a diagnostic after exiting this loop. */ dirp = NULL; } - else + else if (need_rewinddir) { -#if ! HAVE_WORKING_READDIR /* On buggy systems, call rewinddir if we've called unlink or rmdir since the opendir or a previous rewinddir. */ - if (performed_unlink_or_rmdir) - { - rewinddir (dirp); - performed_unlink_or_rmdir = 0; - continue; - } -#endif + rewinddir (dirp); + need_rewinddir = false; + continue; } break; } @@ -878,7 +871,7 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb, case RM_OK: /* On buggy systems, record the fact that we've just removed a directory entry. */ - IF_READDIR_NEEDS_REWINDDIR (performed_unlink_or_rmdir = 1); + need_rewinddir = ! HAVE_WORKING_READDIR; break; case RM_ERROR: