#!/bin/sh

#
# Bring up a patched file in tkdiff.  We show the diffs
# in the topmost patch, unless it was specified
#

. patchfns 2>/dev/null ||
. /usr/lib/patch-scripts/patchfns 2>/dev/null ||
. $PATCHSCRIPTS_LIBDIR/patchfns 2>/dev/null ||
{
	echo "Impossible to find my library 'patchfns'."
	echo "Check your install, or go to the right directory"
	exit 1
}

usage()
{
	echo "Usage: ptkdiff [patchname]"
	exit 1
}

doit()
{
	filename=$1
	unpatched_file=$filename"~"$PATCH_NAME
	need_file_there $filename
	if [ -e $unpatched_file ]
	then
		tkdiff $unpatched_file $filename
	else
		echo ptkdiff: $filename appears to not be in $PATCH_NAME
	fi
}

PATCH_NAME=$(top_patch)

if [ $# = 0 ]
then
	FILES=$(inpatch)
else
	FILES="$*"
fi

for i in $FILES
do
	doit $i &
done
cat txt/$PATCH_NAME.txt
