findutils-patches
[Top][All Lists]
Advanced

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

[Findutils-patches] [PATCH] Fix Savannah bug 29460, -printf %Y fails in


From: James Youngman
Subject: [Findutils-patches] [PATCH] Fix Savannah bug 29460, -printf %Y fails in $CWD-dependent way
Date: Wed, 7 Apr 2010 10:27:46 +0100

* find/pred.c (do_fprintf): Use optionl_stat and optionp_stat
instead of stat and lstat, because the first two functions are
aware of state.cwd_dir_fd.
* find/testsuite/find.gnu/printf-nonlocal-symlink.exp: A new test
case for this bug.
* find/testsuite/find.gnu/printf-nonlocal-symlink.xo: Expected
output for this test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test
case.
(EXTRA_DIST_XO): Add the expected-output file.

Signed-off-by: James Youngman <address@hidden>
---
 ChangeLog                                          |   14 ++++++++++++++
 find/pred.c                                        |    2 +-
 find/testsuite/Makefile.am                         |    2 ++
 .../testsuite/find.gnu/printf-nonlocal-symlink.exp |    7 +++++++
 find/testsuite/find.gnu/printf-nonlocal-symlink.xo |    1 +
 5 files changed, 25 insertions(+), 1 deletions(-)
 create mode 100644 find/testsuite/find.gnu/printf-nonlocal-symlink.exp
 create mode 100644 find/testsuite/find.gnu/printf-nonlocal-symlink.xo

diff --git a/ChangeLog b/ChangeLog
index 4e712b9..a92d40d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-04-07  James Youngman  <address@hidden>
+
+       Fix Savannah bug 29460, -printf %Y fails in $CWD-dependent way
+       * find/pred.c (do_fprintf): Use optionl_stat and optionp_stat
+       instead of stat and lstat, because the first two functions are
+       aware of state.cwd_dir_fd.
+       * find/testsuite/find.gnu/printf-nonlocal-symlink.exp: A new test
+       case for this bug.
+       * find/testsuite/find.gnu/printf-nonlocal-symlink.xo: Expected
+       output for this test.
+       * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test
+       case.
+       (EXTRA_DIST_XO): Add the expected-output file.
+
 2010-04-05  James Youngman  <address@hidden>
 
        Use set_program_name in regexprops.
diff --git a/find/pred.c b/find/pred.c
index 29fad54..1e0e891 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1030,7 +1030,7 @@ do_fprintf (struct format_val *dest,
                /* If we would normally follow links, do not do so.
                 * If we would normally not follow links, do so.
                 */
-               if ((following_links () ? lstat : stat)
+               if ((following_links () ? optionp_stat : optionl_stat)
                    (state.rel_pathname, &sbuf) != 0)
                  {
                    if ( errno == ENOENT )
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index 7f99dad..4ce87f6 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -48,6 +48,7 @@ find.gnu/posix-dflt.xo \
 find.gnu/posix-h.xo \
 find.gnu/posix-l.xo \
 find.gnu/printfHdfl.xo \
+find.gnu/printf-nonlocal-symlink.xo \
 find.gnu/printf-slash.xo \
 find.gnu/printf-symlink.xo \
 find.gnu/printf-h.xo \
@@ -160,6 +161,7 @@ find.gnu/posix-perminvalid.exp \
 find.gnu/printfHdfl.exp \
 find.gnu/printf.exp \
 find.gnu/printf.exp \
+find.gnu/printf-nonlocal-symlink.exp \
 find.gnu/printf-slash.exp \
 find.gnu/printf-symlink.exp \
 find.gnu/printf-h.exp \
diff --git a/find/testsuite/find.gnu/printf-nonlocal-symlink.exp 
b/find/testsuite/find.gnu/printf-nonlocal-symlink.exp
new file mode 100644
index 0000000..f8e61e1
--- /dev/null
+++ b/find/testsuite/find.gnu/printf-nonlocal-symlink.exp
@@ -0,0 +1,7 @@
+exec rm -rf tmp
+exec mkdir tmp
+exec mkdir tmp/foo
+exec touch tmp/foo/file
+exec ln -s file tmp/foo/LINK
+find_start p {tmp  -type l -printf "%p: %Y %y\n" }
+exec rm -rf tmp
diff --git a/find/testsuite/find.gnu/printf-nonlocal-symlink.xo 
b/find/testsuite/find.gnu/printf-nonlocal-symlink.xo
new file mode 100644
index 0000000..fcb338a
--- /dev/null
+++ b/find/testsuite/find.gnu/printf-nonlocal-symlink.xo
@@ -0,0 +1 @@
+tmp/foo/LINK: f l
-- 
1.7.0





reply via email to

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