Remove one unnecessary backslash-check in StringReader::getTokens(). (This patch looks like it's removing the last backslash-counting loop, but really it removes the first one and then reindents everything.)
This commit is contained in:
@@ -43,20 +43,11 @@ std::string StringReader::getTokens(const char *stop_chars, bool truncateEnd)
|
|||||||
size_t found_pos = rd_string.find_first_of(stop_chars, str_pos);
|
size_t found_pos = rd_string.find_first_of(stop_chars, str_pos);
|
||||||
|
|
||||||
if (rd_string[str_pos] == '\"') {
|
if (rd_string[str_pos] == '\"') {
|
||||||
//See if we have an even or odd number of backslashes (that is, this quote is not or is escaped)
|
|
||||||
int numBackslashes = 0;
|
|
||||||
int countBack = 1;
|
|
||||||
while (str_pos-countBack >= 0 && rd_string[str_pos-countBack] == '\\') {
|
|
||||||
numBackslashes++;
|
|
||||||
countBack++;
|
|
||||||
}
|
|
||||||
//If the quote is not escaped
|
|
||||||
if (numBackslashes % 2 == 0) {
|
|
||||||
//Find the next quote
|
//Find the next quote
|
||||||
found_pos = rd_string.find("\"", str_pos+1);
|
found_pos = rd_string.find("\"", str_pos+1);
|
||||||
//Check to see if the quote is escaped
|
//Check to see if the quote is escaped
|
||||||
numBackslashes = 0;
|
int numBackslashes = 0;
|
||||||
countBack = 1;
|
int countBack = 1;
|
||||||
while (found_pos >= countBack && rd_string[found_pos-countBack] == '\\') {
|
while (found_pos >= countBack && rd_string[found_pos-countBack] == '\\') {
|
||||||
numBackslashes++;
|
numBackslashes++;
|
||||||
countBack++;
|
countBack++;
|
||||||
@@ -74,7 +65,6 @@ std::string StringReader::getTokens(const char *stop_chars, bool truncateEnd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (found_pos == str_pos) //We are at the endline
|
if (found_pos == str_pos) //We are at the endline
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user