Improve fix #32

This commit is contained in:
Jonathan Müller 2018-01-25 21:57:07 +01:00
commit bca488c3d7

View file

@ -736,11 +736,17 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
ts::flag in_string(false), in_char(false);
while (p)
{
auto next = std::strpbrk(p.ptr(), "\"'#/"); // look for ", ', # or /
auto next = std::strpbrk(p.ptr(), R"(\"'#/)"); // look for \, ", ', # or /
if (next && next > p.ptr())
p.bump(std::size_t(next - p.ptr() - 1)); // subtract one to get before that character
if (in_char == false && starts_with(p, "\"")) // starts with "
if (starts_with(p, R"(\\)")) // starts with two backslashes
p.bump(2u);
else if (starts_with(p, R"(\")")) // starts with \"
p.bump(2u);
else if (starts_with(p, R"(\')")) // starts with \'
p.bump(2u);
else if (in_char == false && starts_with(p, R"(")")) // starts with "
{
p.bump();
in_string.toggle();
@ -752,10 +758,6 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
}
else if (in_string == true || in_char == true)
p.bump();
else if (starts_with(p, "\\\"")) // starts with \"
p.bump(2u);
else if (starts_with(p, "\\'")) // starts with \'
p.bump(2u);
else if (auto macro = parse_macro(p, result, file_depth == 0u))
{
if (logger.is_verbose())