]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(HAVE_WORKING_READDIR): Define to 0 if not defined.
authorJim Meyering <jim@meyering.net>
Sun, 4 May 2003 07:10:21 +0000 (07:10 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 4 May 2003 07:10:21 +0000 (07:10 +0000)
(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.

src/remove.c

index cf808dd21e51743f662832f0e5c65bacda7cd682..c5cba1e39cb3e64b6543a2259750b61eb16a4eab 100644 (file)
 # 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: