From 66b38fc99ecc3835502fae6851908b0d11d6b175 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 30 Sep 2004 06:42:39 +0000 Subject: Update. 2004-09-29 Ulrich Drepper * sysdeps/generic/glob.c (glob_in_dir): Don't blindly trust readdir results; for symlinks or files of unknown type check using stat whether the file exists. * posix/tst-gnuglob.c (find_file): Handle leading "./". Fix recognition of files. --- posix/tst-gnuglob.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'posix') diff --git a/posix/tst-gnuglob.c b/posix/tst-gnuglob.c index b15dad12ef..72f3fa4a3e 100644 --- a/posix/tst-gnuglob.c +++ b/posix/tst-gnuglob.c @@ -30,7 +30,7 @@ #include -/* #define DEBUG */ +// #define DEBUG #ifdef DEBUG # define PRINTF(fmt, args...) printf (fmt, ##args) #else @@ -106,6 +106,9 @@ find_file (const char *s) if (strcmp (s, ".") == 0) return 0; + if (s[0] == '.' && s[1] == '/') + s += 2; + while (*s != '\0') { char *endp = strchrnul (s, '/'); @@ -126,6 +129,10 @@ find_file (const char *s) errno = ENOENT; return -1; } + + if (*endp == '\0') + return idx + 1; + if (filesystem[idx].type != DT_DIR && (idx + 1 >= nfiles || filesystem[idx].level >= filesystem[idx + 1].level)) @@ -136,9 +143,6 @@ find_file (const char *s) ++idx; - if (*endp == '\0') - return idx; - s = endp + 1; ++level; } -- cgit 1.4.1