Skip to content

Commit

Permalink
Test 3
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi committed Feb 3, 2025
1 parent 6047bc2 commit 46f1df5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,10 +1411,10 @@ void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
}
}

void simplecpp::TokenList::constFoldQuestionOp(Token *tok1)
void simplecpp::TokenList::constFoldQuestionOp(Token **tok1)
{
bool gotoTok1 = false;
for (Token *tok = tok1; tok && tok->op != ')'; tok = gotoTok1 ? tok1 : tok->next) {
for (Token *tok = *tok1; tok && tok->op != ')'; tok = gotoTok1 ? *tok1 : tok->next) {
gotoTok1 = false;
if (tok->str() != "?")
continue;
Expand All @@ -1429,8 +1429,8 @@ void simplecpp::TokenList::constFoldQuestionOp(Token *tok1)
Token * const falseTok = trueTok->next->next;
if (!falseTok)
throw std::runtime_error("invalid expression");
if (condTok == tok1)
tok1 = (condTok->str() != "0" ? trueTok : falseTok);
if (condTok == *tok1)
*tok1 = (condTok->str() != "0" ? trueTok : falseTok);
deleteToken(condTok->next); // ?
deleteToken(trueTok->next); // :
deleteToken(condTok->str() == "0" ? trueTok : falseTok);
Expand Down
2 changes: 1 addition & 1 deletion simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ namespace simplecpp {
void constFoldComparison(Token *tok);
void constFoldBitwise(Token *tok);
void constFoldLogicalOp(Token *tok);
void constFoldQuestionOp(Token *tok1);
void constFoldQuestionOp(Token **tok1);

//Token * deleteUntil(Token *tok, const std::string & breakPoint, Token *(step)(Token *));
static int getTokensDeleteCount(Token *tok, const std::set<std::string> & breakPoints, Token *(step)(Token *), const std::pair<std::string, std::string> & brackets);
Expand Down

0 comments on commit 46f1df5

Please sign in to comment.