mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 11:35:53 +00:00
Guarantee C locale
* Remove all calls to setlocale to ensure that the global
locale is always C.
* Also replace beast::SystemStats::getNumCpus() with
std:🧵:hardware_concurrency()
This commit is contained in:
committed by
Tom Ritchford
parent
7847ac3144
commit
e965b7c0da
@@ -109,10 +109,6 @@ void CPUInformation::initialise() noexcept
|
||||
hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0;
|
||||
hasSSE3 = IsProcessorFeaturePresent (13 /*PF_SSE3_INSTRUCTIONS_AVAILABLE*/) != 0;
|
||||
has3DNow = IsProcessorFeaturePresent (7 /*PF_AMD3D_INSTRUCTIONS_AVAILABLE*/) != 0;
|
||||
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetNativeSystemInfo (&systemInfo);
|
||||
numCpus = (int) systemInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -397,27 +393,4 @@ String SystemStats::getComputerName()
|
||||
return String (text, len);
|
||||
}
|
||||
|
||||
static String getLocaleValue (LCID locale, LCTYPE key, const char* defaultValue)
|
||||
{
|
||||
TCHAR buffer [256] = { 0 };
|
||||
if (GetLocaleInfo (locale, key, buffer, 255) > 0)
|
||||
return buffer;
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
String SystemStats::getUserLanguage() { return getLocaleValue (LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, "en"); }
|
||||
String SystemStats::getUserRegion() { return getLocaleValue (LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, "US"); }
|
||||
|
||||
String SystemStats::getDisplayLanguage()
|
||||
{
|
||||
DynamicLibrary dll ("kernel32.dll");
|
||||
BEAST_LOAD_WINAPI_FUNCTION (dll, GetUserDefaultUILanguage, getUserDefaultUILanguage, LANGID, (void))
|
||||
|
||||
if (getUserDefaultUILanguage != nullptr)
|
||||
return getLocaleValue (MAKELCID (getUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SISO639LANGNAME, "en");
|
||||
|
||||
return "en";
|
||||
}
|
||||
|
||||
} // beast
|
||||
|
||||
Reference in New Issue
Block a user