Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cleaning up the whatis file.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
cwr
Veteran
Veteran


Joined: 17 Dec 2005
Posts: 1969

PostPosted: Sun Oct 26, 2008 8:14 pm    Post subject: Cleaning up the whatis file. Reply with quote

The current standard whatis file produced by makewhatis doesn't play
very well with "apropos". Below is an awk script to clean it up and make
apropos' results more useful. It seems easier to post-process makewhatis'
output than patch the makewhatis script itself.

#!/bin/awk -f
# Version 0.3 of 20 October 2008, written for gawk 3.1.5.
#
# Clean up the /usr/share/man/whatis file so that apropos'
# output is more accurate and complete. The output is
# written to stdout, and probably needs to be sorted.
# Ideally the "makewhatis" script would do all this itself,
# but post-processing the main whatis file seems simpler.
#
# Notes:
# Capital letters denote string variables and lower case
# letters denote integers.
# The first section must be updated whenever the version
# numbers change.
#
# Check the command line arguments
BEGIN {
ksh = 0
status = 1
if (ARGC < 2) {
print "Usage: " ENVIRON["_"] " whatisfile - clean up a \"whatis\" file"
status = 0
exit 1
}
}
# Discard all the damaged ksh lines
/\[ksh\]/ { ksh = 1 ; next }
# Check each remaining line of the input
{
# Add missing version numbers to man page names
sub (/\(1ssl\)/, "(1)")
sub (/\(3ssl\)/, "(3)")
sub (/\(5ssl\)/, "(5)")
sub (/\[automake-1/, "&.10")
sub (/\[autoconf-2/, "&.61")
sub (/\[autoheader-2/, "&.61")
sub (/\[autom4te-2/, "&.61")
sub (/\[autoreconf-2/, "&.61")
sub (/\[autoscan-2/, "&.61")
sub (/\[autoupdate-2/, "&.61")
sub (/\[ifnames-2/, "&.61")
sub (/config.guess \[config/, "&.guess-2.61")
sub (/config.sub \[config/, "&.sub-2.61")
sub (/\[gtk-query-immodules-2/, "&.0")
sub (/\[gst-.*-0/, "&.10")
sub (/\[python2\]/, "[python2.4]")
# Remove or correct invalid references
v = split ($0, A, "(") # Get the page and reference entries
split (A[1], B, " ")
C = B[1] " " B[2] # Remove any trailing blanks
w = split (C, D, "/") # Remove any leading path string
x = split (D[w], E, ".") # Get the first part of the page name
y = split (D[w], F, " ") # Get the whole page name
z = match (D[w], /\[.*\]/)
G = substr(D[w], z) # Get the reference name
H = "[" E[1] "]"
# Compare the page name with the reference
if (G == H) {
#print "REPLACEMENT:"
printf "%-20s%s%s\n", F[1], " (", A[2]
}
else {
#print "ORIGINAL:"
print $0
}
}
# Add the corrected Korn shell entries if necessary
END {
if (status && ksh) {
print "ksh (1) - KornShell, a standard/restricted command and programming language"
print "pfksh [ksh] (1) - KornShell, a standard/restricted command and programming language"
print "rksh [ksh] (1) - KornShell, a standard/restricted command and programming language"
}
}
# eof


Any comments welcome - Will
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum