diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2015-07-24 13:25:04 +0100 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2015-07-24 13:25:04 +0100 |
commit | d9f1a85948478fe5038ecc2fd1923c451cca84d5 (patch) | |
tree | 5c852f82e2f93d7c0f3f984604b05e425f79ec7f /drivers/nrex | |
parent | 732bfd0baff3fc17790c345f7e6b02e5c12a5080 (diff) |
More nrex fixes
Diffstat (limited to 'drivers/nrex')
-rw-r--r-- | drivers/nrex/nrex.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/nrex/nrex.cpp b/drivers/nrex/nrex.cpp index 36a5bb4ced..696d46240e 100644 --- a/drivers/nrex/nrex.cpp +++ b/drivers/nrex/nrex.cpp @@ -246,7 +246,18 @@ struct nrex_node_group : public nrex_node { return res; } - if ((res >= 0) != negate) + if (negate) + { + if (res < 0) + { + res = pos + 1; + } + else + { + return -1; + } + } + if (res >= 0) { if (capturing >= 0) { @@ -479,7 +490,6 @@ struct nrex_node_quantifier : public nrex_node { nrex_array<int> backtrack; backtrack.push(pos); - s->complete = false; while (backtrack.top() <= s->end) { if (max >= 1 && backtrack.size() > (unsigned int)max) @@ -502,7 +512,6 @@ struct nrex_node_quantifier : public nrex_node return res; } } - s->complete = false; int res = child->test(s, backtrack.top()); if (s->complete) { @@ -516,12 +525,7 @@ struct nrex_node_quantifier : public nrex_node } while (greedy && (unsigned int) min < backtrack.size()) { - s->complete = false; int res = backtrack.top(); - if (s->complete) - { - return res; - } if (next) { res = next->test(s, res); @@ -530,6 +534,10 @@ struct nrex_node_quantifier : public nrex_node { return res; } + if (s->complete) + { + return res; + } backtrack.pop(); } return -1; |