Skip to content

Commit 85523e0

Browse files
committed
review: enum
1 parent a516b07 commit 85523e0

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/suppressions.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -806,47 +806,47 @@ std::vector<std::pair<std::string, std::string>> polyspace::Parser::parseFamilyR
806806
std::vector<std::pair<std::string, std::string>> fr;
807807
std::string family;
808808
std::string rule;
809-
int state = 0; // 0=family, 1=colon, 2=rule, 3=rule/family
809+
enum class State: uint8_t { family, colon, rule, rule_or_family } state = State::family;
810810
const std::string::size_type endpos = startsWith(comment, "/*") ? comment.size() - 2 : comment.size();
811811
for (; pos <= endpos; ++pos) {
812812
const char c = comment[pos];
813813
if (std::strchr("[\"", c))
814814
break;
815815
switch (state) {
816-
case 0: // parse family
816+
case State::family:
817817
if (std::isalnum(c) || std::strchr("-_.",c))
818818
family += c;
819819
else if (!family.empty() && std::strchr(" \t:",c))
820-
++state;
820+
state = State::colon;
821821
break;
822-
case 1: // colon
822+
case State::colon:
823823
if (!std::strchr(" \t:", c)) {
824824
rule.clear();
825825
--pos;
826-
++state;
826+
state = State::rule;
827827
}
828828
break;
829-
case 2: // rules
829+
case State::rule:
830830
if (std::strchr(", \t",c)) {
831831
if (!rule.empty()) {
832832
fr.emplace_back(family,rule);
833833
rule.clear();
834834
if (c != ',')
835-
++state;
835+
state = State::rule_or_family;
836836
}
837837
}
838838
else
839839
rule += c;
840840
break;
841-
case 3: // rule/family
841+
case State::rule_or_family:
842842
rule.clear();
843843
if (std::isalnum(c)) {
844844
--pos;
845845
family.clear();
846-
state = 0; // family
846+
state = State::family;
847847
} else if (c == ',') {
848848
--pos;
849-
state = 2; // rule
849+
state = State::rule;
850850
}
851851
break;
852852
}

0 commit comments

Comments
 (0)