diff options
author | Jim Meyering <jim@meyering.net> | 2003-05-04 07:10:21 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-05-04 07:10:21 +0000 |
commit | 87c13cce86896036b57ddada461219a32ff91c23 (patch) | |
tree | 5d1f63866fe75bce186701d4222c37c5861c7d34 | |
parent | c48100ccf1ede206548e35d526bbad60c3c64070 (diff) | |
download | coreutils-87c13cce86896036b57ddada461219a32ff91c23.tar.xz |
(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.
-rw-r--r-- | src/remove.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/remove.c b/src/remove.c index cf808dd21..c5cba1e39 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: |