Fix for recent LANG locale workaround

Need to get a copy of the string since stored pointer is affected
by subsequent calls of setlocale().
This commit is contained in:
Sergey Sharybin 2015-02-04 16:02:47 +05:00
parent 3b0c4d888c
commit 66eacc2abb
1 changed files with 3 additions and 0 deletions

View File

@ -211,11 +211,14 @@ void BLF_lang_init(void)
const char *lang = getenv("LANG");
if(lang != NULL) {
char *old_locale = setlocale(LC_ALL, NULL);
/* Make a copy so subsequenct setlocale() doesn't interfere. */
old_locale = BLI_strdup(old_locale);
if (setlocale(LC_ALL, lang) == NULL) {
setenv("LANG", "C", 1);
printf("Warning: Falling back to the standard locale (\"C\")\n");
}
setlocale(LC_ALL, old_locale);
MEM_freeN(old_locale);
}
#endif