mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Rearrange switches so default cases are last
This commit is contained in:
@@ -119,14 +119,6 @@ static std::string escapeString(std::string const &str) {
|
|||||||
for (char c : str) {
|
for (char c : str) {
|
||||||
// Escape characters that need escaping
|
// Escape characters that need escaping
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\\':
|
|
||||||
case '"':
|
|
||||||
case '{':
|
|
||||||
escaped += '\\';
|
|
||||||
[[fallthrough]];
|
|
||||||
default:
|
|
||||||
escaped += c;
|
|
||||||
break;
|
|
||||||
case '\n':
|
case '\n':
|
||||||
escaped += "\\n";
|
escaped += "\\n";
|
||||||
break;
|
break;
|
||||||
@@ -139,6 +131,14 @@ static std::string escapeString(std::string const &str) {
|
|||||||
case '\0':
|
case '\0':
|
||||||
escaped += "\\0";
|
escaped += "\\0";
|
||||||
break;
|
break;
|
||||||
|
case '\\':
|
||||||
|
case '"':
|
||||||
|
case '{':
|
||||||
|
escaped += '\\';
|
||||||
|
[[fallthrough]];
|
||||||
|
default:
|
||||||
|
escaped += c;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return escaped;
|
return escaped;
|
||||||
|
|||||||
@@ -1257,14 +1257,6 @@ static void appendEscapedString(std::string &str, std::string const &escape) {
|
|||||||
for (char c : escape) {
|
for (char c : escape) {
|
||||||
// Escape characters that need escaping
|
// Escape characters that need escaping
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\\':
|
|
||||||
case '"':
|
|
||||||
case '{':
|
|
||||||
str += '\\';
|
|
||||||
[[fallthrough]];
|
|
||||||
default:
|
|
||||||
str += c;
|
|
||||||
break;
|
|
||||||
case '\n':
|
case '\n':
|
||||||
str += "\\n";
|
str += "\\n";
|
||||||
break;
|
break;
|
||||||
@@ -1277,6 +1269,14 @@ static void appendEscapedString(std::string &str, std::string const &escape) {
|
|||||||
case '\0':
|
case '\0':
|
||||||
str += "\\0";
|
str += "\\0";
|
||||||
break;
|
break;
|
||||||
|
case '\\':
|
||||||
|
case '"':
|
||||||
|
case '{':
|
||||||
|
str += '\\';
|
||||||
|
[[fallthrough]];
|
||||||
|
default:
|
||||||
|
str += c;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,14 +360,6 @@ static void dumpString(std::string const &escape, FILE *file) {
|
|||||||
for (char c : escape) {
|
for (char c : escape) {
|
||||||
// Escape characters that need escaping
|
// Escape characters that need escaping
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\\':
|
|
||||||
case '"':
|
|
||||||
case '{':
|
|
||||||
putc('\\', file);
|
|
||||||
[[fallthrough]];
|
|
||||||
default:
|
|
||||||
putc(c, file);
|
|
||||||
break;
|
|
||||||
case '\n':
|
case '\n':
|
||||||
fputs("\\n", file);
|
fputs("\\n", file);
|
||||||
break;
|
break;
|
||||||
@@ -380,6 +372,14 @@ static void dumpString(std::string const &escape, FILE *file) {
|
|||||||
case '\0':
|
case '\0':
|
||||||
fputs("\\0", file);
|
fputs("\\0", file);
|
||||||
break;
|
break;
|
||||||
|
case '\\':
|
||||||
|
case '"':
|
||||||
|
case '{':
|
||||||
|
putc('\\', file);
|
||||||
|
[[fallthrough]];
|
||||||
|
default:
|
||||||
|
putc(c, file);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user