mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
refactor: simplify FormatSubVersion
using strprintf/Join
Rather than using std::ostringstream and manually joining the comments, use strprintf and our own `Join` helper.
This commit is contained in:
parent
b94061902e
commit
12d82817bf
1 changed files with 4 additions and 14 deletions
|
@ -5,11 +5,11 @@
|
||||||
#include <config/bitcoin-config.h> // IWYU pragma: keep
|
#include <config/bitcoin-config.h> // IWYU pragma: keep
|
||||||
|
|
||||||
#include <clientversion.h>
|
#include <clientversion.h>
|
||||||
|
#include <util/string.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -64,19 +64,9 @@ std::string FormatFullVersion()
|
||||||
*/
|
*/
|
||||||
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
|
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::string comments_str;
|
||||||
ss << "/";
|
if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; "));
|
||||||
ss << name << ":" << FormatVersion(nClientVersion);
|
return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str);
|
||||||
if (!comments.empty())
|
|
||||||
{
|
|
||||||
std::vector<std::string>::const_iterator it(comments.begin());
|
|
||||||
ss << "(" << *it;
|
|
||||||
for(++it; it != comments.end(); ++it)
|
|
||||||
ss << "; " << *it;
|
|
||||||
ss << ")";
|
|
||||||
}
|
|
||||||
ss << "/";
|
|
||||||
return ss.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CopyrightHolders(const std::string& strPrefix)
|
std::string CopyrightHolders(const std::string& strPrefix)
|
||||||
|
|
Loading…
Add table
Reference in a new issue