Return-Path: owner-linux-activists@Niksula.hut.fi
Return-Path: <owner-linux-activists@Niksula.hut.fi>
Received: from joker.cs.hut.fi by hydra.Helsinki.FI (4.1/SMI-4.1/39)
	id AA20163; Thu, 8 Apr 93 18:56:40 +0300
Received: from joker.cs.hut.fi by niksula.hut.fi id <61978-3>; Thu, 8 Apr 1993 18:55:57 +0300
From: "Linux Activists" <linux-activists@Niksula.hut.fi>
To: "Linux-Activists" <linux-activists@Niksula.hut.fi>
Reply-To: "Linux-Activists" <linux-activists@Niksula.hut.fi>
X-Note1: Remember to put 'X-Mn-Key: DOC' to your mail body or header
Subject: Linux-Activists - DOC Channel digest. 93-3-8-13:30
X-Mn-Key: DOC
Sender: owner-linux-activists@Niksula.hut.fi
Message-Id: <93Apr8.185557eet_dst.61978-3@niksula.hut.fi>
Date: Thu, 8 Apr 1993 18:55:48 +0300
Status: RO
X-Status: 


Topics:
	 Re: Linux-Activists - DOC Channel digest. 93-3-8-6:13


----------------------------------------------------------------------

From: Rik Faith <faith@cs.unc.edu>
Subject: Re: Linux-Activists - DOC Channel digest. 93-3-8-6:13
Date: Thu, 8 Apr 1993 16:18:20 +0300


"cloos@TC.Cornell.EDU" wrote (Thu,  8 Apr 1993 15:34:15 +0300):

> At a site where roff src is online for all of the manpages--as it
> really ought to be in most cases--the included makewhatis works fine.
> If only the catpages are available, the whatis database will not be
> buildable.

The current version of John Eaton's man (the C version) for Linux
(ftp.cs.unc.edu:/pub/faith/linux/utils/man11B.taz, which should be
available on tsx-11 and sunsite) has a makewhatis that supports the
following features:

1) Works fine with DOC format pages

2) Can create a whatis database from *.cat pages *ONLY* (thanks to patches
   by Mitchum DSouza)

> If you cannot get the nroff src, I recomend the C man system, and the
> manpath(1) program, if it is not part of that suite.

The manpath program is part of John Eaton's man.

> I'll post another followup when I get makewhatis(8) to proerly
> recognie doc format pages.

You may want to check out the makewhatis that I wrote, since the changes
for DOC should be trivial to fold back into the Perl makewhatis.  My
makewhatis can also be used to create the whatis database for the Perl man
(but, of course, won't make *.dbm files).  Here is a copy from the current
man11B distribution -- it requires bash, gawk, col, sed, sort, uniq, and a
few others.  The support programs must work correctly (some older sed
binaries that were incorrectly compiled will fail).  Please send bug
reports, enhancements, and comments to faith@cs.unc.edu

********************************* CUT HERE *******************************

#!/bin/sh
# makewhatis: create the whatis database
# Created: Sun Jun 14 10:49:37 1992
# Revised: Wed Dec 23 14:22:44 1992 by root
# Copyright 1992 Rickard E. Faith (faith@cs.unc.edu)
# May be freely distributed and modified as long as copyright is retained.

# Wed Dec 23 13:27:50 1992: Rik Faith (faith@cs.unc.edu) applied changes
# based on Mitchum DSouza (mitchum.dsouza@mrc-apu.cam.ac.uk) cat patches.
# Also, cleaned up code and make it work with NET-2 doc pages.


PATH=/usr/bin:/bin

for name in $*
do
case $name in
    -u) update="-ctime 0";
        continue;;
    -c) pages=cat;
        filter="col -bx";
        continue;;
    -*) echo "Usage: makewhatis -c -u [manpath]";
        echo "       -c: build database from cat pages";
        echo "       -u: update database with new pages";
        echo "       [manpath]: man directory (default: /usr/man)";
        exit;;
     *) if [-d $name]
        then
            mandir=$name
        else
            echo "No such directory $name"
            exit
        fi;;
esac
done

pages=${pages-man}
export pages
mandir=${mandir-/usr/man}
filter=${filter-cat}

cd $mandir

for i in 1 2 3 4 5 6 7 8 9 n l
do
    if [ -d ${pages}$i ]
    then
        cd ${pages}$i
        section=$i
        export section
        for j in `find . -name '*' ${update} -print`
        do
            if [ `basename $j .Z` != `basename $j` ]
            then
                Cat=zcat
            else
                Cat=cat
            fi
            ${Cat} ${j} | ${filter} |\
            gawk 'BEGIN {after = 0; insh = 0;
                        pages = ENVIRON["pages"];
                        section = ENVIRON["section"]} {
                if (($1 ~ /^\.[Ss][Hh]/ && $2 ~ /[Nn][Aa][Mm][Ee]/) ||
                    (pages == "cat" && $1 ~ /^NAME/)) {
                    if (!insh)
                        insh = 1
                    else {
                        printf "\n"
                        exit
                    }
                } else if (insh) {
                    if ($1 ~ /^\.[Ss][HhYS]/ ||
                        (pages == "cat" && $1 ~ /^S[yYeE]/)) {
                        printf "\n"
                        exit
                    } else { # Substitutions after Tom Christiansen perl script
                        gsub(/	/, " ")             # Translate tabs to spaces
                        gsub(/  /, " ")             # Collapse spaces
                        gsub(/  /, " ")             # Collapse spaces
                        gsub(/  /, " ")             # Collapse spaces
                        sub(/^[ ]/, "")             # Kill initial spaces
                        sub(/-$/,"")                # Handle Hyphenations
                        sub(/^.[IB] /, "")          # Kill bold and italics
                        gsub(/\\f[PRIB0123]/, "")   # Kill font changes
                        gsub(/\\s[-+0-9]*/, "")     # Kill size changes
                        gsub(/\\&/, "")             # Kill \&
                        gsub(/\\\((ru|ul)/, "_")    # Translate
                        gsub(/\\\((mi|hy|em)/, "-") # Translate
                        gsub(/\\\*\(../, "")        # Kill troff strings
                        sub(/^\.\\\"/, "")          # Kill comments
                        gsub(/\\/, "")              # Kill all backslashes
                        if ($0 !~ / - / && $0 !~ / -$/ && $0 !~ /^- /) {
                            if (after) {
                                if ($1 !~ /^\.../ && $1 != "")
                                    printf " %s", $0
                                else {
                                    printf "\n"
                                    after = 0
                                }
                            } else {
                                if ($1 !~ /^\.../ && $1 != "")
                                    printf "%s ", $0
                                else
                                    printf "\n"
                            }
                        } else {
                            after = 1
                            if ($0 ~ / - /) {
                                printf "%-20s", sprintf( "%s (%s)",
                                    substr( $0, 0, match( $0, / - / )-1 ),
                                        section )
                                printf "%s", substr( $0, match( $0, / - / ) )
                            } else if ($0 ~ / -$/) {
                                printf "%-20s", sprintf( "%s (%s) -",
                                    substr( $0, 0, match( $0, / -$/ )-1 ),
                                        section )
                            } else {
                                printf "(%s) %s", section, $0
                            }
                        }
                    }
                }
            }'
            done
        cd ..
    fi
done > /tmp/whatis$$
sed '/^$/d' < /tmp/whatis$$ | sort | uniq > ${mandir}/whatis
chmod 644 ${mandir}/whatis
rm /tmp/whatis$$
********************************* CUT HERE *******************************



------------------------------

End of DOC Digest
*****************
-------
