changed getTokenExclude method to allow escaped characters.
This commit is contained in:
parent
c70f135710
commit
8f5dd52c6a
@ -291,9 +291,16 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZString ZString::getTokenExclude(const char *exclude) {
|
ZString ZString::getTokenExclude(const char *exclude) {
|
||||||
|
char previous = 0;
|
||||||
char *start = cursor;
|
char *start = cursor;
|
||||||
while ((cursor <= (data + length)) && !isCharacter(*cursor, exclude))
|
do {
|
||||||
|
while ((cursor <= (data + length)) && !isCharacter(*cursor, exclude)) {
|
||||||
|
previous = *cursor;
|
||||||
++cursor;
|
++cursor;
|
||||||
|
}
|
||||||
|
++cursor;
|
||||||
|
} while(previous == '\\');
|
||||||
|
--cursor;
|
||||||
return ZString(start, cursor - start);
|
return ZString(start, cursor - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,4 +112,8 @@ int main(int argc, char **argv) {
|
|||||||
std::cout << "Trailing Zeros: " << test21.removeTrailingZeros() << std::endl;
|
std::cout << "Trailing Zeros: " << test21.removeTrailingZeros() << std::endl;
|
||||||
std::cout << " " << test21 << std::endl;
|
std::cout << " " << test21 << std::endl;
|
||||||
|
|
||||||
|
coreutils::ZString test22("This is a \\\"quoted\\\" string.\"");
|
||||||
|
std::cout << "quoted string: " << test22 << std::endl;
|
||||||
|
std::cout << "quoted string: " << test22.getTokenExclude("\"") << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user