aboutsummaryrefslogtreecommitdiffstats
path: root/pc/testoutcmp.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-12-08 21:20:11 +0200
committerArnold D. Robbins <arnold@skeeve.com>2011-12-08 21:20:11 +0200
commitc5da922b0486462028584e4568d6e00d1a4f2783 (patch)
treede1d17b273449e5aa03dcbf79d53edbc0bc3b157 /pc/testoutcmp.awk
parent69239a8fd65ad7f55cc2d567c933a800d5d10fac (diff)
parentd586094c7c4a9a412a7633a32d2b92a8e1cfea1c (diff)
downloadegawk-c5da922b0486462028584e4568d6e00d1a4f2783.tar.gz
egawk-c5da922b0486462028584e4568d6e00d1a4f2783.tar.bz2
egawk-c5da922b0486462028584e4568d6e00d1a4f2783.zip
Merge branch 'gawk-4.0-stable'
Diffstat (limited to 'pc/testoutcmp.awk')
-rw-r--r--pc/testoutcmp.awk38
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
+}