Skip to content

Commit 5f4bcf6

Browse files
committed
boost: drop boost dependency in version.cpp.
Also add a test to verify.
1 parent 352058e commit 5f4bcf6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/test/util_tests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "sync.h"
1010
#include "utilstrencodings.h"
1111
#include "utilmoneystr.h"
12+
#include "version.h"
1213

1314
#include <stdint.h>
1415
#include <vector>
@@ -341,4 +342,15 @@ BOOST_AUTO_TEST_CASE(test_FormatParagraph)
341342
BOOST_CHECK_EQUAL(FormatParagraph("test test", 4, 4), "test\n test");
342343
}
343344

345+
BOOST_AUTO_TEST_CASE(test_FormatSubVersion)
346+
{
347+
std::vector<std::string> comments;
348+
comments.push_back(std::string("comment1"));
349+
std::vector<std::string> comments2;
350+
comments2.push_back(std::string("comment1"));
351+
comments2.push_back(std::string("comment2"));
352+
BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, std::vector<std::string>()),std::string("/Test:0.9.99/"));
353+
BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, comments),std::string("/Test:0.9.99(comment1)/"));
354+
BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, comments2),std::string("/Test:0.9.99(comment1; comment2)/"));
355+
}
344356
BOOST_AUTO_TEST_SUITE_END()

src/version.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#include <string>
1010

11-
#include <boost/algorithm/string/join.hpp>
12-
1311
// Name of client reported in the 'version' message. Report the same name
1412
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
1513
// target servers or GUI users specifically.
@@ -94,7 +92,13 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const
9492
ss << "/";
9593
ss << name << ":" << FormatVersion(nClientVersion);
9694
if (!comments.empty())
97-
ss << "(" << boost::algorithm::join(comments, "; ") << ")";
95+
{
96+
std::vector<std::string>::const_iterator it(comments.begin());
97+
ss << "(" << *it;
98+
for(++it; it != comments.end(); ++it)
99+
ss << "; " << *it;
100+
ss << ")";
101+
}
98102
ss << "/";
99103
return ss.str();
100104
}

0 commit comments

Comments
 (0)