aboutsummaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-12-16 17:50:48 +0000
committerUlrich Drepper <drepper@redhat.com>2000-12-16 17:50:48 +0000
commit3d73829c187f7d34c5c3c44047da1137adf36d86 (patch)
tree0f4757a60e32527b36721436d93af71013422081 /io
parent887e7ab6c5a13398e5986c7054235a135e6429f9 (diff)
downloadglibc-3d73829c187f7d34c5c3c44047da1137adf36d86.tar
glibc-3d73829c187f7d34c5c3c44047da1137adf36d86.tar.gz
glibc-3d73829c187f7d34c5c3c44047da1137adf36d86.tar.bz2
glibc-3d73829c187f7d34c5c3c44047da1137adf36d86.zip
Update.
2000-12-16 Ulrich Drepper <drepper@redhat.com> * timezone/asia: Update from tzdata2000h. * timezone/australasia: Likewise. * timezone/backward: Likewise. * timezone/europe: Likewise. * timezone/northamerica: Likewise. * timezone/southamerica: Likewise. * timezone/zone.tab: Likewise. 2000-12-14 Jakub Jelinek <jakub@redhat.com> * io/ftw.c (ftw_dir): If process_entry returned non-zero result and dir.stream is NULL, only free dir.content. * io/ftwtest.c (cb, main): Add --early-exit option to test it. * io/ftwtest-sh: Test with --early-exit.
Diffstat (limited to 'io')
-rw-r--r--io/ftw.c6
-rw-r--r--io/ftwtest-sh19
-rw-r--r--io/ftwtest.c19
3 files changed, 31 insertions, 13 deletions
diff --git a/io/ftw.c b/io/ftw.c
index e832fbbc99..01abb63782 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -426,15 +426,11 @@ ftw_dir (struct ftw_data *data, struct STAT *st)
int save_err;
char *runp = dir.content;
- assert (result == 0);
-
- while (*runp != '\0')
+ while (result == 0 && *runp != '\0')
{
char *endp = strchr (runp, '\0');
result = process_entry (data, &dir, runp, endp - runp);
- if (result != 0)
- break;
runp = endp + 1;
}
diff --git a/io/ftwtest-sh b/io/ftwtest-sh
index 837470da47..7fc82088ec 100644
--- a/io/ftwtest-sh
+++ b/io/ftwtest-sh
@@ -5,10 +5,12 @@ objpfx=$1
# We expect one parameter which is the test program. This must understand
# a number options:
-# --phys use the FTW_PHYS flag
-# --chdir use the FTW_CHDIR and print the current directory in the
-# callback
-# --depth use the FTW_DEPTH flag
+# --phys use the FTW_PHYS flag
+# --chdir use the FTW_CHDIR and print the current directory
+# in the callback
+# --depth use the FTW_DEPTH flag
+# --early-exit print file@2 item only and return non-zero from the
+# callback when it is seen
testprogram=$2
# We cannot test this as root.
@@ -136,6 +138,15 @@ base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd
EOF
rm $testout
+LD_LIBRARY_PATH=$objpfx $ldso $testprogram --early-exit $tmpdir |
+ sort > $testout
+
+cat <<EOF | cmp $testout - || exit 1
+base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
+succeeded
+EOF
+rm $testout
+
rm -fr $tmpdir
exit 0
diff --git a/io/ftwtest.c b/io/ftwtest.c
index 6079265175..851ed1d587 100644
--- a/io/ftwtest.c
+++ b/io/ftwtest.c
@@ -3,6 +3,7 @@
#include <mcheck.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -10,12 +11,14 @@
int do_depth;
int do_chdir;
int do_phys;
+int do_exit;
struct option options[] =
{
{ "depth", no_argument, &do_depth, 1 },
{ "chdir", no_argument, &do_chdir, 1 },
{ "phys", no_argument, &do_phys, 1 },
+ { "early-exit", no_argument, &do_exit, 1 },
{ NULL, 0, NULL, 0 }
};
@@ -31,9 +34,12 @@ const char *flag2name[] =
};
-int
+static int
cb (const char *name, const struct stat *st, int flag, struct FTW *f)
{
+ if (do_exit && strcmp (name + f->base, "file@2"))
+ return 0;
+
printf ("base = \"%.*s\", file = \"%s\", flag = %s",
f->base, name, name + f->base, flag2name[flag]);
if (do_chdir)
@@ -43,7 +49,7 @@ cb (const char *name, const struct stat *st, int flag, struct FTW *f)
free (cwd);
}
printf (", level = %d\n", f->level);
- return 0;
+ return do_exit ? 26 : 0;
}
int
@@ -64,8 +70,13 @@ main (int argc, char *argv[])
if (do_phys)
flag |= FTW_PHYS;
- r = nftw (optind < argc ? argv[optind] : ".", cb, 3, flag);
- if (r)
+ r = nftw (optind < argc ? argv[optind] : ".", cb, do_exit ? 1 : 3, flag);
+ if (r < 0)
perror ("nftw");
+ if (do_exit)
+ {
+ puts (r == 26 ? "succeeded" : "failed");
+ return r == 26 ? 0 : 1;
+ }
return r;
}