diff --git a/Frameworks/regexp/src/glob.cc b/Frameworks/regexp/src/glob.cc index 166da0c0..374b3f2c 100644 --- a/Frameworks/regexp/src/glob.cc +++ b/Frameworks/regexp/src/glob.cc @@ -241,6 +241,9 @@ namespace path bool glob_list_t::exclude (std::string const& path, kPathItemType itemType, bool defaultResult) const { + if(_globs.empty()) + return false; + for(auto record : _globs) { if((itemType == kPathItemAny || record.item_type == kPathItemAny || itemType == record.item_type) && record.glob.does_match(path)) diff --git a/Frameworks/regexp/tests/t_glob_list.cc b/Frameworks/regexp/tests/t_glob_list.cc index 3c65a681..20d2b209 100644 --- a/Frameworks/regexp/tests/t_glob_list.cc +++ b/Frameworks/regexp/tests/t_glob_list.cc @@ -3,6 +3,24 @@ class GlobListTests : public CxxTest::TestSuite { public: + void test_empty_glob_list () + { + path::glob_list_t globs; + TS_ASSERT(globs.include("foo")); + TS_ASSERT(globs.include("bar")); + TS_ASSERT(globs.include(".foo")); + TS_ASSERT(globs.include(".bar")); + } + + void test_non_empty_glob_list () + { + path::glob_list_t globs("*"); + TS_ASSERT(globs.include("foo")); + TS_ASSERT(globs.include("bar")); + TS_ASSERT(globs.exclude(".foo")); + TS_ASSERT(globs.exclude(".bar")); + } + void test_glob_list () { path::glob_list_t globs;