mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 10:59:00 +08:00
Fix Strings::split() to handle delimiters of arbitrary size
This commit is contained in:
parent
eca5a8b8d4
commit
86f3a9dbbd
@ -154,11 +154,13 @@ namespace vcpkg::Strings
|
||||
return output;
|
||||
}
|
||||
|
||||
const size_t delimiter_length = delimiter.length();
|
||||
size_t i = 0;
|
||||
for (size_t pos = s.find(delimiter); pos != std::string::npos; pos = s.find(delimiter, pos))
|
||||
{
|
||||
output.push_back(s.substr(i, pos - i));
|
||||
i = ++pos;
|
||||
pos += delimiter_length;
|
||||
i = pos;
|
||||
}
|
||||
|
||||
// Add the rest of the string after the last delimiter, unless there is nothing after it
|
||||
|
Loading…
Reference in New Issue
Block a user