source: patches/man-1.6f-i18n-1.patch@ 8377528

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 8377528 was b0c96c6, checked in by Jim Gifford <clfs@…>, 16 years ago

Added Internationalization Patch to Man

  • Property mode set to 100644
File size: 10.3 KB
RevLine 
[b0c96c6]1Submitted By: Jim Gifford <jim at cross-lfs dot org>
2Date: 2009-01-08
3Initial Package Version: 1.6f
4Upstream Status: Unkown
5Origin: Mandriva
6Description: i18n Updates
7
8diff -Naur man-1.6f.orig/catopen/catopen.c man-1.6f/catopen/catopen.c
9--- man-1.6f.orig/catopen/catopen.c 2005-08-20 16:26:06.000000000 -0700
10+++ man-1.6f/catopen/catopen.c 2009-01-08 22:01:17.000000000 -0800
11@@ -9,22 +9,63 @@
12 extern char *index (const char *, int); /* not always in <string.h> */
13 extern char *my_malloc(int); /* in util.c */
14
15+/* if the program has sgid/suid privileges then getenv doesn't return
16+ * NLSPATH; so we set here a good default value.
17+ */
18 #ifndef DEFAULT_NLSPATH
19 # if __GLIBC__ >= 2
20-# define DEFAULT_NLSPATH "/usr/share/locale/%L/%N"
21+# define DEFAULT_NLSPATH "/usr/share/locale/%L/%N:/usr/share/locale/%l_%t/%N:/usr/share/locale/%l/%N"
22 # else
23 # define DEFAULT_NLSPATH "/usr/lib/locale/%N/%L"
24 # endif
25 #endif
26
27-static nl_catd my_catopenpath(char *name, char *path);
28+static nl_catd my_catopenpath(char *name, char *path, char *lang);
29
30 static /* this source included in gripes.c */
31 nl_catd
32 my_catopen(char *name, int oflag) {
33- nl_catd fd;
34+ nl_catd fd = (nl_catd) -1;
35+
36+ /* using first the my_catopenpath, which looks with LANGUAGE
37+ * and only if it fails ressort to catopen, it gives better i18n
38+ */
39+ {
40+ char *nlspath, *lang, *s;
41
42- fd = catopen(name, oflag);
43+ /*
44+ * "If NLSPATH does not exist in the environment, or if a
45+ * message catalog cannot be opened in any of the paths specified
46+ * by NLSPATH, then an implementation defined default path is used"
47+ */
48+ nlspath = getenv("NLSPATH");
49+ if (!nlspath)
50+ nlspath = DEFAULT_NLSPATH;
51+
52+ lang = getenv("LANGUAGE");
53+ if (!lang)
54+ lang = getenv("LC_ALL");
55+ if (!lang)
56+ lang = getenv("LC_MESSAGES");
57+ if (!lang)
58+ lang = getenv("LANG");
59+ if (!lang)
60+ lang = "";
61+
62+ while(*lang && (fd == (nl_catd) -1)) {
63+ s = index(lang, ':');
64+ if (s) *s = 0;
65+ fd = my_catopenpath(name, nlspath, lang);
66+ if (s) lang=s+1;
67+ else lang = "";
68+ }
69+ if (fd == (nl_catd) -1)
70+ fd = my_catopenpath(name, nlspath, "en");
71+ }
72+
73+ /* still not found, use the system catopen */
74+ if (fd == (nl_catd) -1)
75+ fd = catopen(name, oflag);
76
77 if (fd == (nl_catd) -1 && oflag) {
78 oflag = 0;
79@@ -32,8 +73,6 @@
80 }
81
82 if (fd == (nl_catd) -1) {
83- char *nlspath;
84-
85 /* The libc catopen fails - let us see if we can do better */
86 /* The quotes below are from X/Open, XPG 1987, Vol. 3. */
87
88@@ -58,17 +97,6 @@
89 #endif
90 }
91
92- /*
93- * "If NLSPATH does not exist in the environment, or if a
94- * message catalog cannot be opened in any of the paths specified
95- * by NLSPATH, then an implementation defined default path is used"
96- */
97-
98- nlspath = getenv("NLSPATH");
99- if (nlspath)
100- fd = my_catopenpath(name, nlspath);
101- if (fd == (nl_catd) -1)
102- fd = my_catopenpath(name, DEFAULT_NLSPATH);
103 }
104 return fd;
105 }
106@@ -90,15 +118,13 @@
107 *
108 */
109 static nl_catd
110-my_catopenpath(char *name, char *nlspath) {
111- int fd;
112+my_catopenpath(char *name, char *nlspath, char *lang) {
113 nl_catd cfd = (nl_catd) -1;
114- char *path0, *path, *s, *file, *lang, *lang_l, *lang_t, *lang_c;
115+ char *path0, *path, *s, *file, *lang_l, *lang_t, *lang_c;
116 int langsz, namesz, sz, lang_l_sz, lang_t_sz, lang_c_sz;
117
118 namesz = strlen(name);
119
120- lang = getenv("LANG");
121 if (!lang)
122 lang = "";
123 langsz = strlen(lang);
124@@ -194,14 +220,9 @@
125 path = s+1;
126 } else
127 path = 0;
128- fd = open(file, O_RDONLY);
129- if (fd != -1) {
130- /* we found the right catalog - but we don't know the
131- type of nl_catd, so close it again and ask libc */
132- close(fd);
133- cfd = catopen(file, 0);
134- break;
135- }
136+ cfd = catopen(file, 0);
137+ if (cfd != (nl_catd) -1)
138+ break;
139 }
140
141 free(path0);
142diff -Naur man-1.6f.orig/configure man-1.6f/configure
143--- man-1.6f.orig/configure 2007-08-20 21:15:21.000000000 -0700
144+++ man-1.6f/configure 2009-01-08 22:29:17.000000000 -0800
145@@ -412,9 +412,9 @@
146 fi
147 done
148 done
149- troff=""
150- nroff=""
151- jnroff=""
152+ troff=/usr/bin/troff
153+ nroff=/usr/bin/nroff
154+ jnroff=/usr/bin/nroff
155 eqn=""
156 neqn=""
157 jneqn=""
158@@ -472,29 +472,32 @@
159 done
160 # -Tlatin1 is bad when utf8 is used, but needed for groff, not for nroff
161 # Hmm - also needed for nroff, to prevent double conversion on uxterm
162+ Fgroff=/usr/bin/groff
163+ Fnroff=/usr/bin/nroff
164+ Fjnroff=/usr/bin/nroff
165 if test $Fgroff = "missing"
166 then
167 if test $Fnroff = "missing"
168 then
169- nroff="nroff -Tlatin1 -mandoc"
170+ nroff="nroff -Tutf8 -mandoc"
171 else
172- nroff="$Fnroff -Tlatin1 -mandoc"
173+ nroff="$Fnroff -Tutf8 -mandoc"
174 fi
175 troff="troff -mandoc"
176 echo "Warning: could not find groff"
177 else
178 if test $Fnroff = "missing"
179 then
180- nroff="$Fgroff -Tlatin1 -mandoc"
181+ nroff="$Fgroff -Tutf8 -mandoc"
182 else
183- nroff="$Fnroff -Tlatin1 -mandoc"
184+ nroff="$Fnroff -Tutf8 -mandoc"
185 fi
186 troff="$Fgroff -Tps -mandoc"
187- jnroff="$Fgroff -Tnippon -mandocj"
188+ jnroff="$Fjnroff -Tutf8 -mandocj"
189 fi
190 eqn="$Fgeqn -Tps"
191- neqn="$Fgeqn -Tlatin1"
192- jneqn="$Fgeqn -Tnippon"
193+ neqn="$Fgeqn -Tutf8"
194+ jneqn="$Fgeqn -Tutf8"
195 tbl="$Fgtbl"
196 col="$Fcol"
197 vgrind="$Fvgrind"
198@@ -960,7 +963,7 @@
199
200 # What sections do we anticipate?
201
202-tmpsections="1 1p 8 2 3 3p 4 5 6 7 9 0p tcl n l p o"
203+tmpsections="1 1p 8 2 3 3p 3pm 4 5 6 7 9 0p tcl n l p o"
204
205 if [ x$default = x ]; then
206 echo ""
207diff -Naur man-1.6f.orig/msgs/inst.sh man-1.6f/msgs/inst.sh
208--- man-1.6f.orig/msgs/inst.sh 2005-08-20 16:26:06.000000000 -0700
209+++ man-1.6f/msgs/inst.sh 2009-01-08 22:01:46.000000000 -0800
210@@ -27,8 +27,7 @@
211 for j in $M; do
212 if [ -f $j ]; then
213 i=`echo $j | sed -e 's/mess.//; s/.cat//'`
214- dest=`echo $locdir | sed -e "s/%N/man/; s/%L/$i/"`
215- dest=${PREFIX}$dest
216+ dest=${PREFIX}/`echo $locdir | sed -e "s/%N/man/; s/%L/$i/"`
217 echo "mkdir -p `dirname $dest`"
218 mkdir -p `dirname $dest`;
219 echo "install -c -m 644 $j $dest"
220diff -Naur man-1.6f.orig/src/apropos.sh man-1.6f/src/apropos.sh
221--- man-1.6f.orig/src/apropos.sh 2005-08-20 16:26:06.000000000 -0700
222+++ man-1.6f/src/apropos.sh 2009-01-08 22:02:47.000000000 -0800
223@@ -60,16 +60,56 @@
224 esac
225 done
226
227+# list of languages to look for
228+LANG_LIST=`echo $LANGUAGE:$LC_ALL:$LC_MESSAGES:$LANG | tr ':' ' '`
229+DIR_LIST=""
230+for d in /var/cache/man $manpath /usr/lib
231+do
232+ for l in $LANG_LIST
233+ do
234+ if [ -d $d/$l ]
235+ then
236+ # check that the path is not already in the list
237+ if ! echo "$DIR_LIST" | grep " $d/$l\b" > /dev/null
238+ then
239+ DIR_LIST="$DIR_LIST $d/$l"
240+ fi
241+ fi
242+ done
243+ DIR_LIST="$DIR_LIST $d"
244+ # check that the path is not already in the list
245+ if ! echo "$DIR_LIST" | grep " $d\b" > /dev/null
246+ then
247+ DIR_LIST="$DIR_LIST $d/$l"
248+ fi
249+done
250+
251 while [ "$1" != "" ]
252 do
253 found=0
254- for d in /var/cache/man $manpath /usr/lib
255+ # in order not to display lines in more than one language for
256+ # a same man page; we check that a given man page name
257+ # hasn't already been displayed
258+ BAZ=""
259+ for d in $DIR_LIST
260 do
261 if [ -f $d/whatis ]
262 then
263- if grep -"$grepopt1" "$grepopt2""$1" $d/whatis
264+ if FOO=`grep -"$grepopt1" "$grepopt2""$1" $d/whatis`
265 then
266- found=1
267+ # the LC_ALL=C is needed in case the text is
268+ # in a different encoding than the locale
269+ BAR=`echo -e "$FOO" | LC_ALL=C sed 's/ - .*$//' | tr ' []' '_' | sort -u`
270+ for i in $BAR
271+ do
272+ if ! echo "$BAZ" | grep "$i" > /dev/null
273+ then
274+ BAZ="$BAZ $i"
275+ i="^`echo $i | sed 's:_\+:\\\(\[_ \]\\\|\\\[\\\|\\\]\\\)\\\+:g'`"
276+ echo -e "$FOO" | grep "$i"
277+ found=1
278+ fi
279+ done
280 # Some people are satisfied with a single occurrence
281 # But it is better to give all
282 # break
283diff -Naur man-1.6f.orig/src/makewhatis.sh man-1.6f/src/makewhatis.sh
284--- man-1.6f.orig/src/makewhatis.sh 2007-09-17 11:35:14.000000000 -0700
285+++ man-1.6f/src/makewhatis.sh 2009-01-08 22:02:47.000000000 -0800
286@@ -55,6 +55,9 @@
287 dc=
288 for d in /usr/man/preformat /usr/man /usr/share/man/preformat /usr/share/man
289 do
290+ if [ -n "$LANG" -a -d "$d/$LANG" ]; then
291+ if [ x$dc = x ]; then dm="$d/$LANG"; else dm=$dc:"$d/$LANG"; fi
292+ fi
293 if [ -d $d ]; then
294 if [ x$dc = x ]; then dc=$d; else dc=$dc:$d; fi
295 fi
296@@ -227,7 +230,7 @@
297 section=$i
298 curdir=$mandir/${pages}$i
299 export section verbose curdir
300- find $mandir/${pages}$i/. -name '*' $findarg0 $findarg -print | $AWK '
301+ find $mandir/${pages}$i/. -name '*' $findarg0 $findarg -print | LC_ALL=C $AWK -v MAN_NAME="$MAN_NAME" -v MAN_DESCRIPTION="$MAN_DESCRIPTION" '
302
303 function readline() {
304 if (use_zcat || use_bzcat || use_lzcat) {
305@@ -315,6 +318,7 @@
306 if ($1 ~ /^\.[Ss][HhYS]/ ||
307 (pages == "cat" &&
308 ($1 ~ /^S[yYeE]/ || $1 ~ /^DESCRIPTION/ ||
309+ $1 ~ MAN_DESCRIPTION ||
310 $1 ~ /^COMMAND/ || $1 ~ /^OVERVIEW/ ||
311 $1 ~ /^STRUCTURES/ || $1 ~ /^INTRODUCTION/ ||
312 $0 ~ /^[^ ]/))) {
313diff -Naur man-1.6f.orig/src/manpath.c man-1.6f/src/manpath.c
314--- man-1.6f.orig/src/manpath.c 2006-08-03 14:18:33.000000000 -0700
315+++ man-1.6f/src/manpath.c 2009-01-08 22:01:17.000000000 -0800
316@@ -282,13 +282,14 @@
317 /* We cannot use "lang = setlocale(LC_MESSAGES, NULL)" or so:
318 the return value of setlocale is an opaque string. */
319 /* POSIX prescribes the order: LC_ALL, LC_MESSAGES, LANG */
320- if((lang = getenv("LC_ALL")) != NULL)
321+ /* LANGUAGE is GNU/Linux and overrules all */
322+ if((lang = getenv("LANGUAGE")) != NULL)
323 split2(dir, lang, add_to_mandirlist_x, perrs);
324- if((lang = getenv("LC_MESSAGES")) != NULL)
325+ else if((lang = getenv("LC_ALL")) != NULL)
326 split2(dir, lang, add_to_mandirlist_x, perrs);
327- if((lang = getenv("LANG")) != NULL)
328+ else if((lang = getenv("LC_MESSAGES")) != NULL)
329 split2(dir, lang, add_to_mandirlist_x, perrs);
330- if((lang = getenv("LANGUAGE")) != NULL)
331+ else if((lang = getenv("LANG")) != NULL)
332 split2(dir, lang, add_to_mandirlist_x, perrs);
333 add_to_mandirlist_x(dir, 0, perrs);
334 }
Note: See TracBrowser for help on using the repository browser.