find -prune now makes sure it has valid stat() information

* find/parser.c (parse_prune): -prune needs stat information if
-depth is not in use.
* find/pred.c (pred_prune): Assert that stat information is
available if needed.
* find/testsuite/find.posix/prune-stat.exp: New test.
* find/testsuite/find.posix/prune-stat.xo: New test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP, EXTRA_DIST_XO): Added
prune-stat.exp, prune-stat.xo.
* NEWS: Mention this bugfix.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
This commit is contained in:
Colin Watson
2009-05-07 22:11:09 +01:00
committed by James Youngman
parent 7f59cd5d71
commit e17bdbe04f
7 changed files with 36 additions and 5 deletions

View File

@@ -1,3 +1,15 @@
2009-05-07 Colin Watson <cjwatson@ubuntu.com>
* find/parser.c (parse_prune): -prune needs stat information if
-depth is not in use.
* find/pred.c (pred_prune): Assert that stat information is
available if needed.
* find/testsuite/find.posix/prune-stat.exp: New test.
* find/testsuite/find.posix/prune-stat.xo: New test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP, EXTRA_DIST_XO): Added
prune-stat.exp, prune-stat.xo.
* NEWS: Mention this bugfix.
2009-04-25 James Youngman <jay@gnu.org>
* AUTHORS: Add Andreas Metzler.

4
NEWS
View File

@@ -2,6 +2,10 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.4.2-git, YYYY-MM-DD
** Bug Fixes
find -prune now makes sure it has valid stat() information.
* Major changes in release 4.4.1, 2009-04-21
** Bug Fixes

View File

@@ -1982,7 +1982,8 @@ parse_prune (const struct parser_table* entry, char **argv, int *arg_ptr)
(void) arg_ptr;
our_pred = insert_primary (entry);
our_pred->need_stat = our_pred->need_type = false;
if (options.do_dir_first == false)
our_pred->need_stat = our_pred->need_type = false;
/* -prune has a side effect that it does not descend into
the current directory. */
our_pred->side_effects = true;

View File

@@ -1605,10 +1605,12 @@ pred_prune (const char *pathname, struct stat *stat_buf, struct predicate *pred_
(void) pathname;
(void) pred_ptr;
if (options.do_dir_first == true && /* no effect with -depth */
stat_buf != NULL &&
S_ISDIR(stat_buf->st_mode))
state.stop_at_current_level = true;
if (options.do_dir_first == true) { /* no effect with -depth */
assert (state.have_stat);
if (stat_buf != NULL &&
S_ISDIR(stat_buf->st_mode))
state.stop_at_current_level = true;
}
/* findutils used to return options.do_dir_first here, so that -prune
* returns true only if -depth is not in effect. But POSIX requires

View File

@@ -88,6 +88,7 @@ find.posix/perm-vanilla.xo \
find.posix/posixnot.xo \
find.posix/prune.xo \
find.posix/prune-result.xo \
find.posix/prune-stat.xo \
find.posix/sizes.xo \
find.posix/sizetype.xo \
find.posix/sv-bug-11175.xo \
@@ -205,6 +206,7 @@ find.posix/perm-vanilla.exp \
find.posix/posixnot.exp \
find.posix/prune.exp \
find.posix/prune-result.exp \
find.posix/prune-stat.exp \
find.posix/size-invalid.exp \
find.posix/size-missing.exp \
find.posix/sizes.exp \

View File

@@ -0,0 +1,7 @@
# tests that -prune gets stat information
exec rm -rf tmp
exec mkdir tmp tmp/a
exec touch tmp/b
exec mkdir tmp/c
find_start p {tmp -name b -prune -o -print }
exec rm -rf tmp

View File

@@ -0,0 +1,3 @@
tmp
tmp/a
tmp/c