diff --git a/src/detection/locale/locale_linux.c b/src/detection/locale/locale_linux.c index 99edccec0..2b0ad2d4f 100644 --- a/src/detection/locale/locale_linux.c +++ b/src/detection/locale/locale_linux.c @@ -1,61 +1,15 @@ #include "detection/locale/locale.h" -#include "common/properties.h" -#include "common/parsing.h" -#include #include -FF_MAYBE_UNUSED -static void getLocaleFromEnv(FFstrbuf* locale) -{ - ffStrbufAppendS(locale, getenv("LANG")); - if(locale->length > 0) - return; - - ffStrbufAppendS(locale, getenv("LC_ALL")); - if(locale->length > 0) - return; - - ffStrbufAppendS(locale, getenv("LC_MESSAGES")); -} - -static void getLocaleFromStdFn(FFstrbuf* locale) -{ - #ifdef LC_MESSAGES - ffStrbufAppendS(locale, setlocale(LC_MESSAGES, NULL)); - - if(locale->length > 0) - return; - #endif - - ffStrbufAppendS(locale, setlocale(LC_ALL, NULL)); -} - void ffDetectLocale(FFstrbuf* result) { - #if !(defined(__APPLE__) || defined(_WIN32)) - - //Ubuntu (and deriviates) use a non standard locale file. - //Parse it first, because on distributions where it exists, it takes precedence. - //Otherwise use the standard etc/locale.conf file. - ffParsePropFile(FASTFETCH_TARGET_DIR_ETC"/default/locale", "LANG =", result); - - if(result->length > 0) - return; - - ffParsePropFile(FASTFETCH_TARGET_DIR_ETC"/locale.conf", "LANG =", result); - if(result->length > 0) - return; + #ifdef LC_MESSAGES + ffStrbufAppendS(result, setlocale(LC_MESSAGES, NULL)); + if(result->length > 0) + return; #endif - #ifndef _WIN32 - - getLocaleFromEnv(result); - if(result->length > 0) - return; - - #endif - - getLocaleFromStdFn(result); + ffStrbufAppendS(result, setlocale(LC_ALL, NULL)); } diff --git a/src/detection/locale/locale_windows.c b/src/detection/locale/locale_windows.c index 128913129..c14732ffb 100644 --- a/src/detection/locale/locale_windows.c +++ b/src/detection/locale/locale_windows.c @@ -9,10 +9,5 @@ void ffDetectLocale(FFstrbuf* result) wchar_t name[LOCALE_NAME_MAX_LENGTH]; int size = GetUserDefaultLocaleName(name, LOCALE_NAME_MAX_LENGTH); if (size > 1) // including '\0' - { ffStrbufSetNWS(result, (uint32_t)size - 1, name); - ffStrbufAppendS(result, ".UTF-8"); // set explicitly in `ffInitInstance` - } - else - ffStrbufSetS(result, setlocale(LC_ALL, NULL)); }