#!/bin/sh
#                        Copyright (c) 1988 Bellcore
#                            All Rights Reserved
#       Permission is granted to copy or use this program, EXCEPT that it
#       may not be sold for profit, the copyright notice must be reproduced
#       on copies, and credit should be given to Bellcore where it is due.
#       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.

#	$Header: INDEX,v 4.2 88/06/30 12:44:46 bianchi Exp $
#	$Source: /tmp/mgrsrc/doc/usrman/RCS/INDEX,v $


# make an index from troff index generation pass

grep '^[a-z]' $*  |
	sort  +0 -1 -d  +1 -2 -n +2 -3 -r  |
	awk '
	BEGIN	{
			name = ""
			num = 0
			printf ".na\n.Ih"
		}
	name != $1 {
			name = $1
			printf "\n.br\n%s", $1
			num = 0
		}
	num != $2 {
			if( num != 0 )
				printf ","
			if ($3 == "*")	# defining reference
				printf " \\fB%s\\fP",$2
			else		# additional reference
				printf " %s", $2
			num = $2
		}
	END	{
			printf "\n.br\n.ad\n"
		}
	'
