summaryrefslogtreecommitdiff
path: root/pc/testoutcmp.awk
blob: ff190155bde97017f18e9b8f2eae9cd444cdc7b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# cmp replacement program for PC where the error messages aren't
# exactly the same.  should run even on old awk

{
	if (FNR == NR)
		file = 0
	else
		file = 1
	gsub(/\r/, "", $0)
	lines[file, FNR] = $0
}

END {
	if (NR/2 != FNR) {
		printf("testoutcmp: warning: files are not of equal length!\n") > "/dev/stderr"
		exit 1
	}

	for (i = 1; i <= FNR; i++) {
		good = lines[0, i]
		actual = lines[1, i]
		if (good == actual)
			continue

		l = length(good)
		if (substr(good, l, 1) == ")")
			l--
		if (substr(good, 1, l) == substr(actual, 1, l))
			continue
		else {
			printf("%s and %s are not equal\n", ARGV[1],
				ARGV[2]) > "/dev/stderr"
			exit 1
		}
	}

	exit 0
}