aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin/man/makewhatis/makewhatis.perl
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>1995-09-10 13:05:52 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>1995-09-10 13:05:52 +0000
commit6f4da234fbe76d01e74ff4fd91ac72bd223d3ba7 (patch)
tree157bf1a25e3f94425d73280ce753b9168e1365e9 /gnu/usr.bin/man/makewhatis/makewhatis.perl
parent60ce5bccf03417242de5f133d0a44ab0a45d4b1c (diff)
downloadsrc-6f4da234fbe76d01e74ff4fd91ac72bd223d3ba7.tar.gz
src-6f4da234fbe76d01e74ff4fd91ac72bd223d3ba7.zip
Fix a few minor bugs in makewhatis.
Submitted by: wosch@cs.tu-berlin.de (Wolfram Schneider)
Notes
Notes: svn path=/head/; revision=10662
Diffstat (limited to 'gnu/usr.bin/man/makewhatis/makewhatis.perl')
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.perl37
1 files changed, 33 insertions, 4 deletions
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.perl b/gnu/usr.bin/man/makewhatis/makewhatis.perl
index af2fc5d1a1ff..02f11a36eabb 100644
--- a/gnu/usr.bin/man/makewhatis/makewhatis.perl
+++ b/gnu/usr.bin/man/makewhatis/makewhatis.perl
@@ -35,7 +35,7 @@
#
# E-Mail: Wolfram Schneider <wosch@cs.tu-berlin.de>
#
-# $Id: makewhatis.perl,v 1.5 1995/03/31 04:00:53 joerg Exp $
+# $Id: makewhatis.perl,v 1.6 1995/04/01 11:43:09 joerg Exp $
#
sub usage {
@@ -220,8 +220,9 @@ sub ext {
sub name {
local($name) = @_;
- $name =~ s/.*\///g;
- $name =~ s/\.[^.]*$//;
+ $name =~ s=.*/==;
+ $name =~ s=$ext$==o;
+ $name =~ s=\.[^\.]+$==;
return "$name";
}
@@ -250,6 +251,9 @@ sub out {
$man =~ s/[,. ]+$//;
$man =~ s/,/($extension),/g;
$man .= "($extension)";
+
+ &manpagename;
+
$desc =~ s/^[ \t]+//;
for($i = length($man); $i < $indent && $desc; $i++) {
@@ -262,6 +266,31 @@ sub out {
}
}
+# The filename of manual page is not a keyword.
+# This may be dangerous, because you don't find the manpage
+# whith: $ man <section> <keyword>
+#
+# Add filename if a) filename is not a keyword and b) no keyword(s)
+# exist as file in same mansection
+#
+sub manpagename {
+ foreach (split(/,\s+/, $man)) {
+ s/\(.+//;
+ # filename is keyword
+ return if $name eq $_;
+ }
+
+ $name =~ s=\[=\\\[=g; # shit '['
+ foreach (split(/,\s+/, $man)) {
+ s/\(.+//;
+ ($f = $file) =~ s/$name/$_/;
+ # a keyword exist as file
+ return if -e "$f";
+ }
+
+ $man .= ", $name($extension)";
+}
+
# looking for NAME
sub manual {
local($file) = @_;
@@ -384,7 +413,7 @@ sub variables {
# if no argument for directories given
@defaultmanpath = ( '/usr/share/man' );
- $ext = ".gz"; # extension
+ $ext = '.gz'; # extension
umask(022);
$err = 0; # exit code