aboutsummaryrefslogtreecommitdiff
path: root/build2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-03-13 13:37:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-03-13 13:37:10 +0200
commit8b7ead9400820969a6133a5c5827b4690099b4d5 (patch)
tree9d31dc059f31c240889bc99bf1502f6ebcf55d73 /build2/parser.cxx
parent482d362979baf8b0fef7f46b0cd61a29faeb11a8 (diff)
Filter hidden files/directories in wildcard patterns matches
Diffstat (limited to 'build2/parser.cxx')
-rw-r--r--build2/parser.cxx20
1 files changed, 15 insertions, 5 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 50fcc06..b7f1930 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -2422,22 +2422,32 @@ namespace build2
unique = (i == string::npos || p.find ("**", i + 2) == string::npos);
}
- //@@ PAT TODO: weed out starting with dot (unless pattern starts
- // with dot; last component? intermediate components?).
- //
function<bool (path&&, const string&, bool)> func;
if (unique)
- func = [a, &append] (path&& m, const string&, bool interm)
+ func = [a, &append] (path&& m, const string& p, bool interm)
{
+ // Ignore entries that start with a dot unless the pattern that
+ // matched them also starts with a dot.
+ //
+ const string& s (m.string ());
+ if (p[0] != '.' && s[path::traits::find_leaf (s)] == '.')
+ return !interm;
+
if (!interm)
append (move (m).representation (), a);
+
return true;
};
else
- func = [a, &include_match] (path&& m, const string&, bool interm)
+ func = [a, &include_match] (path&& m, const string& p, bool interm)
{
+ const string& s (m.string ());
+ if (p[0] != '.' && s[path::traits::find_leaf (s)] == '.')
+ return !interm;
+
if (!interm)
include_match (move (m).representation (), a);
+
return true;
};