Sfoglia il codice sorgente

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

default_compile_flags
vector-of-bool 4 anni fa
parent
commit
ed999df17d
2 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. +4
    -0
      src/dds/util/glob.cpp
  2. +3
    -0
      src/dds/util/glob.test.cpp

+ 4
- 0
src/dds/util/glob.cpp Vedi 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 Vedi 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…
Annulla
Salva