master
Daniel Kolesa 2015-08-21 11:14:24 -07:00
parent 349e9b7851
commit a3317607d0
1 changed files with 6 additions and 6 deletions

12
main.cc
View File

@ -64,7 +64,7 @@ static bool ob_check_exec(ostd::ConstCharRange tname,
} }
static int ob_exec_rule(ObState &os, ostd::ConstCharRange target, static int ob_exec_rule(ObState &os, ostd::ConstCharRange target,
ostd::ConstCharRange from = ostd::ConstCharRange()); ostd::ConstCharRange from = nullptr);
struct SubRule { struct SubRule {
ostd::ConstCharRange sub; ostd::ConstCharRange sub;
@ -147,14 +147,14 @@ static ostd::ConstCharRange ob_compare_subst(ostd::ConstCharRange expanded,
auto rep = ostd::find(toexpand, '%'); auto rep = ostd::find(toexpand, '%');
/* no subst found */ /* no subst found */
if (rep.empty()) if (rep.empty())
return ostd::ConstCharRange(); return nullptr;
/* get the part before % */ /* get the part before % */
auto fp = ostd::slice_until(toexpand, rep); auto fp = ostd::slice_until(toexpand, rep);
/* part before % does not compare, so ignore */ /* part before % does not compare, so ignore */
if (expanded.size() <= fp.size()) if (expanded.size() <= fp.size())
return ostd::ConstCharRange(); return nullptr;
if (expanded.slice(0, fp.size()) != fp) if (expanded.slice(0, fp.size()) != fp)
return ostd::ConstCharRange(); return nullptr;
/* pop out front part */ /* pop out front part */
expanded.pop_front_n(fp.size()); expanded.pop_front_n(fp.size());
/* part after % */ /* part after % */
@ -163,9 +163,9 @@ static ostd::ConstCharRange ob_compare_subst(ostd::ConstCharRange expanded,
return expanded; return expanded;
/* part after % does not compare, so ignore */ /* part after % does not compare, so ignore */
if (expanded.size() <= rep.size()) if (expanded.size() <= rep.size())
return ostd::ConstCharRange(); return nullptr;
if (expanded.slice(expanded.size() - rep.size(), expanded.size()) != rep) if (expanded.slice(expanded.size() - rep.size(), expanded.size()) != rep)
return ostd::ConstCharRange(); return nullptr;
/* cut off latter part */ /* cut off latter part */
expanded.pop_back_n(rep.size()); expanded.pop_back_n(rep.size());
/* we got what we wanted... */ /* we got what we wanted... */