1#! /bin/sh
2
3#
4# compare_gets
5#
6# This script compares the results of getting each SID from a list of
7# SCCS files with each of two implementations of sccs-get.
8#
9# usage:
10#   compare_gets.sh dir1 dir2 file [ file ... ]
11#
12# example:
13#   compare_gets.sh /usr/ccs/bin /usr/local/libexec/cssc s.foo.c s.bar.c
14#
15# If you have a source tree to compare, you could use it like this:-
16#   find /usr/src -name s.\* -print |
17#        xargs compare_gets.sh /usr/ccs/bin /usr/local/libexec/cssc
18
19tfile1="/tmp/scmp_tfile1.$$"
20tfile2="/tmp/scmp_tfile2.$$"
21rv=0
22
23# get_sid_list
24#
25# arg1: The name of the SCCS file.
26#
27get_sid_list () {
28    # Lists the SIDs in the named file, on stdout.
29    "$dir1/prs" -l -r1.1 -d:I: "$1" | nl -ba | sort -rn | awk '{print $2;}'
30}
31
32# compare_sid_getting
33#
34# arg1: The name of the SCCS file.
35#
36compare_sid_getting () {
37    sfile="$1"
38    echo "$sfile:"
39    rm -f $tfile1 $tfile2
40    for sid in `get_sid_list "$sfile"`
41    do
42	echo "Comparing $sfile at SID $sid..."
43
44	"$get1" -s -p -r$sid "$sfile" > "$tfile1" 2>/dev/null
45	s1=$?
46	if test $s1 -gt 1
47	then
48	    echo "Fatal error in $get1." >&2
49	    rm -f  $tfile1 $tfile2
50	    exit $s1
51	fi
52
53
54	"$get2" -s -p -r$sid "$sfile" > "$tfile2" 2>/dev/null
55	s2=$?
56	if test $s2 -gt 1
57	then
58	    echo "Fatal error in $get2." >&2
59	    rm -f  $tfile1 $tfile2
60	    exit $s2
61	fi
62
63	diff "$tfile1" "$tfile2" >/dev/null
64	s3=$?
65	rm -f  $tfile1 $tfile2
66	if test $s3 -gt 1
67	then
68	    echo "Fatal error in diff." >&2
69	    exit $s3
70	fi
71
72	if test $s3 -ne 0
73	then
74	    echo "File $sfile differs between $get1 and $get2 at SID $sid" >&2
75	    rv=1
76            return 1
77        fi
78    done
79    return 0
80}
81
82
83dir1="$1"
84dir2="$2"
85get1="$dir1/get"
86get2="$dir2/get"
87
88shift
89shift
90
91if test -x "$get1"
92then
93    true
94else
95    echo "$get1 is not exexutable." >&2
96    exit 2
97fi
98
99if test -x "$get2"
100then
101    true
102else
103    echo "$get2 is not exexutable." >&2
104    exit 2
105fi
106
107rv=0
108
109for filename
110do
111    echo SIDs in file $filename...
112    compare_sid_getting "$filename" || break
113done
114exit $rv
115
116
117# The remaining arguments should be a list of files.
118