aboutsummaryrefslogtreecommitdiff
path: root/mod/build-config-module.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-19 22:37:02 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-27 18:55:52 +0300
commitc3020dee6c91f2694cd098566716f2a4a7794dbe (patch)
tree0233483d45a111ea405a2b0708d39c90f57c78c6 /mod/build-config-module.cxx
parent41480b8da4a7d039bf3e1ba57339b228188d6b12 (diff)
Adapt to bracket expressions in wildcard patterns
Diffstat (limited to 'mod/build-config-module.cxx')
-rw-r--r--mod/build-config-module.cxx34
1 files changed, 21 insertions, 13 deletions
diff --git a/mod/build-config-module.cxx b/mod/build-config-module.cxx
index d21849e..1efc514 100644
--- a/mod/build-config-module.cxx
+++ b/mod/build-config-module.cxx
@@ -362,36 +362,44 @@ namespace brep
}
path build_config_module::
- dash_components_to_path (const string& s)
+ dash_components_to_path (const string& pattern)
{
string r;
- for (size_t i (0); i != s.size (); ++i)
+ size_t nstar (0);
+ for (const path_pattern_term& pt: path_pattern_iterator (pattern))
{
- char c (s[i]);
-
- switch (c)
+ switch (pt.type)
{
- case '-':
+ case path_pattern_term_type::star:
{
- r += '/';
+ // Replace ** with */**/* and skip all the remaining stars that may
+ // follow in this sequence.
+ //
+ if (nstar == 0)
+ r += "*";
+ else if (nstar == 1)
+ r += "/**/*"; // The first star is already copied.
+
break;
}
- case '*':
+ case path_pattern_term_type::literal:
{
- if (s[i + 1] == '*') // Can be '\0'.
+ // Replace '-' with '/' and fall through otherwise.
+ //
+ if (get_literal (pt) == '-')
{
- r += "*/**/*";
- ++i;
+ r += '/';
break;
}
}
// Fall through.
default:
{
- r += c;
- break;
+ r.append (pt.begin, pt.end); // Copy the pattern term as is.
}
}
+
+ nstar = pt.star () ? nstar + 1 : 0;
}
// Append the trailing slash to match the resulting paths as directories.