Merge pull request #345 from svost/c++11
authorCryptoManiac <CryptoManiac@users.noreply.github.com>
Fri, 6 May 2016 22:28:52 +0000 (02:28 +0400)
committerCryptoManiac <CryptoManiac@users.noreply.github.com>
Fri, 6 May 2016 22:28:52 +0000 (02:28 +0400)
Minor fix: c++11 branch

src/ecies.cpp
src/init.cpp
src/serialize.h
src/ui_interface.h

index 93a8900..502bc96 100644 (file)
@@ -523,7 +523,7 @@ unsigned char * ecies_decrypt(const ies_ctx_t *ctx, const cryptogram_t *cryptogr
 {
     unsigned char *envelope_key = NULL, *output = NULL;
 
-    if (!ctx || !cryptogram || !length || !error) {
+    if (!ctx || !cryptogram || !length) {
         SET_ERROR("Invalid argument");
         goto err;
     }
index 6689169..5117dd5 100644 (file)
@@ -584,7 +584,6 @@ bool AppInit2()
         printf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
     printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
     printf("Used data directory %s\n", strDataDir.c_str());
-    std::ostringstream strErrors;
 
     if (fDaemon)
         fprintf(stdout, "NovaCoin server starting\n");
@@ -595,8 +594,6 @@ bool AppInit2()
             NewThread(ThreadScriptCheck, NULL);
     }
 
-    int64_t nStart;
-
     // ********************************************************* Step 5: verify database integrity
 
     uiInterface.InitMessage(_("Verifying database integrity..."));
@@ -794,6 +791,7 @@ bool AppInit2()
 
     printf("Loading block index...\n");
     bool fLoaded = false;
+    int64_t nStart;
     while (!fLoaded) {
         std::string strLoadError;
         uiInterface.InitMessage(_("Loading block index..."));
@@ -845,7 +843,7 @@ bool AppInit2()
         for (auto mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
         {
             auto hash = (*mi).first;
-            if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
+            if (strMatch.compare(hash.ToString()) == 0)
             {
                 auto pindex = (*mi).second;
                 CBlock block;
@@ -879,6 +877,7 @@ bool AppInit2()
     uiInterface.InitMessage(_("Loading wallet..."));
     printf("Loading wallet...\n");
     nStart = GetTimeMillis();
+    std::ostringstream strErrors;
     bool fFirstRun = true;
     pwalletMain = new CWallet(strWalletFileName);
     DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun);
index e54d1aa..ddff706 100644 (file)
@@ -845,20 +845,6 @@ public:
     iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); }
     void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); }
 
-    void insert(iterator it, const_iterator first, const_iterator last)
-    {
-        assert(last - first >= 0);
-        if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
-        {
-            // special case for inserting at the front when there's room
-            nReadPos -= (unsigned int)(last - first);
-            memcpy(&vch[nReadPos], &first[0], last - first);
-        }
-        else
-            vch.insert(it, first, last);
-    }
-
-#ifndef _MSC_VER
     void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last)
     {
         assert(last - first >= 0);
@@ -871,7 +857,6 @@ public:
         else
             vch.insert(it, first, last);
     }
-#endif
 
     void insert(iterator it, const char* first, const char* last)
     {
index d62e64b..c56bb30 100644 (file)
@@ -105,8 +105,14 @@ extern CClientUIInterface uiInterface;
  */
 inline std::string _(const char* psz)
 {
-    boost::optional<std::string> rv = uiInterface.Translate(psz);
-    return rv ? (*rv) : psz;
+    try {
+        boost::optional<std::string> rv = uiInterface.Translate(psz);
+        return rv ? (*rv) : psz;
+    }
+    catch (const boost::bad_function_call& e) {
+        printf("Warning: %s in %s:%d\n", e.what(), __FILE__, __LINE__);
+        return psz;
+    }
 }
 
 #endif