From 0ee9f123b2a53a23bc69b24358dfe915132d2de7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Oct 2012 10:29:34 +0000 Subject: Fix #32819: Crash when starting CUDA kernel compilation if UI translation is not "Default" Issue was caused by some boost filesystem routines accessing current locale and such an access failed in cases code page isn't specified for the current locale. Made it so UTF-8 locale name would be tried to be used first. --- source/blender/blenfont/intern/blf_lang.c | 70 +++++++++++++++++-------------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index ff574a71549..284983b346a 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -214,11 +214,33 @@ void BLF_lang_set(const char *str) get_language_variable("LANGUAGE", default_language, sizeof(default_language)); if (short_locale[0]) { + char *short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale); + if (G.debug & G_DEBUG) - printf("Setting LANG= and LANGUAGE to %s\n", short_locale); + printf("Setting LANG and LANGUAGE to %s\n", short_locale_utf8); + + locreturn = setlocale(LC_ALL, short_locale_utf8); + + if (locreturn != NULL) { + BLI_setenv("LANG", short_locale_utf8); + BLI_setenv("LANGUAGE", short_locale_utf8); + } + else { + if (G.debug & G_DEBUG) + printf("Setting LANG and LANGUAGE to %s\n", short_locale); + + locreturn = setlocale(LC_ALL, short_locale); - BLI_setenv("LANG", short_locale); - BLI_setenv("LANGUAGE", short_locale); + if (locreturn != NULL) { + BLI_setenv("LANG", short_locale); + BLI_setenv("LANGUAGE", short_locale); + } + } + + if (G.debug & G_DEBUG && locreturn == NULL) + printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8); + + MEM_freeN(short_locale_utf8); } else { if (G.debug & G_DEBUG) @@ -226,43 +248,27 @@ void BLF_lang_set(const char *str) BLI_setenv("LANG", default_lang); BLI_setenv("LANGUAGE", default_language); - } + locreturn = setlocale(LC_ALL, ""); - locreturn = setlocale(LC_ALL, short_locale); + if (G.debug & G_DEBUG && locreturn == NULL) + printf("Could not reset locale\n"); + } if (locreturn == NULL) { - char *short_locale_utf8 = NULL; - - if (short_locale[0]) { - short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale); - locreturn = setlocale(LC_ALL, short_locale_utf8); - } - - if (locreturn == NULL) { - char language[65]; - - get_language(long_locale, default_lang, language, sizeof(language)); + char language[65]; - if (G.debug & G_DEBUG) { - if (short_locale[0]) - printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8); - else - printf("Could not reset locale\n"); + get_language(long_locale, default_lang, language, sizeof(language)); - printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language); - } - - /* Fallback to default settings. */ - BLI_setenv("LANG", default_lang); - BLI_setenv("LANGUAGE", language); + if (G.debug & G_DEBUG) + printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language); - locreturn = setlocale(LC_ALL, ""); + /* Fallback to default settings. */ + BLI_setenv("LANG", default_lang); + BLI_setenv("LANGUAGE", language); - ok = 0; - } + locreturn = setlocale(LC_ALL, ""); - if (short_locale_utf8) - MEM_freeN(short_locale_utf8); + ok = 0; } } #endif -- cgit v1.2.3