summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/man/man-1.6f/man-1.6e-use_i18n_vars_in_a_std_way.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/man/man-1.6f/man-1.6e-use_i18n_vars_in_a_std_way.patch')
-rw-r--r--meta/recipes-extended/man/man-1.6f/man-1.6e-use_i18n_vars_in_a_std_way.patch156
1 files changed, 156 insertions, 0 deletions
diff --git a/meta/recipes-extended/man/man-1.6f/man-1.6e-use_i18n_vars_in_a_std_way.patch b/meta/recipes-extended/man/man-1.6f/man-1.6e-use_i18n_vars_in_a_std_way.patch
new file mode 100644
index 0000000000..a448da54d7
--- /dev/null
+++ b/meta/recipes-extended/man/man-1.6f/man-1.6e-use_i18n_vars_in_a_std_way.patch
@@ -0,0 +1,156 @@
1diff -Naur man-1.6e.orig/catopen/catopen.c man-1.6e/catopen/catopen.c
2--- man-1.6e.orig/catopen/catopen.c 2005-08-20 20:26:06.000000000 -0300
3+++ man-1.6e/catopen/catopen.c 2007-05-18 11:31:05.000000000 -0300
4@@ -9,22 +9,63 @@
5 extern char *index (const char *, int); /* not always in <string.h> */
6 extern char *my_malloc(int); /* in util.c */
7
8+/* if the program has sgid/suid privileges then getenv doesn't return
9+ * NLSPATH; so we set here a good default value.
10+ */
11 #ifndef DEFAULT_NLSPATH
12 # if __GLIBC__ >= 2
13-# define DEFAULT_NLSPATH "/usr/share/locale/%L/%N"
14+# define DEFAULT_NLSPATH "/usr/share/locale/%L/%N:/usr/share/locale/%l_%t/%N:/usr/share/locale/%l/%N"
15 # else
16 # define DEFAULT_NLSPATH "/usr/lib/locale/%N/%L"
17 # endif
18 #endif
19
20-static nl_catd my_catopenpath(char *name, char *path);
21+static nl_catd my_catopenpath(char *name, char *path, char *lang);
22
23 static /* this source included in gripes.c */
24 nl_catd
25 my_catopen(char *name, int oflag) {
26- nl_catd fd;
27+ nl_catd fd = (nl_catd) -1;
28+
29+ /* using first the my_catopenpath, which looks with LANGUAGE
30+ * and only if it fails ressort to catopen, it gives better i18n
31+ */
32+ {
33+ char *nlspath, *lang, *s;
34
35- fd = catopen(name, oflag);
36+ /*
37+ * "If NLSPATH does not exist in the environment, or if a
38+ * message catalog cannot be opened in any of the paths specified
39+ * by NLSPATH, then an implementation defined default path is used"
40+ */
41+ nlspath = getenv("NLSPATH");
42+ if (!nlspath)
43+ nlspath = DEFAULT_NLSPATH;
44+
45+ lang = getenv("LANGUAGE");
46+ if (!lang)
47+ lang = getenv("LC_ALL");
48+ if (!lang)
49+ lang = getenv("LC_MESSAGES");
50+ if (!lang)
51+ lang = getenv("LANG");
52+ if (!lang)
53+ lang = "";
54+
55+ while(*lang && (fd == (nl_catd) -1)) {
56+ s = index(lang, ':');
57+ if (s) *s = 0;
58+ fd = my_catopenpath(name, nlspath, lang);
59+ if (s) lang=s+1;
60+ else lang = "";
61+ }
62+ if (fd == (nl_catd) -1)
63+ fd = my_catopenpath(name, nlspath, "en");
64+ }
65+
66+ /* still not found, use the system catopen */
67+ if (fd == (nl_catd) -1)
68+ fd = catopen(name, oflag);
69
70 if (fd == (nl_catd) -1 && oflag) {
71 oflag = 0;
72@@ -32,8 +73,6 @@
73 }
74
75 if (fd == (nl_catd) -1) {
76- char *nlspath;
77-
78 /* The libc catopen fails - let us see if we can do better */
79 /* The quotes below are from X/Open, XPG 1987, Vol. 3. */
80
81@@ -58,17 +97,6 @@
82 #endif
83 }
84
85- /*
86- * "If NLSPATH does not exist in the environment, or if a
87- * message catalog cannot be opened in any of the paths specified
88- * by NLSPATH, then an implementation defined default path is used"
89- */
90-
91- nlspath = getenv("NLSPATH");
92- if (nlspath)
93- fd = my_catopenpath(name, nlspath);
94- if (fd == (nl_catd) -1)
95- fd = my_catopenpath(name, DEFAULT_NLSPATH);
96 }
97 return fd;
98 }
99@@ -90,15 +118,13 @@
100 *
101 */
102 static nl_catd
103-my_catopenpath(char *name, char *nlspath) {
104- int fd;
105+my_catopenpath(char *name, char *nlspath, char *lang) {
106 nl_catd cfd = (nl_catd) -1;
107- char *path0, *path, *s, *file, *lang, *lang_l, *lang_t, *lang_c;
108+ char *path0, *path, *s, *file, *lang_l, *lang_t, *lang_c;
109 int langsz, namesz, sz, lang_l_sz, lang_t_sz, lang_c_sz;
110
111 namesz = strlen(name);
112
113- lang = getenv("LANG");
114 if (!lang)
115 lang = "";
116 langsz = strlen(lang);
117@@ -194,14 +220,9 @@
118 path = s+1;
119 } else
120 path = 0;
121- fd = open(file, O_RDONLY);
122- if (fd != -1) {
123- /* we found the right catalog - but we don't know the
124- type of nl_catd, so close it again and ask libc */
125- close(fd);
126- cfd = catopen(file, 0);
127- break;
128- }
129+ cfd = catopen(file, 0);
130+ if (cfd != (nl_catd) -1)
131+ break;
132 }
133
134 free(path0);
135diff -Naur man-1.6e.orig/src/manpath.c man-1.6e/src/manpath.c
136--- man-1.6e.orig/src/manpath.c 2006-08-03 18:18:33.000000000 -0300
137+++ man-1.6e/src/manpath.c 2007-05-18 11:02:48.000000000 -0300
138@@ -282,13 +282,14 @@
139 /* We cannot use "lang = setlocale(LC_MESSAGES, NULL)" or so:
140 the return value of setlocale is an opaque string. */
141 /* POSIX prescribes the order: LC_ALL, LC_MESSAGES, LANG */
142- if((lang = getenv("LC_ALL")) != NULL)
143+ /* LANGUAGE is GNU/Linux and overrules all */
144+ if((lang = getenv("LANGUAGE")) != NULL)
145 split2(dir, lang, add_to_mandirlist_x, perrs);
146- if((lang = getenv("LC_MESSAGES")) != NULL)
147+ else if((lang = getenv("LC_ALL")) != NULL)
148 split2(dir, lang, add_to_mandirlist_x, perrs);
149- if((lang = getenv("LANG")) != NULL)
150+ else if((lang = getenv("LC_MESSAGES")) != NULL)
151 split2(dir, lang, add_to_mandirlist_x, perrs);
152- if((lang = getenv("LANGUAGE")) != NULL)
153+ else if((lang = getenv("LANG")) != NULL)
154 split2(dir, lang, add_to_mandirlist_x, perrs);
155 add_to_mandirlist_x(dir, 0, perrs);
156 }