mirror of
https://github.com/monero-project/monero.git
synced 2024-12-27 16:39:45 -05:00
util: allow newlines in string to be split
This commit is contained in:
parent
fe3f6a3e6b
commit
f19c9f2307
@ -1239,7 +1239,7 @@ std::string get_nix_version_display_string()
|
||||
return get_string_prefix_by_width(s, 999999999).second;
|
||||
};
|
||||
|
||||
std::vector<std::pair<std::string, size_t>> split_string_by_width(const std::string &s, size_t columns)
|
||||
std::vector<std::pair<std::string, size_t>> split_line_by_width(const std::string &s, size_t columns)
|
||||
{
|
||||
std::vector<std::string> words;
|
||||
std::vector<std::pair<std::string, size_t>> lines;
|
||||
@ -1279,4 +1279,17 @@ std::string get_nix_version_display_string()
|
||||
return lines;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, size_t>> split_string_by_width(const std::string &s, size_t columns)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
std::vector<std::pair<std::string, size_t>> all_lines;
|
||||
boost::split(lines, s, boost::is_any_of("\n"), boost::token_compress_on);
|
||||
for (const auto &e: lines)
|
||||
{
|
||||
std::vector<std::pair<std::string, size_t>> new_lines = split_line_by_width(e, columns);
|
||||
for (auto &l: new_lines)
|
||||
all_lines.push_back(std::move(l));
|
||||
}
|
||||
return all_lines;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user