Changeset View
Standalone View
src/util.cpp
Show First 20 Lines • Show All 594 Lines • ▼ Show 20 Lines | |||||
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale may | // On most POSIX systems (e.g. Linux, but not BSD) the environment's locale may | ||||
// be invalid, in which case the "C" locale is used as fallback. | // be invalid, in which case the "C" locale is used as fallback. | ||||
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && \ | #if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && \ | ||||
!defined(__OpenBSD__) | !defined(__OpenBSD__) | ||||
try { | try { | ||||
// Raises a runtime error if current locale is invalid. | // Raises a runtime error if current locale is invalid. | ||||
std::locale(""); | std::locale(""); | ||||
} catch (const std::runtime_error &) { | } catch (const std::runtime_error &) { | ||||
setenv("LC_ALL", "C", 1); | setenv("LC_ALL", "C", 1); | ||||
deadalnix: There is a setenv call int hat very file. | |||||
movrcxAuthorUnsubmitted Not Done Inline ActionsThis will be updated to use SetEnvironmentalVariable() movrcx: This will be updated to use SetEnvironmentalVariable() | |||||
} | } | ||||
#endif | #endif | ||||
// The path locale is lazy initialized and to avoid deinitialization errors | // The path locale is lazy initialized and to avoid deinitialization errors | ||||
// in multithreading environments, it is set explicitly by the main thread. | // in multithreading environments, it is set explicitly by the main thread. | ||||
// A dummy locale is used to extract the internal default locale, used by | // A dummy locale is used to extract the internal default locale, used by | ||||
// fs::path, which is then used to explicitly imbue the path. | // fs::path, which is then used to explicitly imbue the path. | ||||
std::locale loc = fs::path::imbue(std::locale::classic()); | std::locale loc = fs::path::imbue(std::locale::classic()); | ||||
fs::path::imbue(loc); | fs::path::imbue(loc); | ||||
Show All 21 Lines | |||||
#endif | #endif | ||||
} | } | ||||
std::string CopyrightHolders(const std::string &strPrefix) { | std::string CopyrightHolders(const std::string &strPrefix) { | ||||
return strPrefix + | return strPrefix + | ||||
strprintf(_(COPYRIGHT_HOLDERS), _(COPYRIGHT_HOLDERS_SUBSTITUTION)); | strprintf(_(COPYRIGHT_HOLDERS), _(COPYRIGHT_HOLDERS_SUBSTITUTION)); | ||||
} | } | ||||
/** | |||||
* Platform independent function to set environmental variable. | |||||
*/ | |||||
int SetEnvironmentalVariable(const char *variableName, const char *variableValue) { | |||||
#if defined(WIN32) | |||||
return _putenv_s(variableName, variableValue); | |||||
#else | |||||
return setenv(variableName, variableValue, 0); | |||||
#endif | |||||
deadalnixUnsubmitted Not Done Inline ActionsThe two codepath do something different. deadalnix: The two codepath do something different. | |||||
movrcxAuthorUnsubmitted Not Done Inline ActionsThe _putenv_s function adds new environment variables or modifies the values of existing environment variables. Environment variables define the environment in which a process executes (for example, the default search path for libraries to be linked with a program). _wputenv_s is a wide-character version of _putenv_s; the envstring argument to _wputenv_s is a wide-character string. The setenv() function shall update or add a variable in the environment of the calling process. The envname argument points to a string containing the name of an environment variable to be added or altered. The environment variable shall be set to the value to which envval points. The function shall fail if envname points to a string which contains an '=' character. If the environment variable named by envname already exists and the value of overwrite is non-zero, the function shall return success and the environment shall be updated. I will switch the overwrite flag to 1 so the behavior is similar. movrcx: The _putenv_s function adds new environment variables or modifies the values of existing… | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsDoes this still need to be completed? jasonbcox: Does this still need to be completed? | |||||
} | |||||
/** | |||||
* Platform independent function to get environmental variable. | |||||
*/ | |||||
const char* GetEnvironmentalVariable(const char *variableName) { | |||||
return getenv(variableName); | |||||
} | |||||
deadalnixUnsubmitted Not Done Inline ActionsNot sure what this brings if this is not plateform dependent. deadalnix: Not sure what this brings if this is not plateform dependent. | |||||
movrcxAuthorUnsubmitted Not Done Inline ActionsI'll remove this function. movrcx: I'll remove this function. | |||||
schancelUnsubmitted Not Done Inline ActionsHaving consistent APIs are good. Please leave it. schancel: Having consistent APIs are good. Please leave it. | |||||
// Obtain the application startup time (used for uptime calculation) | // Obtain the application startup time (used for uptime calculation) | ||||
int64_t GetStartupTime() { | int64_t GetStartupTime() { | ||||
return nStartupTime; | return nStartupTime; | ||||
} | } |
There is a setenv call int hat very file.