Simplify appendCharInLiteral

This commit is contained in:
Rangi42
2025-07-11 23:52:52 -04:00
parent f2708ce967
commit 82513e5255

View File

@@ -1452,14 +1452,11 @@ static void appendExpandedString(std::string &str, std::string const &expanded)
} }
} }
static void appendCharInLiteral(std::string &str, int c, bool rawString) { static void appendCharInLiteral(std::string &str, int c) {
bool rawMode = lexerState->mode == LEXER_RAW; bool rawMode = lexerState->mode == LEXER_RAW;
switch (c) { switch (c) {
case '\\': // Character escape or macro arg case '\\': // Character escape or macro arg
if (rawString) {
break;
}
c = peek(); c = peek();
switch (c) { switch (c) {
// Character escape // Character escape
@@ -1545,9 +1542,6 @@ static void appendCharInLiteral(std::string &str, int c, bool rawString) {
break; break;
case '{': // Symbol interpolation case '{': // Symbol interpolation
if (rawString) {
break;
}
// We'll be exiting the string scope, so re-enable expansions // We'll be exiting the string scope, so re-enable expansions
// (Not interpolations, since they're handled by the function itself...) // (Not interpolations, since they're handled by the function itself...)
lexerState->disableMacroArgs = false; lexerState->disableMacroArgs = false;
@@ -1637,7 +1631,11 @@ static void readString(std::string &str, bool rawString) {
} }
// Append the character or handle special ones // Append the character or handle special ones
appendCharInLiteral(str, c, rawString); if (rawString) {
str += c;
} else {
appendCharInLiteral(str, c);
}
} }
} }