mirror of
https://github.com/tnodir/fort
synced 2024-11-14 16:23:03 +00:00
UI: RuleTextParser: Simplify parseLine()
This commit is contained in:
parent
973581ada4
commit
daa710ff4a
@ -134,22 +134,9 @@ bool RuleTextParser::parseLine()
|
||||
if (!parseLineSection(expectedSeparator))
|
||||
break;
|
||||
|
||||
if (m_ruleFilter.isLineEnd || m_ruleFilter.isListEnd)
|
||||
if (!processSectionFilter())
|
||||
break;
|
||||
|
||||
const bool isSectionEnd = m_ruleFilter.isSectionEnd;
|
||||
|
||||
if (!checkAddFilter())
|
||||
return false;
|
||||
|
||||
resetFilter();
|
||||
|
||||
// Next default type, if applicable
|
||||
if (!isSectionEnd && !m_ruleFilter.hasFilterName) {
|
||||
m_ruleFilter.type = m_ruleFilter.isTypeAddress() ? FORT_RULE_FILTER_TYPE_PORT
|
||||
: FORT_RULE_FILTER_TYPE_INVALID;
|
||||
}
|
||||
|
||||
expectedSeparator = CharColon | CharNewLine;
|
||||
}
|
||||
|
||||
@ -158,6 +145,27 @@ bool RuleTextParser::parseLine()
|
||||
return !hasError();
|
||||
}
|
||||
|
||||
bool RuleTextParser::processSectionFilter()
|
||||
{
|
||||
if (m_ruleFilter.isLineEnd || m_ruleFilter.isListEnd)
|
||||
return false;
|
||||
|
||||
if (!checkAddFilter())
|
||||
return false;
|
||||
|
||||
const bool isSectionEnd = m_ruleFilter.isSectionEnd;
|
||||
|
||||
resetFilter();
|
||||
|
||||
// Next default type, if applicable
|
||||
if (!isSectionEnd && !m_ruleFilter.hasFilterName) {
|
||||
m_ruleFilter.type = m_ruleFilter.isTypeAddress() ? FORT_RULE_FILTER_TYPE_PORT
|
||||
: FORT_RULE_FILTER_TYPE_INVALID;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuleTextParser::parseLineSection(RuleCharTypes expectedSeparator)
|
||||
{
|
||||
for (;;) {
|
||||
|
@ -96,6 +96,7 @@ private:
|
||||
bool parseLines();
|
||||
bool parseLineComments();
|
||||
bool parseLine();
|
||||
bool processSectionFilter();
|
||||
bool parseLineSection(RuleCharTypes expectedSeparator);
|
||||
bool parseSection();
|
||||
bool parseSectionBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user