From b445af98c22cd2d13673e2699a77ab728a7073b0 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Wed, 4 Mar 2009 00:04:36 +0000 Subject: [PATCH 3/3] Fix Savannah bug #25359, more efficiently (suggestion by Nick Fortino). To: address@hidden * find/ftsfind.c (consider_visiting): revert the previous change which discarded type information, and instead simply ensure that state.curdepth holds the correct value before digest_mode() is called. (find): revert the previous change. (visit): we no longer need to set state.curdepth here, since it will have been set already in consider_visiting(). Signed-off-by: James Youngman --- ChangeLog | 11 +++++++++++ find/ftsfind.c | 35 ++++++++--------------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index e75fe72..b419dd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-03-03 James Youngman + + Fix Savannah bug #25359, more efficiently (suggestion by Nick Fortino). + * find/ftsfind.c (consider_visiting): revert the previous change + which discarded type information, and instead simply ensure that + state.curdepth holds the correct value before digest_mode() is + called. + (find): revert the previous change. + (visit): we no longer need to set state.curdepth here, since it + will have been set already in consider_visiting(). + 2009-03-02 James Youngman Fix Savannah bug #25359. diff --git a/find/ftsfind.c b/find/ftsfind.c index 1c1634e..e7f6fbe 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -227,7 +227,6 @@ visit(FTS *p, FTSENT *ent, struct stat *pstat) { struct predicate *eval_tree; - state.curdepth = ent->fts_level; state.have_stat = (ent->fts_info != FTS_NS) && (ent->fts_info != FTS_NSOK); state.rel_pathname = ent->fts_accpath; state.cwd_dir_fd = p->fts_cwd_fd; @@ -472,22 +471,8 @@ consider_visiting(FTS *p, FTSENT *ent) || ent->fts_info == FTS_NS /* e.g. symlink loop */) { assert (!state.have_stat); - if ((options.symlink_handling == SYMLINK_DEREF_ARGSONLY) - && (S_ISLNK(mode))) - { - /* Force whichever stat version we should be using; the file - * type information from fts doesn't take account of -H. - * This conditional fixes Savannah bug 25359, but the bug - * only manifests on filesystems which populate d_type. - */ - state.have_type = 0; - state.type = mode = 0; - } - else - { - assert (ent->fts_info == FTS_NSOK || state.type != 0); - mode = state.type; - } + assert (ent->fts_info == FTS_NSOK || state.type != 0); + mode = state.type; } else { @@ -504,6 +489,10 @@ consider_visiting(FTS *p, FTSENT *ent) } } + /* update state.curdepth before calling digest_mode(), because digest_mode + * may call following_links(). + */ + state.curdepth = ent->fts_level; if (mode) { if (!digest_mode(mode, ent->fts_path, ent->fts_name, &statbuf, 0)) @@ -629,16 +618,8 @@ find(char *arg) while ( (ent=fts_read(p)) != NULL ) { state.have_stat = false; - if (options.symlink_handling == SYMLINK_DEREF_ARGSONLY) - { - state.have_type = false; - state.type = 0; - } - else - { - state.have_type = !!ent->fts_statp->st_mode; - state.type = state.have_type ? ent->fts_statp->st_mode : 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.5.6.5