diff --git a/src/ui/util/conf/ruletextparser.cpp b/src/ui/util/conf/ruletextparser.cpp index eaa36aacd..bef403957 100644 --- a/src/ui/util/conf/ruletextparser.cpp +++ b/src/ui/util/conf/ruletextparser.cpp @@ -210,22 +210,35 @@ RuleCharType RuleTextParser::nextCharType(quint32 expectedCharTypes, const char charType = processCharType(charType, c, extraChars); - switch (charType) { - case CharNone: { - setErrorMessage(tr("Bad symbol: %1").arg(c)); - return CharNone; - } break; - default: - if ((charType & expectedCharTypes) == 0) { - if (cp == m_p) { - setErrorMessage(tr("Unexpected symbol: %1").arg(c)); - } - return CharNone; - } - + if (!checkNextCharType(expectedCharTypes, charType, cp, c)) { return charType; } } return CharNone; } + +bool RuleTextParser::checkNextCharType( + quint32 expectedCharTypes, RuleCharType &charType, const QChar *cp, const QChar c) +{ + switch (charType) { + case CharNone: { + setErrorMessage(tr("Bad symbol: %1").arg(c)); + + charType = CharNone; + return false; + } break; + default: + if ((charType & expectedCharTypes) == 0) { + if (cp == m_p) { + setErrorMessage(tr("Unexpected symbol: %1").arg(c)); + } + + charType = CharNone; + } + + return false; + } + + return true; +} diff --git a/src/ui/util/conf/ruletextparser.h b/src/ui/util/conf/ruletextparser.h index d38893e76..44e0f5c25 100644 --- a/src/ui/util/conf/ruletextparser.h +++ b/src/ui/util/conf/ruletextparser.h @@ -79,6 +79,8 @@ class RuleTextParser : public QObject RuleExpr &listNode(int listIndex) { return m_ruleExprArray[listIndex]; } RuleCharType nextCharType(quint32 expectedCharTypes, const char *extraChars = nullptr); + bool checkNextCharType( + quint32 expectedCharTypes, RuleCharType &charType, const QChar *cp, const QChar c); private: bool m_isNot = false;