aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-builds.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-19 22:33:15 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-19 22:33:15 +0300
commit3cb2a7937b281516bde876e5884fbe5ec552ec9b (patch)
treefd6c820702a6a064bd6265d661ff77120064ac7c /mod/mod-builds.cxx
parent6ad9156ab3336aa56ed2892dc0d9a04e1551b7f4 (diff)
Revert previous commit erroneously pushed to master instead of dev branch
Diffstat (limited to 'mod/mod-builds.cxx')
-rw-r--r--mod/mod-builds.cxx78
1 files changed, 23 insertions, 55 deletions
diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx
index d446133..71e7f7b 100644
--- a/mod/mod-builds.cxx
+++ b/mod/mod-builds.cxx
@@ -13,8 +13,7 @@
#include <odb/transaction.hxx>
#include <libbutl/timestamp.mxx> // to_string()
-#include <libbutl/filesystem.mxx> // path_match(), path_pattern(), literal(),
- // path_pattern_iterator
+#include <libbutl/filesystem.mxx> // path_match()
#include <libbbot/manifest.hxx> // to_result_status(), to_string(result_status)
@@ -67,66 +66,32 @@ init (scanner& s)
options_->root (dir_path ("/"));
}
-// Transform the wildcard to the SIMILAR TO-pattern.
+// Transform the wildcard to the LIKE-pattern.
//
static string
-transform (const string& pattern)
+transform (const string& s)
{
- if (pattern.empty ())
+ if (s.empty ())
return "%";
string r;
- for (const path_pattern_char& pc: path_pattern_iterator (pattern))
+ for (char c: s)
{
- switch (pc.type)
+ switch (c)
{
- case path_pattern_char_type::question_mark: r += '_'; break;
- case path_pattern_char_type::star: r += '%'; break;
- case path_pattern_char_type::bracket_expr:
- {
- size_t n (r.size ());
- r.append (pc.begin, pc.end);
-
- // Translate the inverse character, if present.
- //
- if (r[n + 1] == '!')
- r[n + 1] = '^';
-
- break;
- }
- case path_pattern_char_type::literal:
- {
- char c (literal (pc));
-
- // Note that '.' is not a special character for SIMILAR TO.
- //
- switch (c)
- {
- case '\\':
- case '%':
- case '_':
- case '|':
- case '+':
- case '{':
- case '(': r += '\\'; break;
- }
-
- r += c;
- break;
- }
+ case '*': c = '%'; break;
+ case '?': c = '_'; break;
+ case '\\':
+ case '%':
+ case '_': r += '\\'; break;
}
+
+ r += c;
}
return r;
}
-template <typename T, typename C>
-static inline query<T>
-match (const C qc, const string& pattern)
-{
- return qc + "SIMILAR TO" + query<T>::_val (transform (pattern));
-}
-
template <typename T>
static inline query<T>
build_query (const brep::cstrings* configs,
@@ -159,7 +124,8 @@ build_query (const brep::cstrings* configs,
// Package name.
//
if (!params.name ().empty ())
- q = q && match<T> (pid.name, params.name ());
+ q = q && pid.name.like (package_name (transform (params.name ()),
+ package_name::raw_string));
// Package version.
//
@@ -201,17 +167,17 @@ build_query (const brep::cstrings* configs,
// Build configuration name.
//
if (!params.configuration ().empty ())
- q = q && match<T> (qb::id.configuration, params.configuration ());
+ q = q && qb::id.configuration.like (transform (params.configuration ()));
// Build machine name.
//
if (!params.machine ().empty ())
- q = q && match<T> (qb::machine, params.machine ());
+ q = q && qb::machine.like (transform (params.machine ()));
// Build target.
//
if (!params.target ().empty ())
- q = q && match<T> (qb::target, params.target ());
+ q = q && qb::target.like (transform (params.target ()));
// Build result.
//
@@ -284,7 +250,8 @@ package_query (const brep::params::builds& params,
// Package name.
//
if (!params.name ().empty ())
- q = q && match<T> (qp::id.name, params.name ());
+ q = q && qp::id.name.like (
+ package_name (transform (params.name ()), package_name::raw_string));
// Package version.
//
@@ -499,8 +466,9 @@ handle (request& rq, response& rs)
// We will not display hidden configurations, unless the configuration is
// specified explicitly.
//
- bool exclude_hidden (params.configuration ().empty () ||
- path_pattern (params.configuration ()));
+ bool exclude_hidden (
+ params.configuration ().empty () ||
+ params.configuration ().find_first_of ("*?") != string::npos);
cstrings conf_names;