summaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/glob.c5
-rw-r--r--posix/tst-gnuglob.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/posix/glob.c b/posix/glob.c
index ece71c168f..85237c2a44 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -276,6 +276,11 @@ glob (pattern, flags, errfunc, pglob)
return -1;
}
+ /* POSIX requires all slashes to be matched. This means that with
+ a trailing slash we must match only directories. */
+ if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
+ flags |= GLOB_ONLYDIR;
+
if (!(flags & GLOB_DOOFFS))
/* Have to do this so `globfree' knows where to start freeing. It
also makes all the code that uses gl_offs simpler. */
diff --git a/posix/tst-gnuglob.c b/posix/tst-gnuglob.c
index 0c967d0a7a..6e42724d08 100644
--- a/posix/tst-gnuglob.c
+++ b/posix/tst-gnuglob.c
@@ -168,7 +168,7 @@ my_opendir (const char *s)
my_DIR *dir;
- if (idx == -1)
+ if (idx == -1 || filesystem[idx].type != DT_DIR)
{
PRINTF ("my_opendir(\"%s\") == NULL\n", s);
return NULL;
@@ -358,7 +358,7 @@ test_result (const char *fmt, int flags, glob_t *gl, const char *str[])
break;
if (str[inner] == NULL)
- errstr = ok ? "" : " *** WRONG";
+ errstr = ok ? "" : " *** WRONG";
else
errstr = ok ? "" : " * wrong position";
@@ -483,6 +483,12 @@ main (void)
"/file1lev1",
"/file2lev1");
+ test ("*/*/", 0 , 0,
+ "dir1lev1/dir1lev2/",
+ "dir1lev1/dir2lev2/",
+ "dir1lev1/dir3lev2/",
+ "dir2lev1/dir1lev2/");
+
test ("", 0, GLOB_NOMATCH, NULL);
test ("", GLOB_NOCHECK, 0, "");