mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-22 18:58:52 +00:00
Merge pull request #6335
0078ce7
wipeable_string: split - treat CR, LF and Tabs as separators (xiphon)
This commit is contained in:
commit
292e2d8f28
@ -188,13 +188,14 @@ void wipeable_string::split(std::vector<wipeable_string> &fields) const
|
|||||||
while (len--)
|
while (len--)
|
||||||
{
|
{
|
||||||
const char c = *ptr++;
|
const char c = *ptr++;
|
||||||
if (c != ' ')
|
const bool space_prev = space;
|
||||||
|
space = std::isspace(c);
|
||||||
|
if (!space)
|
||||||
{
|
{
|
||||||
if (space)
|
if (space_prev)
|
||||||
fields.push_back({});
|
fields.push_back({});
|
||||||
fields.back().push_back(c);
|
fields.back().push_back(c);
|
||||||
}
|
}
|
||||||
space = c == ' ';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +182,7 @@ TEST(wipeable_string, split)
|
|||||||
ASSERT_TRUE(check_split(" foo bar baz ", {"foo", "bar", "baz"}));
|
ASSERT_TRUE(check_split(" foo bar baz ", {"foo", "bar", "baz"}));
|
||||||
ASSERT_TRUE(check_split(" foo bar baz", {"foo", "bar", "baz"}));
|
ASSERT_TRUE(check_split(" foo bar baz", {"foo", "bar", "baz"}));
|
||||||
ASSERT_TRUE(check_split("foo bar baz ", {"foo", "bar", "baz"}));
|
ASSERT_TRUE(check_split("foo bar baz ", {"foo", "bar", "baz"}));
|
||||||
|
ASSERT_TRUE(check_split("\tfoo\n bar\r\nbaz", {"foo", "bar", "baz"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(wipeable_string, parse_hexstr)
|
TEST(wipeable_string, parse_hexstr)
|
||||||
|
Loading…
Reference in New Issue
Block a user