bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with readdir in Darwin-6.5 and hfs?


From: Paul Eggert
Subject: Re: problem with readdir in Darwin-6.5 and hfs?
Date: 03 May 2003 21:28:47 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

How about the following further patch, on stylistic grounds?  The
macro IF_READDIR_NEEDS_REWINDDIR is a bit weird because it can't be
emulated by a function.  The new code should be just as fast as the
old, if the compiler does reasonable optimizations.

As I get older, I get more confused by C macro weirdnesses
(even though I've been guilty of them myself...).

2003-05-04  Paul Eggert  <address@hidden>

        * src/remove.c (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.

Index: src/remove.c
===================================================================
RCS file: /home/m/meyering/fetish/cu/src/remove.c,v
retrieving revision 1.87
diff -p -u -r1.87 remove.c
--- src/remove.c        2 May 2003 12:53:02 -0000       1.87
+++ src/remove.c        4 May 2003 04:21:15 -0000
@@ -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, 
   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, 
              /* 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, 
        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:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]