fix: string literal line separator escape
This commit is contained in:
parent
2f7fbd57ee
commit
9667b81438
@ -370,7 +370,7 @@ std::string BasicParser::parseString(char quote, bool closeRequired) {
|
|||||||
case '"': ss << '"'; break;
|
case '"': ss << '"'; break;
|
||||||
case '\\': ss << '\\'; break;
|
case '\\': ss << '\\'; break;
|
||||||
case '/': ss << '/'; break;
|
case '/': ss << '/'; break;
|
||||||
case '\n': pos++; continue;
|
case '\n': continue;
|
||||||
default:
|
default:
|
||||||
throw error(
|
throw error(
|
||||||
"'\\" + std::string({c}) + "' is an illegal escape"
|
"'\\" + std::string({c}) + "' is an illegal escape"
|
||||||
|
|||||||
@ -26,6 +26,8 @@ class TomlReader : BasicParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modified version of BaseParser.parseString
|
||||||
|
// todo: extract common part
|
||||||
std::string parseMultilineString() {
|
std::string parseMultilineString() {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
char next = peek();
|
char next = peek();
|
||||||
@ -57,7 +59,7 @@ class TomlReader : BasicParser {
|
|||||||
case '"': ss << '"'; break;
|
case '"': ss << '"'; break;
|
||||||
case '\\': ss << '\\'; break;
|
case '\\': ss << '\\'; break;
|
||||||
case '/': ss << '/'; break;
|
case '/': ss << '/'; break;
|
||||||
case '\n': pos++; continue;
|
case '\n': continue;
|
||||||
default:
|
default:
|
||||||
throw error(
|
throw error(
|
||||||
"'\\" + std::string({c}) + "' is an illegal escape"
|
"'\\" + std::string({c}) + "' is an illegal escape"
|
||||||
|
|||||||
@ -73,7 +73,8 @@ inline std::string SRC_EXAMPLE =
|
|||||||
"\n"
|
"\n"
|
||||||
"[servers.beta]\n"
|
"[servers.beta]\n"
|
||||||
"ip = \"10.0.0.2\"\n"
|
"ip = \"10.0.0.2\"\n"
|
||||||
"role = \"\"\"backend\"\"\"";
|
"role = \"\"\"back\\\n"
|
||||||
|
"end\"\"\"";
|
||||||
|
|
||||||
TEST(TOML, ExampleCode) {
|
TEST(TOML, ExampleCode) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user