]> xenbits.xen.org Git - xenclient/uclibc.git/commitdiff
locale.patch origin/HEAD origin/master
authorVincent Hanquez <vincent.hanquez@eu.citrix.com>
Mon, 9 Feb 2009 17:25:57 +0000 (17:25 +0000)
committerVincent Hanquez <vincent.hanquez@eu.citrix.com>
Mon, 9 Feb 2009 17:25:57 +0000 (17:25 +0000)
Rules.mak
extra/locale/gen_wc8bit.c

index d3cda90374160e08cc0ffc367c72e63156d8a437..39e7ffbbd3b370e2c138ea5d890feb1e48d07a68 100644 (file)
--- a/Rules.mak
+++ b/Rules.mak
@@ -91,7 +91,13 @@ ifneq ($(EXTRAVERSION),)
 VERSION       := $(VERSION)$(EXTRAVERSION)
 endif
 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
-LC_ALL := C
+# To allow gen_wc8bit.c to compile without US UTF installed, LC_CTYPE can be
+# set to another UTF (eg. en_GB.utf8) before typing "make".  However, loading
+# LC_ALL here causes the charmap to be replaced with ANSI_X3.4-1968.  This
+# breaks building gen_wc8bit.c (when the previously mentioned US UTF isn't
+# installed).  Hack workaround is to assume all will be OK without all
+# locale categories set to 'C'.
+# LC_ALL := C
 export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
 
 LIBC := libc
index 20f8f648b7684c543096a473c180fde700f14505..eaa53ce1053e911d07a0212ae5cba5506f7b98a5 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <locale.h>
+#include <langinfo.h>
 #include <stddef.h>
 #include <wctype.h>
 #include <limits.h>
@@ -81,6 +82,7 @@ int main(int argc, char **argv)
 {
        FILE *fp;
        FILE *out;
+       char    *ctype;
        charset_data csd[30];
        unsigned long max_wchar;
        unsigned char *p;
@@ -97,7 +99,26 @@ int main(int argc, char **argv)
        int codeset_list_end = 0;
        int total_size = 0;
 
-       if (!setlocale(LC_CTYPE, "en_US.UTF-8")) {
+       /*
+        * Kludge to allow building on a system without the US UTF installed.
+        * If cannot load the US UTF, then restore the char encoding and
+        * continue if it is a UTF encoding.
+        */
+
+       ctype = setlocale(LC_CTYPE, "");
+       if (ctype != NULL) {
+               i = strlen(ctype);
+               if (i < sizeof (buf)) {
+                       memcpy(buf, ctype, i + 1);
+               } else {
+                       ctype = NULL;
+               }
+       }
+       if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL && ctype != NULL) {
+               (void) setlocale(LC_CTYPE, buf);
+       }
+       if (strcmp(nl_langinfo(CODESET), "UTF-8") != 0 &&
+           setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) {
                printf("setlocale(LC_CTYPE,\"en_US.UTF-8\") failed!\n");
                return EXIT_FAILURE;
        }