X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Futil.cpp;h=211d1a036f31bfa01befa405fc2996c9db4ed5fd;hb=a93ab877877925c60b2dbf56bdde8aa46b6b7391;hp=3472111bb1e0a50fec9612030272119226147d4f;hpb=eb2a10afd600b2680f24d02ffc73d4c9d9800492;p=novacoin.git diff --git a/src/util.cpp b/src/util.cpp index 3472111..211d1a0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,9 +1,20 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" #include "strlcpy.h" + +// 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 +// See also: http://stackoverflow.com/questions/10020179/compilation-fail-in-boost-librairies-program-options +// http://clang.debian.net/status.php?version=3.0&key=CANNOT_FIND_FUNCTION +namespace boost { + namespace program_options { + std::string to_internal(const std::string&); + } +} + #include #include #include @@ -401,14 +412,14 @@ bool ParseMoney(const char* pszIn, int64& nRet) vector ParseHex(const char* psz) { - static char phexdigit[256] = + static signed char phexdigit[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1, -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1 + -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, @@ -425,12 +436,12 @@ vector ParseHex(const char* psz) { while (isspace(*psz)) psz++; - char c = phexdigit[(unsigned char)*psz++]; - if (c == (char)-1) + signed char c = phexdigit[(unsigned char)*psz++]; + if (c == (signed char)-1) break; unsigned char n = (c << 4); c = phexdigit[(unsigned char)*psz++]; - if (c == (char)-1) + if (c == (signed char)-1) break; n |= c; vch.push_back(n); @@ -567,7 +578,7 @@ vector DecodeBase64(const char* p, bool* pfInvalid) while (1) { - int dec = decode64_table[*p]; + int dec = decode64_table[(unsigned char)*p]; if (dec == -1) break; p++; switch (mode) @@ -607,12 +618,12 @@ vector DecodeBase64(const char* p, bool* pfInvalid) break; case 2: // 4n+2 base64 characters processed: require '==' - if (left || p[0] != '=' || p[1] != '=' || decode64_table[p[2]] != -1) + if (left || p[0] != '=' || p[1] != '=' || decode64_table[(unsigned char)p[2]] != -1) *pfInvalid = true; break; case 3: // 4n+3 base64 characters processed: require '=' - if (left || p[0] != '=' || decode64_table[p[1]] != -1) + if (left || p[0] != '=' || decode64_table[(unsigned char)p[1]] != -1) *pfInvalid = true; break; } @@ -737,26 +748,35 @@ string MyGetSpecialFolderPath(int nFolder, bool fCreate) { PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath = (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA"); + bool fSuccess = false; if (pSHGetSpecialFolderPath) + fSuccess = (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); FreeModule(hShell32); + if (fSuccess) + return pszPath; } // Backup option - if (pszPath[0] == '\0') + std::string strPath; { + const char *pszEnv; if (nFolder == CSIDL_STARTUP) { - strcpy(pszPath, getenv("USERPROFILE")); - strcat(pszPath, "\\Start Menu\\Programs\\Startup"); + pszEnv = getenv("USERPROFILE"); + if (pszEnv) + strPath = pszEnv; + strPath += "\\Start Menu\\Programs\\Startup"; } else if (nFolder == CSIDL_APPDATA) { - strcpy(pszPath, getenv("APPDATA")); + pszEnv = getenv("APPDATA"); + if (pszEnv) + strPath = pszEnv; } } - return pszPath; + return strPath; } #endif