Changeset 13993


Ignore:
Timestamp:
2012-11-20T16:40:38+01:00 (11 years ago)
Author:
perost
Message:
  • Got rid of GNU extension asprintf to please clang.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/runtime/systemimpl.c

    r13930 r13993  
    19131913}
    19141914
     1915char* 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
    19151924void SystemImpl__gettextInit(const char *locale)
    19161925{
     
    19361945#else
    19371946  /* 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);
    19401950  char *old_ctype = strdup(setlocale(LC_CTYPE, ""));
    19411951  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
    19441953  int res = *locale == 0 ? setlocale(LC_MESSAGES, "") && setlocale(LC_CTYPE, ""):
    19451954    (setlocale(LC_MESSAGES, locale3) && setlocale(LC_CTYPE, locale3))  ||
Note: See TracChangeset for help on using the changeset viewer.