Skip to content

Commit

Permalink
Nits 7
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi committed Jan 28, 2025
1 parent 262e44d commit 1af91ac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,9 @@ simplecpp::Token * simplecpp::TokenList::foldLogicalOpToSingleValue(Token *tok,
tok = (step)(tok);
deleteToken(oldToken);
} else {
deleteToken(tok);
Token * oldToken = tok;
tok = (step)(tok);
deleteToken(oldToken);
break;
}
}
Expand Down Expand Up @@ -1363,20 +1365,20 @@ void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
breakPoints.insert(":");
breakPoints.insert("?");
if (tok->str() == "||"){
if (stringToLL(tok->previous->str()) != 0) {
if (stringToLL(tok->previous->str())) {
tok = foldLogicalOpToSingleValue(tok->previous, breakPoints, &stepForward, std::make_pair<std::string, std::string>("(", ")"), "1");
break;
} else if (stringToLL(tok->next->str()) != 0) {
} else if (stringToLL(tok->next->str())) {
tok = foldLogicalOpToSingleValue(tok->next, breakPoints, &stepBack, std::make_pair<std::string, std::string>(")", "("), "1");
break;
}
result = 0;
} else /*if (tok->str() == "&&")*/ {
breakPoints.insert("||");
if (stringToLL(tok->previous->str()) == 0) {
if (!stringToLL(tok->previous->str())) {
tok = foldLogicalOpToSingleValue(tok->previous, breakPoints, &stepForward, std::make_pair<std::string, std::string>("(", ")"), "0");
break;
} else if (stringToLL(tok->next->str()) == 0) {
} else if (!stringToLL(tok->next->str())) {
tok = foldLogicalOpToSingleValue(tok->next, breakPoints, &stepBack, std::make_pair<std::string, std::string>(")", "("), "0");
break;
}
Expand Down

0 comments on commit 1af91ac

Please sign in to comment.