#!/usr/local/bin/ksh

typeset -u xr			# Just in case somebody used "XR" or "xr"

if [ $# -lt 1 ]
then
	print -u2 "Usage: $0 file ..."
	exit 1
fi

for i
do
	gzcat $i |
	while read xr manp sect junk
	do
		if [ "X$xr" != "X.XR" ]
		then
			continue
		fi

		print -u2 -n "Checking for $manp($sect)..."
		if man -w $sect $manp >/dev/null 2>&1
		then
			print -u2 "found!"
		else
			print -u2 "not found!"
			print "$manp($sect) in $i"
		fi
	done
done
