[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help with man-db #40743



Hi,

At Sat, 7 Apr 2001 23:44:04 +0100,
Colin Watson <cjw44@flatline.org.uk> wrote:

> With that in mind, I have an open bug (#40743) against man-db, which
> asks for its treatment of LANG, LC_*, and LANGUAGE to be changed. I'm
> happy to make sure that the patch applies cleanly and still does what it
> says it does, and I'll try to update the documentation too, but I'd like
> to check that the behaviour described in the bug report is what i18n
> people expect.

I wrote a patch which my previous mail mentioned.

Though LANGUAGE variable determines language for messages (thus
usage of LANGUAGE for choosing language for manpage is appropriate),
LANGUAGE variable should be considered only when LC_CTYPE locale
category has significant value (i.e., setlocale(LC_MESSAGES,"")
must return other than NULL, "C", and "POSIX".)  This is because
LANGUAGE is not standard variable but GNU extension.

I found a bug in the patch supplied by Bug#40743.  LANGUAGE check
order is opposite.

The following is the patch to fix these problems.  Please apply
this patch to man-db 2.3.7.1-2 .

-------------------------------------------
--- man-db-2.3.17.1.old/src/man.c	Tue Apr 10 01:33:17 2001
+++ man-db-2.3.17.1/src/man.c	Wed Apr 11 02:14:24 2001
@@ -806,17 +806,25 @@
 {
 	int argc_env, status = 0, exit_status = OK;
 	char **argv_env, *tmp;
-	char *nextarg;
+	char *nextarg, *multiple_locale;
 	extern int optind;
 	void (int_handler)( int);
 
 
 	umask(022);
 	/* initialise the locale */
-	internal_locale = setlocale( LC_ALL, "");
+	setlocale( LC_ALL, "");
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
 
+	internal_locale = setlocale( LC_MESSAGES, NULL);
+	multiple_locale = getenv("LANGUAGE");
+	/* Use LANGUAGE only when LC_MESSAGES locale category is 
+	 * not "C" nor "POSIX". */
+	if (multiple_locale)
+		if (internal_locale && strcmp(internal_locale, "C") &&
+		    strcmp(internal_locale, "POSIX"))
+			internal_locale = multiple_locale;
 	if (internal_locale != NULL)
 		internal_locale = xstrdup (internal_locale);
 	else
@@ -935,9 +943,24 @@
 		exit (exit_status);
 	}
 
-	if (manp == NULL)
-		manp = add_nls_manpath(manpath (alt_system_name), 
-				       internal_locale);
+	if (manp == NULL) {
+		char tmp_locale[3];
+		int idx;
+
+		manp = add_nls_manpath(manpath (alt_system_name), NULL);
+                for ( idx = strlen(internal_locale)-1; idx;) {
+			while (idx && internal_locale[idx] !=':') idx--;
+			if (internal_locale[idx] == ':') idx++;
+			tmp_locale[0] = internal_locale[idx];
+			tmp_locale[1] = internal_locale[idx+1];
+			tmp_locale[2] = 0;
+			if (idx) idx--;
+			if (idx) idx--;
+			if (debug) fprintf(stderr,"checking for locale %s\n"
+					   , tmp_locale);
+			manp = add_nls_manpath(manp,tmp_locale);
+		}
+	}
 	else
 		free(manpath(NULL));
-------------------------------------------
 
---
Tomohiro KUBOTA <kubota@debian.org>
http://surfchem0.riken.go.jp/~kubota/
"Introduction to I18N"
http://www.debian.org/doc/manuals/intro-i18n/



Reply to: