diff options
Diffstat (limited to 'pc/testoutcmp.awk')
-rw-r--r-- | pc/testoutcmp.awk | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pc/testoutcmp.awk b/pc/testoutcmp.awk new file mode 100644 index 00000000..ff190155 --- /dev/null +++ b/pc/testoutcmp.awk @@ -0,0 +1,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 +} |