summaryrefslogtreecommitdiff
path: root/posix/tst-gnuglob.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-30 06:42:39 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-30 06:42:39 +0000
commit66b38fc99ecc3835502fae6851908b0d11d6b175 (patch)
tree1d27136d28fdf13ab181b367310012ed59108c32 /posix/tst-gnuglob.c
parent8930fcf9beee6c0d1ace2e4a67be1525f5d6b8aa (diff)
downloadglibc-66b38fc99ecc3835502fae6851908b0d11d6b175.tar.gz
Update.
2004-09-29 Ulrich Drepper <drepper@redhat.com> * 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.
Diffstat (limited to 'posix/tst-gnuglob.c')
-rw-r--r--posix/tst-gnuglob.c12
1 files changed, 8 insertions, 4 deletions
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 <sys/stat.h>
-/* #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;
}