aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-28 20:48:35 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-10-01 12:15:10 +0300
commit59db6ff22d090f8b47e278e9ecbeaa049ba3ba55 (patch)
tree5a0a1944e12e8a67d24e5a15390e1792d9122bff
parent4c7a3c1350687d2913a2e008c2c41deceedcdead (diff)
Adapt to swapping of entry and pattern parameters in butl::path_match()
-rw-r--r--libbuild2/dist/operation.cxx2
-rw-r--r--libbuild2/functions-filesystem.cxx26
-rw-r--r--libbuild2/parser.cxx6
-rw-r--r--libbuild2/variable.cxx2
-rw-r--r--tests/function/filesystem/testscript38
5 files changed, 37 insertions, 37 deletions
diff --git a/libbuild2/dist/operation.cxx b/libbuild2/dist/operation.cxx
index ad2ee7f..f1dd81c 100644
--- a/libbuild2/dist/operation.cxx
+++ b/libbuild2/dist/operation.cxx
@@ -409,7 +409,7 @@ namespace build2
continue;
}
- if (path_match (pat.leaf ().string (), t.path ().leaf ().string ()))
+ if (path_match (t.path ().leaf ().string (), pat.leaf ().string ()))
cb.function (r, *srs, cb.data);
}
diff --git a/libbuild2/functions-filesystem.cxx b/libbuild2/functions-filesystem.cxx
index d0861ba..752f73a 100644
--- a/libbuild2/functions-filesystem.cxx
+++ b/libbuild2/functions-filesystem.cxx
@@ -82,8 +82,8 @@ namespace build2
// path_match() overloads (below) for details.
//
static bool
- path_match (const path& pattern,
- const path& entry,
+ path_match (const path& entry,
+ const path& pattern,
const optional<dir_path>& start)
{
// If pattern and entry are both either absolute or relative and
@@ -94,7 +94,7 @@ namespace build2
!pattern.empty () && !entry.empty ());
if (rel && !path_pattern_self_matching (pattern))
- return path_match (pattern, entry);
+ return path_match (entry, pattern);
// The start directory must be specified and be absolute.
//
@@ -114,7 +114,7 @@ namespace build2
<< info << "entry: '" << entry.representation () << "'";
}
- return path_match (pattern, entry, *start);
+ return path_match (entry, pattern, *start);
}
void
@@ -179,22 +179,22 @@ namespace build2
//
// Name matching.
//
- f["path_match"] = [](string pattern, string name)
+ f["path_match"] = [](string name, string pattern)
{
- return path_match (pattern, name);
+ return path_match (name, pattern);
};
// Path matching.
//
- f["path_match"] = [](path pat, path ent, optional<dir_path> start)
+ f["path_match"] = [](path ent, path pat, optional<dir_path> start)
{
- return path_match (pat, ent, start);
+ return path_match (ent, pat, start);
};
// The semantics depends on the presence of the start directory or the
// first two argument syntactic representation.
//
- f["path_match"] = [](names pat, names ent, optional<names> start)
+ f["path_match"] = [](names ent, names pat, optional<names> start)
{
auto path_arg = [] (const names& a) -> bool
{
@@ -205,13 +205,13 @@ namespace build2
};
return start || path_arg (pat) || path_arg (ent)
- ? path_match (convert<path> (move (pat)), // Match as paths.
- convert<path> (move (ent)),
+ ? path_match (convert<path> (move (ent)), // Match as paths.
+ convert<path> (move (pat)),
start
? convert<dir_path> (move (*start))
: optional<dir_path> ())
- : path_match (convert<string> (move (pat)), // Match as strings.
- convert<string> (move (ent)));
+ : path_match (convert<string> (move (ent)), // Match as strings.
+ convert<string> (move (pat)));
};
}
}
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 0a5142f..33da1b5 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -3691,10 +3691,10 @@ namespace build2
// Compare name to pattern as paths and according to dir.
//
- auto match = [&dir, sp] (const path& pattern, const name& n) -> bool
+ auto match = [&dir, sp] (const name& n, const path& pattern) -> bool
{
const path& p (dir ? path_cast<path> (n.dir) : path (n.value));
- return path_match (pattern, p, *sp);
+ return path_match (p, pattern, *sp);
};
// Append name/extension to result according to dir. Store an indication
@@ -3810,7 +3810,7 @@ namespace build2
{
for (auto i (r.begin ()); i != r.end (); )
{
- if (match (p, *i))
+ if (match (*i, p))
i = r.erase (i);
else
++i;
diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx
index 86109d2..c84a89c 100644
--- a/libbuild2/variable.cxx
+++ b/libbuild2/variable.cxx
@@ -1485,7 +1485,7 @@ namespace build2
if (pat != "*")
{
if (name.size () < pat.size () - 1 || // One for '*' or '?'.
- !butl::path_match (pat, name))
+ !butl::path_match (name, pat))
continue;
}
diff --git a/tests/function/filesystem/testscript b/tests/function/filesystem/testscript
index 5aa1d47..ecda10e 100644
--- a/tests/function/filesystem/testscript
+++ b/tests/function/filesystem/testscript
@@ -83,19 +83,19 @@
{
: string-string
:
- $* <'print $path_match([string] "b*", [string] "b")' >'true'
+ $* <'print $path_match([string] "b", [string] "b*")' >'true'
- : string-untyped
+ : untyped-string
:
- $* <'print $path_match([string] "b*", "b")' >'true'
+ $* <'print $path_match("b", [string] "b*")' >'true'
- : untyped-string
+ : string-untyped
:
- $* <'print $path_match("b*", [string] "b")' >'true'
+ $* <'print $path_match([string] "b", "b*")' >'true'
- : string-path
+ : path-string
:
- $* <'print $path_match([string] "b*", [path] "b")' >'true'
+ $* <'print $path_match([path] "b", [string] "b*")' >'true'
}
: path
@@ -106,23 +106,23 @@
{
: path-path
:
- $* <'print $path_match([path] "b**", [path] "a/b")' >'true'
+ $* <'print $path_match([path] "a/b", [path] "b**")' >'true'
: path-path-untyped
:
- $* <'print $path_match([path] "b**", [path] "a/b", "$src_base")' >'true'
+ $* <'print $path_match([path] "a/b", [path] "b**", "$src_base")' >'true'
- : path-untyped
+ : untyped-path
:
- $* <'print $path_match([path] "b**", "a/b")' >'true'
+ $* <'print $path_match("a/b", [path] "b**")' >'true'
- : path-untyped-dir
+ : untyped-path-dir
:
- $* <'print $path_match([path] "b**", "a/b", $src_base)' >'true'
+ $* <'print $path_match("a/b", [path] "b**", $src_base)' >'true'
- : untyped-path
+ : path-untyped
:
- $* <'print $path_match("b**", [path] "a/b")' >'true'
+ $* <'print $path_match([path] "a/b", "b**")' >'true'
}
: untyped
@@ -132,21 +132,21 @@
{
: converted-to-strings
:
- $* <'print $path_match("b**", "b")' >'true'
+ $* <'print $path_match("b", "b**")' >'true'
: converted-to-paths-due-to
{
: pattern
:
- $* <'print $path_match("b**/", "a/b/")' >'true'
+ $* <'print $path_match("a/b/", "b**/")' >'true'
: entry
:
- $* <'print $path_match("b**", "a/b")' >'true'
+ $* <'print $path_match("a/b", "b**")' >'true'
: start-dir
:
- $* <'print $path_match("s***/", "", "$src_base")' >'true'
+ $* <'print $path_match("", "s***/", "$src_base")' >'true'
}
}
}