diff options
author | ache <ache@FreeBSD.org> | 1999-09-11 18:21:16 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1999-09-11 18:21:16 +0000 |
commit | e9f7dec9e55a59ba61aacc89c764df9d8551b97d (patch) | |
tree | 35d2ad5b8cb937db14918ead33ec552643e815c4 /gnu | |
parent | d9e5c7d5f23454b95b14ed828e79fcae8c570f38 (diff) | |
download | FreeBSD-src-e9f7dec9e55a59ba61aacc89c764df9d8551b97d.zip FreeBSD-src-e9f7dec9e55a59ba61aacc89c764df9d8551b97d.tar.gz |
localize it
Submitted by: Alexey Zelkin <phantom@crimea.edu>
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/man/makewhatis/makewhatis.1 | 4 | ||||
-rw-r--r-- | gnu/usr.bin/man/makewhatis/makewhatis.perl | 79 |
2 files changed, 68 insertions, 15 deletions
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.1 b/gnu/usr.bin/man/makewhatis/makewhatis.1 index ec9ae57..b715af4 100644 --- a/gnu/usr.bin/man/makewhatis/makewhatis.1 +++ b/gnu/usr.bin/man/makewhatis/makewhatis.1 @@ -34,6 +34,7 @@ .Op Fl a | Fl append .Op Fl h | Fl help .Op Fl i | Fl indent Ar column +.Op Fl L | Fl locale .Op Fl n | Fl name Ar name .Op Fl o | Fl outfile Ar file .Op Fl v | Fl verbose @@ -66,6 +67,9 @@ Print options and exit. .It Fl i , Fl indent Ar column Justify description strings to .Ar column Pq default 24 . +.It Fl L , Fl locale +Sense locale environment variables for possible localized man subdirectories +and process this entries only. .It Fl n , Fl name Ar name Use .Ar name diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.perl b/gnu/usr.bin/man/makewhatis/makewhatis.perl index 7094c92..7b55005 100644 --- a/gnu/usr.bin/man/makewhatis/makewhatis.perl +++ b/gnu/usr.bin/man/makewhatis/makewhatis.perl @@ -32,8 +32,8 @@ sub usage { warn <<EOF; -usage: makewhatis [-a|-append ] [-h|-help] [-i|-indent column] - [-n|-name name] [-o|-outfile file] [-v|-verbose] +usage: makewhatis [-a|-append] [-h|-help] [-i|-indent column] [-L|-locale] + [-n|-name name] [-o|-outfile file] [-v|-verbose] [directories ...] EOF exit 1; @@ -53,11 +53,9 @@ sub open_output { } $tmp = $whatisdb; # for signals - # Array of all entries @a = (); - # Append mode if ($append) { local($file) = $whatisdb; @@ -97,7 +95,6 @@ sub close_output { $w =~ s/\.tmp$//; if ($success) { # success - # uniq warn "\n" if $verbose && $pointflag; warn "sort -u > $whatisdb\n" if $verbose; @@ -199,7 +196,7 @@ sub parse_dir { sub dir_redundant { local($dir) = @_; - local ($dev,$ino) = (stat($dir))[0..1]; + local($dev,$ino) = (stat($dir))[0..1]; if ($dir_redundant{"$dev.$ino"}) { warn "$dir is equal to: $dir_redundant{\"$dev.$ino\"}\n" if $verbose; @@ -332,12 +329,14 @@ sub manual { $extension = &ext($file); $name = &name($file); + $section_name = "NAME|Name|NAMN|BEZEICHNUNG|̾¾Î|îáú÷áîéå"; + local($source) = 0; local($list); while(<F>) { # ``man'' style pages # &&: it takes you only half the user time, regexp is slow!!! - if (/^\.SH/ && /^\.SH[ \t]+["]?(NAME|Name|NAMN|BEZEICHNUNG|̾¾Î)["]?/) { + if (/^\.SH/ && /^\.SH[ \t]+["]?($section_name)["]?/) { #while(<F>) { last unless /^\./ } # Skip #chop; $list = $_; while(<F>) { @@ -354,7 +353,7 @@ sub manual { } } &out($list); close F; return 1; - } elsif (/^\.Sh/ && /^\.Sh[ \t]+["]?(NAME|Name|BEZEICHNUNG|̾¾Î)["]?/) { + } elsif (/^\.Sh/ && /^\.Sh[ \t]+["]?($section_name)["]?/) { # ``doc'' style pages local($flag) = 0; while(<F>) { @@ -425,10 +424,20 @@ sub stripdir { sub variables { $verbose = 0; # Verbose - $indent = 24; # indent for description + $indent = 24; # Indent for description $outfile = 0; # Don't write to ./whatis $whatis_name = "whatis"; # Default name for DB $append = 0; # Don't delete old entries + $locale = 0; # Build DB only for localized man directories + + # choose localized man direcotries suffixs. If $LC_CTYPE is set, then + # its value will be used as suffix, otherwise $LANG value (if set) + $local_suffix = ""; + if ($ENV{'LC_CTYPE'}) { + $local_suffix = $ENV{'LC_CTYPE'}; + } elsif ($ENV{'LANG'}) { + $local_suffix = $ENV{'LANG'} + } # if no argument for directories given @defaultmanpath = ( '/usr/share/man' ); @@ -472,8 +481,11 @@ sub parse { elsif (/^--?(f|format|i|indent)$/) { $i = $argv[0]; shift @argv } elsif (/^--?(n|name)$/) { $whatis_name = $argv[0];shift @argv } elsif (/^--?(a|append)$/) { $append = 1 } + elsif (/^--?(L|locale)$/) { $locale = 1 } else { &usage } } + warn "Localized man directory suffix is ``$local_suffix''\n" + if $verbose && $locale; if ($i ne "") { if ($i =~ /^[0-9]+$/) { @@ -489,6 +501,31 @@ sub parse { warn "Missing directories\n"; &usage; } +# Process man directory +sub process_dir { + local($dir) = @_; + + $dir = &stripdir($dir); + &dir_redundant($dir) && &parse_dir($dir); +} + +# Process man directory and store output to file +sub process_dir_to_file { + local($dir) = @_; + + $dir = &stripdir($dir); + &dir_redundant($dir) && + &close_output(&open_output($dir) && &parse_dir($dir)); +} + +# convert locale name to short notation (ru_RU.KOI8-R -> ru.KOI8-R) +sub short_locale_name { + local($lname) = @_; + + $lname =~ s|_[A-Z][A-Z]||; + warn "short locale name is $lname\n" if $verbose && $locale; + return $lname; +} ## ## Main @@ -498,20 +535,32 @@ sub parse { # allow colons in dir: ``makewhatis dir1:dir2:dir3'' @argv = &parse(split(/[: ]/, join($", @ARGV))); # " - if ($outfile) { if(&open_output($outfile)){ foreach $dir (@argv) { - $dir = &stripdir($dir); - &dir_redundant($dir) && &parse_dir($dir); + # "Local only" flag set ? Yes ... + if ($locale) { + if ($local_suffix ne "") { + &process_dir($dir.'/'.$local_suffix); + &process_dir($dir.'/'.&short_locale_name($local_suffix)); + } + } else { + &process_dir($dir); + } } } &close_output(1); } else { foreach $dir (@argv) { - $dir = &stripdir($dir); - &dir_redundant($dir) && - &close_output(&open_output($dir) && &parse_dir($dir)); + # "Local only" flag set ? Yes ... + if ($locale) { + if ($local_suffix ne "") { + &process_dir_to_file($dir.'/'.$local_suffix); + &process_dir_to_file($dir.'/'.&short_locale_name($local_suffix)); + } + } else { + &process_dir_to_file($dir); + } } } |