diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-07-03 00:28:18 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-07-03 00:28:18 -0400 |
commit | e9e15c687c5ebdf64f2f0679f5a21b41062bc210 (patch) | |
tree | 53a11b091a118adb696da91d134ee91f7be8ec0e /extra/locale/gen_wc8bit.c | |
parent | 14276f18072accb6ad36e8d784e44ee1e1a29c56 (diff) | |
parent | eac5e6eee91332c3c98f4c5a3ee2d55ec1723d81 (diff) |
Merge branch 'master' of git://uclibc.org/uClibc
Diffstat (limited to 'extra/locale/gen_wc8bit.c')
-rw-r--r-- | extra/locale/gen_wc8bit.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c index 418a1ac9d..126cd1ace 100644 --- a/extra/locale/gen_wc8bit.c +++ b/extra/locale/gen_wc8bit.c @@ -98,8 +98,31 @@ int main(int argc, char **argv) int total_size = 0; if (!setlocale(LC_CTYPE, "en_US.UTF-8")) { - printf("setlocale(LC_CTYPE,\"en_US.UTF-8\") failed!\n"); + /* Silly foreigners disabling en_US locales */ + FILE *fp = popen("locale -a", "r"); + if (!fp) + goto locale_failure; + + while (!feof(fp)) { + char buf[256]; + size_t len; + + if (fgets(buf, sizeof(buf) - 10, fp) == NULL) + goto locale_failure; + + len = strlen(buf); + if (buf[len - 1] == '\n') + buf[--len] = '\0'; + strcat(buf, ".UTF8"); + if (setlocale(LC_CTYPE, buf)) + goto locale_success; + } + + locale_failure: + printf("could not find a UTF8 locale ... please enable en_US.UTF-8\n"); return EXIT_FAILURE; + locale_success: + pclose(fp); } if (!(out = fopen("c8tables.h","w"))) { |