1 --- X11-6.8.1/xc/lib/X11/lcFile.c.orig 2004-09-26 00:27:04.984369960 +0200
2 +++ X11-6.8.1/xc/lib/X11/lcFile.c 2004-09-26 00:29:50.926142976 +0200
10 #define NUM_LOCALEDIR 64
13 #define LOCALE_ALIAS "locale.alias"
16 +/* To be translated: ISO-8859-.* => ISO8859-.* */
18 +canonCharmap(char *alias)
20 + static char canonIso[] = "ISO8859-xx";
22 + if (strncmp(alias, "ISO-8859-", 9) != 0) return alias;
23 + if (strlen(alias) > 9 + 2) return alias;
24 + strcpy(&canonIso[8], &alias[9]);
28 +/* Substitute aa_BB[.CC][@dd] with aa_BB.`locale charmap`[@dd] */
30 +appendCharset(const char *locale)
37 + if (strcmp(locale, "C") == 0 || strcmp(locale, "POSIX") == 0) {
38 + fullName = Xmalloc(strlen(locale) + 1);
39 + strcpy(fullName, locale);
42 + oldLocale = setlocale(LC_CTYPE, locale);
43 + charmap = canonCharmap(nl_langinfo(CODESET));
44 + setlocale(LC_CTYPE, oldLocale);
45 + dot = strchr(locale, '.');
46 + if (dot == NULL) dot = strchr(locale, '\0');
47 + at = strchr(dot, '@');
48 + if (at == NULL) at = strchr(dot, '\0');
49 + fullName = Xmalloc(strlen(locale) - (at-dot) + strlen(charmap) + 2);
50 + memset(fullName, 0, strlen(locale) - (at-dot) + strlen(charmap) + 2);
51 + strncpy(fullName, locale, dot-locale);
52 + strcat(fullName, ".");
53 + strcat(fullName, charmap);
54 + strcat(fullName, at);
59 _XlcResolveLocaleName(
64 /* vendor locale name == Xlocale name, no expansion of alias */
65 - pub->siname = Xmalloc (strlen (lc_name) + 1);
66 - strcpy (pub->siname, lc_name);
67 + tmp_siname = Xmalloc (strlen (lc_name) + 1);
68 + strcpy (tmp_siname, lc_name);
74 + pub->siname = appendCharset(tmp_siname);
77 sinamelen = strlen (pub->siname);
78 if (sinamelen == 1 && pub->siname[0] == 'C') {
82 /* If name is not an alias, use lc_name for locale.dir search */
86 + name = appendCharset(lc_name);
88 + char *tmp_name = name;
89 + name = appendCharset(tmp_name);
93 /* look at locale.dir */
98 - if (name != lc_name)
103 if ((1 + (target_dir ? strlen (target_dir) : 0) +
105 sprintf(buf, "%s/locale.dir", target_dir);
106 target_name = resolve_name(name, buf, RtoL);
108 - if (name != lc_name)
111 if (target_name != NULL) {
113 if ((p = strstr(target_name, "/XLC_LOCALE"))) {
114 --- X11-6.8.1/xc/lib/X11/lcWrap.c.orig 2004-09-26 00:27:36.684550800 +0200
115 +++ X11-6.8.1/xc/lib/X11/lcWrap.c 2004-09-26 00:27:31.716306088 +0200
120 + /* Set locale from env before querying it */
121 + char *oldLocale = NULL;
122 + name = setlocale(LC_CTYPE, "");
123 + if (name != NULL) { /* if NULL, locale is unsupported by glibc */
124 + oldLocale = Xmalloc(strlen(name) + 1);
125 + strcpy(oldLocale, name);
127 name = setlocale (LC_CTYPE, (char *)NULL);
128 + if (oldLocale != NULL) {
129 + setlocale(LC_CTYPE, oldLocale);
132 #if !defined(X_LOCALE)
134 * _XlMapOSLocaleName will return the same string or a substring