findutils-patches
[Top][All Lists]
Advanced

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

[Findutils-patches] Re: Fwd: [Patch] Add dirent.d_type support to Cygwin


From: Jim Meyering
Subject: [Findutils-patches] Re: Fwd: [Patch] Add dirent.d_type support to Cygwin 1.7 ?
Date: Sat, 29 Nov 2008 16:59:53 +0100

"James Youngman" <address@hidden> wrote:
> [TO -= bug-gnulib, TO += findutils-patches]
>
> I'm planning to apply Jim's patch to findutils soon.   I have snipped
> out the gnulib patch he sent, because he later changed it.
...
> +         state.have_stat = false; // FIXME: depends on FTS_NOSTAT

Here's the identical patch, but  without that C++ style // FIXME comment.
It was more a note to myself than anything.


>From 317bfcc76c5b522a5cfa51ce5c0b256306a9e888 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 28 Nov 2008 17:21:55 +0100
Subject: [PATCH] find: avoid redundant stat calls when dirent.d_type is usable

When fts provides usable dirent.d_type information, and the only
stat information required by find's predicates the type information
normally found in stat.st_mode, skip the now-redundant stat calls.
This change is useful only with the very latest version of fts.c
from gnulib.
* find/ftsfind.c (find): Use dirent.d_type info from latest fts.
---
 find/ftsfind.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/find/ftsfind.c b/find/ftsfind.c
index 543b80f..e505518 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -472,8 +472,8 @@ consider_visiting(FTS *p, FTSENT *ent)
       || ent->fts_info == FTS_NS /* e.g. symlink loop */)
     {
       assert (!state.have_stat);
-      assert (!state.have_type);
-      state.type = mode = 0;
+      assert (state.type != 0);
+      mode = state.type;
     }
   else
     {
@@ -615,8 +615,8 @@ find(char *arg)
       while ( (ent=fts_read(p)) != NULL )
        {
          state.have_stat = false;
-         state.have_type = false;
-         state.type = 0;
+         state.have_type = !!ent->fts_statp->st_mode;
+         state.type = state.have_type ? ent->fts_statp->st_mode : 0;
          consider_visiting(p, ent);
        }
       fts_close(p);
--
1.6.0.4.1101.g642f8




reply via email to

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