aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-10-11 00:39:51 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2012-10-11 00:39:51 -0700
commitac0ad5dc63f89dfc64f869f0babc1899e01ac867 (patch)
treeab0e41516319862f5c6b41484bc5cd0338e7bd33 /src/util.cpp
parenteb49457ff279721cc3cef10fe68fd75b4aa71833 (diff)
parent6032e4f4e7c1892a4e3f0a1a2007e4cd0fe99937 (diff)
downloadbitcoin-ac0ad5dc63f89dfc64f869f0babc1899e01ac867.tar.xz
Merge pull request #1901 from laanwj/2012_10_remove_strlcpy
get rid of strlcpy.h
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 8b08827d73..3eb2619e8f 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -5,10 +5,11 @@
#include "util.h"
#include "sync.h"
-#include "strlcpy.h"
#include "version.h"
#include "ui_interface.h"
#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
+#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
// Work around clang compilation problem in Boost 1.46:
// /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup
@@ -505,24 +506,24 @@ void ParseParameters(int argc, const char* const argv[])
mapMultiArgs.clear();
for (int i = 1; i < argc; i++)
{
- char psz[10000];
- strlcpy(psz, argv[i], sizeof(psz));
- char* pszValue = (char*)"";
- if (strchr(psz, '='))
+ std::string str(argv[i]);
+ std::string strValue;
+ size_t is_index = str.find('=');
+ if (is_index != std::string::npos)
{
- pszValue = strchr(psz, '=');
- *pszValue++ = '\0';
+ strValue = str.substr(is_index+1);
+ str = str.substr(0, is_index);
}
- #ifdef WIN32
- _strlwr(psz);
- if (psz[0] == '/')
- psz[0] = '-';
- #endif
- if (psz[0] != '-')
+#ifdef WIN32
+ boost::to_lower(str);
+ if (boost::algorithm::starts_with(str, "/"))
+ str = "-" + str.substr(1);
+#endif
+ if (str[0] != '-')
break;
- mapArgs[psz] = pszValue;
- mapMultiArgs[psz].push_back(pszValue);
+ mapArgs[str] = strValue;
+ mapMultiArgs[str].push_back(strValue);
}
// New 0.6 features: