aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin/man/makewhatis/makewhatis.perl
diff options
context:
space:
mode:
authorWolfram Schneider <wosch@FreeBSD.org>1996-05-22 00:57:42 +0000
committerWolfram Schneider <wosch@FreeBSD.org>1996-05-22 00:57:42 +0000
commitd1c14152482fb737fde04216f403466aa3ae25c4 (patch)
tree66b53873e9ab01932915a615488ae824014594e5 /gnu/usr.bin/man/makewhatis/makewhatis.perl
parent33d9c4e18ec87a0e6d383a30951927f7d5df8eff (diff)
downloadsrc-d1c14152482fb737fde04216f403466aa3ae25c4.tar.gz
src-d1c14152482fb737fde04216f403466aa3ae25c4.zip
New option -append: teach makewhatis to only add records, instead
of clobbering the entire database. sort options in alphabetic order. install manpage makewhatis.local.8
Notes
Notes: svn path=/head/; revision=15857
Diffstat (limited to 'gnu/usr.bin/man/makewhatis/makewhatis.perl')
-rw-r--r--gnu/usr.bin/man/makewhatis/makewhatis.perl52
1 files changed, 38 insertions, 14 deletions
diff --git a/gnu/usr.bin/man/makewhatis/makewhatis.perl b/gnu/usr.bin/man/makewhatis/makewhatis.perl
index 0d21fd609a99..c4936ddb60ce 100644
--- a/gnu/usr.bin/man/makewhatis/makewhatis.perl
+++ b/gnu/usr.bin/man/makewhatis/makewhatis.perl
@@ -29,20 +29,18 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-
#
# makewhatis -- update the whatis database in the man directories.
#
-# E-Mail: Wolfram Schneider <wosch@cs.tu-berlin.de>
-#
-# $Id: makewhatis.perl,v 1.8 1996/05/12 21:02:04 wosch Exp $
-#
+# $Id: makewhatis.perl,v 1.9 1996/05/14 14:38:12 wosch Exp $
+
sub usage {
warn <<EOF;
-usage: makewhatis [-v|-verbose] [-h|-help] [-i|-indent colum]
- [-n|-name name] [-o|-outfile file] [directories ...]
+usage: makewhatis [-a|-append ] [-h|-help] [-i|-indent colum]
+ [-n|-name name] [-o|-outfile file] [-v|-verbose]
+ [directories ...]
EOF
exit 1;
}
@@ -61,14 +59,38 @@ sub open_output {
}
$tmp = $whatisdb; # for signals
- if (!open(A, "> $whatisdb")) {
- die "$whatisdb: $!\n" if $outfile;
- warn "$whatisdb: $!\n"; $err++; return 0;
- }
+ # Array of all entries
@a = ();
+
+ # Append mode
+ if ($append) {
+ local($file) = $whatisdb;
+ $file =~ s/\.tmp$// if !$outfile;
+
+ if (open(A, "$file")) {
+ warn "Open $file for append mode\n" if $verbose;
+ while(<A>) {
+ push(@a, $_);
+ }
+ close A;
+ }
+
+ else {
+ warn "$whatisdb: $!\n" if lstat($file) && $verbose; #
+ }
+ undef $file;
+ }
+
+
warn "Open $whatisdb\n" if $verbose;
+ if (!open(A, "> $whatisdb")) {
+ die "$whatisdb: $!\n" if $outfile;
+
+ warn "$whatisdb: $!\n"; $err++; return 0;
+ }
+
select A;
return 1;
}
@@ -83,21 +105,21 @@ sub close_output {
if ($success) { # success
# uniq
- @b = ();
warn "\n" if $verbose && $pointflag;
warn "sort -u > $whatisdb\n" if $verbose;
foreach $i (sort @a) {
if ($i ne $last) {
push(@b, $i);
- $counter++;
}
$last =$i;
}
+
+ $counter = $#b + 1;
print @b; close A; select STDOUT;
if (!$outfile) {
- rename($whatisdb, $w);
warn "Rename $whatisdb to $w\n" if $verbose;
+ rename($whatisdb, $w) || warn "rename $whatisdb $w\n";
$counter_all += $counter;
warn "$counter entries in $w\n" if $verbose;
} else {
@@ -411,6 +433,7 @@ sub variables {
$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
# if no argument for directories given
@defaultmanpath = ( '/usr/share/man' );
@@ -453,6 +476,7 @@ sub parse {
elsif (/^--?(o|outfile)$/) { $outfile = $argv[0]; shift @argv }
elsif (/^--?(f|format|i|indent)$/) { $i = $argv[0]; shift @argv }
elsif (/^--?(n|name)$/) { $whatis_name = $argv[0];shift @argv }
+ elsif (/^--?(a|append)$/) { $append = 1 }
else { &usage }
}