From 8dd362b57cf2b49c5268e72898ae873522d8756f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 17 Mar 2010 02:40:42 -0400 Subject: The include directive now supports file globbing This only happens at the base filename, not for any of the directory names for now. --- src/mask.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/mask.cc') diff --git a/src/mask.cc b/src/mask.cc index 601d2a6a..cd516fe2 100644 --- a/src/mask.cc +++ b/src/mask.cc @@ -52,4 +52,38 @@ mask_t& mask_t::operator=(const string& pat) return *this; } +mask_t& mask_t::assign_glob(const string& pat) +{ + string re_pat = ""; + string::size_type len = pat.length(); + for (string::size_type i = 0; i < len; i++) { + switch (pat[i]) { + case '?': + re_pat += '.'; + break; + case '*': + re_pat += ".*"; + break; + case '[': + while (i < len && pat[i] != ']') + re_pat += pat[i++]; + if (i < len) + re_pat += pat[i]; + break; + + case '\\': + if (i + 1 < len) { + re_pat += pat[++i]; + break; + } else { + // fallthrough... + } + default: + re_pat += pat[i]; + break; + } + } + return (*this = re_pat); +} + } // namespace ledger -- cgit v1.2.3