Merge pull request #641 from pepsiman/rawstringliteral
Fixed #5028 Fix parsing of C++11 raw string literals
This commit is contained in:
commit
b927b77fc4
|
@ -690,7 +690,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
|||
else if (str.compare(i,2,"R\"")==0) {
|
||||
std::string delim;
|
||||
for (std::string::size_type i2 = i+2; i2 < str.length(); ++i2) {
|
||||
if (i2 > 16 ||
|
||||
if (i2 > 16 + i ||
|
||||
std::isspace(str[i2]) ||
|
||||
std::iscntrl(str[i2]) ||
|
||||
str[i2] == ')' ||
|
||||
|
@ -713,7 +713,9 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
|||
} else if (std::iscntrl((unsigned char)str[p]) ||
|
||||
std::isspace((unsigned char)str[p])) {
|
||||
code << " ";
|
||||
} else if (str[p] == '\"' || str[p] == '\'') {
|
||||
} else if (str[p] == '\\') {
|
||||
code << "\\\\";
|
||||
} else if (str[p] == '\"') {
|
||||
code << "\\" << (char)str[p];
|
||||
} else {
|
||||
code << (char)str[p];
|
||||
|
|
|
@ -316,12 +316,12 @@ private:
|
|||
}
|
||||
|
||||
void readCode2() {
|
||||
const char code[] = "R\"( \" /* abc */ \n)\";";
|
||||
const char code[] = "R\"( \" \\ ' /* abc */ \n)\";";
|
||||
Settings settings;
|
||||
Preprocessor preprocessor(settings, this);
|
||||
std::istringstream istr(code);
|
||||
std::string codestr(preprocessor.read(istr,"test.c"));
|
||||
ASSERT_EQUALS("\" \\\" /* abc */ \\n\"\n;", codestr);
|
||||
ASSERT_EQUALS("\" \\\" \\\\ ' /* abc */ \\n\"\n;", codestr);
|
||||
}
|
||||
|
||||
void readCode3() {
|
||||
|
|
Loading…
Reference in New Issue