fix literal escapes

This commit is contained in:
xensik 2022-03-21 17:04:33 +01:00
parent abe083e93e
commit 21d42b5932

View File

@ -82,6 +82,11 @@ auto string::to_code(const std::string& input) -> std::string
data.erase(data.begin() + pos); data.erase(data.begin() + pos);
} }
while ((pos = data.find("\\\\")) != std::string::npos)
{
data.erase(data.begin() + pos);
}
return data; return data;
} }
@ -110,10 +115,15 @@ auto string::to_literal(const std::string& input) -> std::string
for (pos = 0; pos < data.size(); pos++) for (pos = 0; pos < data.size(); pos++)
{ {
if (data.at(pos) == '\"') if (data.at(pos) == '\\')
{ {
data.insert(data.begin() + pos, '\\'); data.insert(data.begin() + pos, '\\');
pos++; pos += 2;
}
else if (data.at(pos) == '\"')
{
data.insert(data.begin() + pos, '\\');
pos += 2;
} }
} }