Changeset 13993
- Timestamp:
- 2012-11-20T16:40:38+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/runtime/systemimpl.c
r13930 r13993 1913 1913 } 1914 1914 1915 char* alloc_locale_str(const char *locale, int llen, const char *suffix, int slen) 1916 { 1917 char *loc = malloc(sizeof(char) * (llen + slen + 1)); 1918 assert(loc != NULL); 1919 strncpy(loc, locale, llen); 1920 strncpy(loc + llen, suffix, slen + 1); 1921 return loc; 1922 } 1923 1915 1924 void SystemImpl__gettextInit(const char *locale) 1916 1925 { … … 1936 1945 #else 1937 1946 /* We might get sent sv_SE when only sv_SE.utf8 exists, etc */ 1938 char *locale2 = NULL; 1939 char *locale3 = NULL; 1947 int locale_len = strlen(locale); 1948 char *locale2 = alloc_locale_str(locale, locale_len, ".utf8", 5); 1949 char *locale3 = alloc_locale_str(locale, locale_len, ".UTF-8", 6); 1940 1950 char *old_ctype = strdup(setlocale(LC_CTYPE, "")); 1941 1951 int old_ctype_is_utf8 = strcmp(nl_langinfo(CODESET), "UTF-8") == 0; 1942 assert(asprintf(&locale2, "%s.utf8", locale) > 0); 1943 assert(asprintf(&locale3, "%s.UTF-8", locale) > 0); 1952 1944 1953 int res = *locale == 0 ? setlocale(LC_MESSAGES, "") && setlocale(LC_CTYPE, ""): 1945 1954 (setlocale(LC_MESSAGES, locale3) && setlocale(LC_CTYPE, locale3)) ||
Note: See TracChangeset
for help on using the changeset viewer.