Browse Source

'**' at the end of a pattern matches everything

default_compile_flags
vector-of-bool 4 years ago
parent
commit
ed999df17d
2 changed files with 7 additions and 0 deletions
  1. +4
    -0
      src/dds/util/glob.cpp
  2. +3
    -0
      src/dds/util/glob.test.cpp

+ 4
- 0
src/dds/util/glob.cpp View File

@@ -221,6 +221,10 @@ bool check_matches(path_iter elem_it,
} else {
// An rglob pattern "**". Check by peeling of individual path elements
const auto next_pat = std::next(pat_it);
if (next_pat == pat_stop) {
// The "**" is at the end of the glob. This matches everything.
return true;
}
for (; elem_it != elem_stop; ++elem_it) {
if (check_matches(elem_it, elem_stop, next_pat, pat_stop)) {
return true;

+ 3
- 0
src/dds/util/glob.test.cpp View File

@@ -66,4 +66,7 @@ TEST_CASE("Check globs") {
CHECK(glob.match("foo/thing/bar/thing/baz.txt"));
CHECK(glob.match("foo/bar/thing/baz.txt"));
CHECK(glob.match("foo/bar/baz/baz.txt"));

glob = dds::glob::compile("doc/**");
CHECK(glob.match("doc/something.txt"));
}

Loading…
Cancel
Save