FilterParser: Fix "OR" and "AND"

Fixes #1599
This commit is contained in:
Jonas Kvinge 2024-11-08 21:38:57 +01:00
parent 2a5e425b71
commit 957a850adc
1 changed files with 22 additions and 19 deletions

View File

@ -91,17 +91,17 @@ FilterTree *FilterParser::parseAndGroup() {
bool FilterParser::checkAnd() { bool FilterParser::checkAnd() {
if (iter_ != end_) { QString::const_iterator and_iter = iter_;
if (*iter_ == u'A') {
buf_ += *iter_; if (and_iter != end_) {
++iter_; if (*and_iter == u'A') {
if (iter_ != end_ && *iter_ == u'N') { ++and_iter;
buf_ += *iter_; if (and_iter != end_ && *and_iter == u'N') {
++iter_; ++and_iter;
if (iter_ != end_ && *iter_ == u'D') { if (and_iter != end_ && *and_iter == u'D') {
buf_ += *iter_; ++and_iter;
++iter_; if (and_iter != end_ && (and_iter->isSpace() || *and_iter == u'-' || *and_iter == u'(')) {
if (iter_ != end_ && (iter_->isSpace() || *iter_ == u'-' || *iter_ == u'(')) { iter_ = and_iter;
advance(); advance();
buf_.clear(); buf_.clear();
return true; return true;
@ -127,18 +127,21 @@ bool FilterParser::checkOr(const bool step_over) {
} }
} }
else { else {
if (iter_ != end_) { QString::const_iterator or_iter = iter_;
if (*iter_ == u'O') { if (or_iter != end_) {
buf_ += *iter_; if (*or_iter == u'O') {
++iter_; ++or_iter;
if (iter_ != end_ && *iter_ == u'R') { if (or_iter != end_ && *or_iter == u'R') {
buf_ += *iter_; ++or_iter;
++iter_; if (or_iter != end_ && (or_iter->isSpace() || *or_iter == u'-' || *or_iter == u'(')) {
if (iter_ != end_ && (iter_->isSpace() || *iter_ == u'-' || *iter_ == u'(')) { iter_ = or_iter;
if (step_over) { if (step_over) {
buf_.clear(); buf_.clear();
advance(); advance();
} }
else {
buf_ += "OR"_L1;
}
return true; return true;
} }
} }