From bca488c3d7acdf7156881c9a763cd43dc035183f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Thu, 25 Jan 2018 21:57:07 +0100 Subject: [PATCH] Improve fix #32 --- src/libclang/preprocessor.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libclang/preprocessor.cpp b/src/libclang/preprocessor.cpp index d05c739..01b8189 100644 --- a/src/libclang/preprocessor.cpp +++ b/src/libclang/preprocessor.cpp @@ -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())