From 62462b48bc8d55aec8c6d321c07f9d1d9d6885b4 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Fri, 30 Aug 2013 14:38:23 -0700 Subject: [PATCH] Ident collector handles escaped starting quotes Previously, it would consider \"foo\"bar" as a slash and a "foo\"bar" string and this would screw up tracking of quotes in the file. Fix #535. --- cpp/ycm/IdentifierUtils.cpp | 17 +++++++++++------ cpp/ycm/tests/IdentifierUtils_test.cpp | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/cpp/ycm/IdentifierUtils.cpp b/cpp/ycm/IdentifierUtils.cpp index e2d41deb..e35ed07a 100644 --- a/cpp/ycm/IdentifierUtils.cpp +++ b/cpp/ycm/IdentifierUtils.cpp @@ -37,13 +37,18 @@ const char *COMMENT_AND_STRING_REGEX = "|" "/\\*.*?\\*/" // C-style comments, '/* ... */' "|" - // Anything inside single quotes, '...', but mind the escaped quote and the - // escaped slash (\\) - "'(?:\\\\\\\\|\\\\'|.)*?'" + // Anything inside single quotes, '...', but mind: + // 1. that the starting single quote is not escaped + // 2. the escaped slash (\\) + // 3. the escaped single quote inside the string + // "(?