diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-31 13:33:18 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-31 13:33:18 +0000 |
commit | 32c075e1f01849e161724bbd400ba77244e482cc (patch) | |
tree | 5f083a3f352104f32bb6c902d57fa3f294bd8d4d /io/ftw.c | |
parent | Include errno.h. Change main() to do_test(). Define TEST_FUNCTION. Include ... (diff) | |
download | glibc-32c075e1f01849e161724bbd400ba77244e482cc.tar.gz glibc-32c075e1f01849e161724bbd400ba77244e482cc.tar.bz2 glibc-32c075e1f01849e161724bbd400ba77244e482cc.zip |
.
Diffstat (limited to 'io/ftw.c')
-rw-r--r-- | io/ftw.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -1,5 +1,5 @@ /* File tree walker functions. - Copyright (C) 1996-2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1996-2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -348,8 +348,17 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp) } else { - const char *name = ((data->flags & FTW_CHDIR) - ? data->dirbuf + data->ftw.base: data->dirbuf); + const char *name; + + if (data->flags & FTW_CHDIR) + { + name = data->dirbuf + data->ftw.base; + if (name[0] == '\0') + name = "."; + } + else + name = data->dirbuf; + dirp->stream = __opendir (name); } @@ -721,9 +730,16 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, /* Get stat info for start directory. */ if (result == 0) { - const char *name = ((data.flags & FTW_CHDIR) - ? data.dirbuf + data.ftw.base - : data.dirbuf); + const char *name; + + if (data.flags & FTW_CHDIR) + { + name = data.dirbuf + data.ftw.base; + if (name[0] == '\0') + name = "."; + } + else + name = data.dirbuf; if (((flags & FTW_PHYS) ? LXSTAT (_STAT_VER, name, &st) |