Bug#38107: new patch (correct, this time) for man-db japanese support.
On Wed, Sep 15, 1999 at 02:16:16AM +0900, Fumitoshi UKAI wrote:
>
> Hmm, As I checked your patch, it does not work correctly.
oh, oh, wrong file attached (hummm)...
sorry for the noise </shame>.
fab
--
| fab@pukki.ntc.nokia.com fpolacco@prosa.it fpolacco@debian.org
| 6F7267F5 fingerprint 57 16 C4 ED C9 86 40 7B 1A 69 A1 66 EC FB D2 5E
| fabrizio.polacco@nokia.com gsm: +358 (0)40 707 2468
--- /var/tmp/man.c Wed Sep 8 16:15:44 1999
+++ src/man.c Wed Sep 15 08:56:48 1999
@@ -142,6 +142,18 @@
# define STDERR_FILENO 2
#endif
+char * lang;
+struct lt {
+ char * lang;
+ char * device;
+ char * charset;
+} lang_table[] = {
+ /* LANG roff_device LESSCHARSET */
+ { "ja" , "nippon" , "ja" },
+ { "cs" , "latin2" , "latin2" },
+ { "*" , "latin1" , "latin1" },
+ { 0 , 0 , 0 } };
+
/* external formatter programs, one for use without -t, and one with -t */
#define NFMT_PROG "./mandb_nfmt"
#define TFMT_PROG "./mandb_tfmt"
@@ -317,6 +329,37 @@
}
#endif /* MAN_CATS */
+char * lang_dir( char * filename)
+{
+ char *ld; /* the lang dir: point to static data */
+ char *fm; /* the first "/man/" dir */
+ char *sm; /* the second "/man?/" dir */
+
+ ld = "";
+ if ( ! filename )
+ return ld;
+
+ if ( ! (fm = strstr( filename, "/man/")) )
+ return ld;
+ if ( ! (sm = strstr( 3+fm, "/man")) )
+ return ld;
+ if ( sm == 4+fm )
+ return ld;
+ if ( sm[5] != '/' )
+ return ld;
+ if ( ! strchr( "123456789lno", sm[4]) )
+ return ld;
+ /* found a lang dir */
+ fm += 5;
+ if ( ! (sm = strchr( fm, '/')) )
+ return ld;
+ ld = xstrdup ( fm);
+ ld[sm-fm] = '\0';
+ if (debug)
+ fprintf (stderr, "found lang dir element %s\n", ld);
+ return ld;
+}
+
static __inline__ void gripe_system (char *command, int status)
{
error (CHILD_FAIL, 0, _( "command exited with status %d: %s"), status, command);
@@ -841,8 +884,6 @@
if (optind == argc)
gripe_no_name (NULL);
- putenv("LESSCHARSET=latin1");
-
signal( SIGINT, int_handler);
/* man issued with `-l' option */
@@ -1285,6 +1326,27 @@
char *dev; /* either " -T<mumble>" or "" */
int using_tbl = 0;
+ /* load the roff_device value dependent on the language dir in path */
+ if ( ! roff_device ) {
+ if ( ! *lang ) {
+ roff_device = "latin1";
+ } else {
+ int j;
+ for ( j=0; lang_table[j].lang; j++ ) {
+ if (( strncmp( lang_table[j].lang, lang
+ , strlen( lang_table[j].lang)) == 0 )
+ || ( lang_table[j].lang[0] == '*' )) {
+ roff_device = lang_table[j].device;
+ troff = 1;
+ putenv( strappend ( 0
+ ,"LESSCHARSET="
+ , lang_table[j].charset
+ , 0));
+ j = sizeof(lang_table)/sizeof(struct lt) - 2;
+ }
+ }
+ }
+ }
/* tell grops to guess the page size */
if ( roff_device && strcmp( roff_device, "ps") == 0 )
roff_device = strappend( NULL, "ps -P-g ", NULL);
@@ -2028,6 +2090,7 @@
if (debug)
fprintf (stderr, "found ultimate source file %s\n", man_file);
+ lang = lang_dir (man_file);
cat_file = find_cat_file (path, man_file, sec);
found += display (path, man_file, cat_file, title);
@@ -2135,6 +2198,7 @@
if (debug)
fprintf (stderr, "found ultimate source file %s\n", man_file);
+ lang = lang_dir (man_file);
cat_file = find_cat_file (path, man_file, in->ext);
found += display (path, man_file, cat_file, title);
Reply to: