[comp.unix.questions] permuted index

jmp@sobeco.uucp (j.pigeon) (08/14/89)

I am looking for the source of a program that produces permuted indices of
the kind found at the beginning of your unix Users Reference Manual.

If possible reply via E-MAIL

Tks

Pierre Laporte
{attcan,mcgill-vision,telly}!sobeco!laporte

tmoore@ciss.Dayton.NCR.COM (Tom.Moore@ciss.Dayton.NCR.COM) (08/17/89)

jmp@sobeco.uucp (j.pigeon) writes:


>I am looking for the source of a program that produces permuted indices of
>the kind found at the beginning of your unix Users Reference Manual.

Try checking the manual for ptx(1) and mptx(5).
These are also found by looking in the permuted index for the keywords
"permuted" or 'index". :-)

-- 
* Tom Moore                NCR Corporation  PCD-6              (513) 445-1373 *
* Consulting Analyst       1700 S. Patterson Blvd.         VOICEplus 622-1373 *
* Network Applications     Dayton, OH 45479          Tom.Moore@Dayton.NCR.COM *

luke@research.canon.oz.au (Luke Kendall) (05/22/91)

The utility `ptx' which generates lines like:

.xx "" "permuted index generation by" "computer" ""
.xx "" "permuted index" "generation by computer" ""
.xx "" "permuted" "index generation by computer" ""
.xx "computer" "" "permuted index generation by" ""

expects you to have or write a suitable .xx macro for troff, which does
several fancy things, but the major one being that the third argument
(the one that the index is sorted on) aligns vertically.

None of the macro packages in /usr/lib/tmac contain definitions of an
xx macro (ie. grep "de *xx" ... finds none).  I've written my own,
passable (but rather weak) macro, but was wondering if anyone has a
more polished one?

----
PS:  in case you're interested, here is the shell script I've written
     that wraps around `ptx':
----
#!/bin/sh
#
# Author: Luke Kendall
#
MYNAME=`basename $0`
usage="usage: $MYNAME [man-directory]
	(generates permuted index of -man files in directory)"
md=/usr/man
#
if [ $# = 0 ]
then
    echo "$MYNAME: no man directory specified: assuming $md"
elif [ $# != 1 ]
then
    echo "$usage"
    exit 1
elif [ -d $1 ]
then
    md="$1"
else
    echo "$usage"
    exit 1
fi
echo "Permuted index of $md:"
out=ptx.tr
# ------ clumsy permuted index macros ------------
cat <<'EOF' > $out
.pn 1
.de xx
\\$1 \\$2  \\fB\\$3\\fR  \\$4	\\s-1\\$5\\s0
..
.pl 10i
.de NP
.ev 1
.ft 1
.ps 10
.sp 0.75c
.tl '\s-2\\fIpermuted index\\fP\s0'\- \\n% \-'\s-2\\fIpermuted index\\fP\s0'
.pn +1
.bp
.ev
..
.wh 9i NP
.nf
.na
.ta 6.5i-1.1iR 6.5iR 6.51iR 6.52R
.ll 6.0i
.po 0i
.sp 0.25i
'\"
EOF
# ------  -------  -------  -------  -------  -------
find $md -type f -name "*.n" -print |
while read f
do
    man=`basename $f`
    man=`expr "$man" : "\(.*\)\.[^\.]*"`
echo $man:
    #
    # Use 1st non-"." and non-"'" started line as input to ptx (this
    # should be the synopsis after the `.SH NAME');
    # strip any "\-" from it (a silly sort key for ptx to avoid);
    # insert a leading man page name for the -r option to find
    #
    sed -n '/^[^.]/s/\\-//gp;/^[^.]/q' $f | sed "s/^/($man) /"
done  | ptx -t -f -r  >> $out
#
# Turn the troff'able permuted index file into PostScript
#
psroff -t -rL10i $out > ptx.ps
echo "$out and ptx.ps produced from man directory $md."
-- 
Luke Kendall, Senior Software Engineer.      | Net:   luke@research.canon.oz.au
Canon Information Systems Research Australia | Phone: +61 2 805 2914
P.O. Box 313 North Ryde, NSW, Australia 2113 | Fax:   +61 2 805 2929