5518
|
1 |
diff -ur GConf-2.6.1/gconf/gconf-locale.c GConf-2.6.1.hacked/gconf/gconf-locale.c
|
|
2 |
--- GConf-2.6.1/gconf/gconf-locale.c.orig 2004-08-02 13:19:41.166861000 -0700
|
|
3 |
+++ GConf-2.6.1/gconf/gconf-locale.c 2004-08-02 13:20:49.947469000 -0700
|
|
4 |
@@ -22,6 +22,7 @@
|
|
5 |
#include <sys/time.h>
|
|
6 |
#include <time.h>
|
|
7 |
#include <string.h>
|
|
8 |
+#include <stdio.h>
|
|
9 |
|
|
10 |
static void
|
|
11 |
gconf_locale_cache_add (GConfLocaleCache* cache,
|
|
12 |
@@ -189,7 +190,66 @@
|
|
13 |
* Big mess o' cut-and-pasted code
|
|
14 |
*/
|
|
15 |
|
|
16 |
-/* --------------------------------------------------------------- */
|
|
17 |
+static GHashTable *alias_table = NULL;
|
|
18 |
+
|
|
19 |
+/*read an alias file for the locales*/
|
|
20 |
+static void
|
|
21 |
+read_aliases (char *file)
|
|
22 |
+{
|
|
23 |
+ FILE *fp;
|
|
24 |
+ char buf[256];
|
|
25 |
+ if (!alias_table)
|
|
26 |
+ alias_table = g_hash_table_new (g_str_hash, g_str_equal);
|
|
27 |
+ fp = fopen (file,"r");
|
|
28 |
+ if (!fp)
|
|
29 |
+ return;
|
|
30 |
+ while (fgets (buf,256,fp))
|
|
31 |
+ {
|
|
32 |
+ char *p;
|
|
33 |
+ g_strstrip(buf);
|
|
34 |
+ if (buf[0]=='#' || buf[0]=='\0')
|
|
35 |
+ continue;
|
|
36 |
+ p = strtok (buf,"\t ");
|
|
37 |
+ if (!p)
|
|
38 |
+ continue;
|
|
39 |
+ p = strtok (NULL,"\t ");
|
|
40 |
+ if(!p)
|
|
41 |
+ continue;
|
|
42 |
+ if (!g_hash_table_lookup (alias_table, buf))
|
|
43 |
+ g_hash_table_insert (alias_table, g_strdup(buf), g_strdup(p));
|
|
44 |
+ }
|
|
45 |
+ fclose (fp);
|
|
46 |
+}
|
|
47 |
+
|
|
48 |
+/*return the un-aliased language as a newly allocated string*/
|
|
49 |
+static char *
|
|
50 |
+unalias_lang (char *lang)
|
|
51 |
+{
|
|
52 |
+ char *p;
|
|
53 |
+ int i;
|
|
54 |
+ if (!alias_table)
|
|
55 |
+ {
|
|
56 |
+ read_aliases ("/usr/share/locale/locale.alias");
|
|
57 |
+ read_aliases ("/usr/local/share/locale/locale.alias");
|
|
58 |
+ read_aliases ("/usr/lib/X11/locale/locale.alias");
|
|
59 |
+ read_aliases ("/usr/openwin/lib/locale/locale.alias");
|
|
60 |
+ }
|
|
61 |
+ i = 0;
|
|
62 |
+ while ((p=g_hash_table_lookup(alias_table,lang)) && strcmp(p, lang))
|
|
63 |
+ {
|
|
64 |
+ lang = p;
|
|
65 |
+ if (i++ == 30)
|
|
66 |
+ {
|
|
67 |
+ static gboolean said_before = FALSE;
|
|
68 |
+ if (!said_before)
|
|
69 |
+ g_warning (_("Too many alias levels for a locale, "
|
|
70 |
+ "may indicate a loop"));
|
|
71 |
+ said_before = TRUE;
|
|
72 |
+ return lang;
|
|
73 |
+ }
|
|
74 |
+ }
|
|
75 |
+ return lang;
|
|
76 |
+}
|
|
77 |
|
|
78 |
/* Mask for components of locale spec. The ordering here is from
|
|
79 |
* least significant to most significant
|
|
80 |
@@ -360,6 +420,8 @@
|
|
81 |
category_memory[0]= '\0';
|
|
82 |
category_memory++;
|
|
83 |
|
|
84 |
+ cp = unalias_lang (cp); /* add locale alias support */
|
|
85 |
+
|
|
86 |
if (strcmp (cp, "C") == 0)
|
|
87 |
c_locale_defined= TRUE;
|
|
88 |
|