]> diplodocus.org Git - nmh/blobdiff - test/common.sh.in
Added -eval 'set document.browse.margin_width = 0' to elinks
[nmh] / test / common.sh.in
index 1d55dff5656aead7f891d1f634bc8fd466b8f0db..94b41906c791902b61ef97781065968e7b32aee0 100644 (file)
@@ -35,7 +35,7 @@ output_md5()
   #### the same line, the caller needs to add it.  This avoids
   #### differences due to a leading '*' binary file indicator, for
   #### text files, on some platforms (Cygwin).
-  @MD5SUM@ $* | @MD5FMT@ | cut -d ' ' -f 1
+  @MD5SUM@ $* | @MD5FMT@ | awk '{print $1}'
 }
 
 #### Use built-in $((...)) in test suite if shell supports it.
@@ -126,14 +126,29 @@ check_for_hard_links () {
   set -e
 }
 
+#### Filter that squeezes blank lines, emulating GNU cat -s.
+squeeze_lines() {
+  awk 'length($0) == 0 && e == 1 { next }
+          { e = length($0) == 0 }
+          { print }'
+}
+
+#### Filter that inserts initial whitespace and converts non-breakable
+#### space U+00A0 to an ASCII space.
+prepare_space() {
+  sed 's/^/ /; s/'"`printf '\\302\\240'`"'/ /g'
+}
+
 #### check() requires two arguments, each the name of a file to be
 #### diff'ed.
 #### If the same, the second file is removed.  And the first file is
 ####   removed unless there's an optional argument with a value of
 ####   'keep first'.
 #### If different, global variable "failed" is incremented.
-#### If there's an optional 'ignore space' argument, diff -b will
-####   be used instead of cmp to compare the files.
+#### If there's an optional 'ignore space' argument, spacing differences
+####   will not be considered signficant, emulating GNU diff -w.  It
+####   is assumed that the first file has already been run through
+####   prepare_space.
 check() {
     first=$1; shift
     second=$1; shift
@@ -151,7 +166,7 @@ check() {
     success=
     if [ "$ignorespace" ]; then
         #### POSIX diff should support -b.
-        diff -b "$first" "$second" >/dev/null  &&  success=1
+        prepare_space <"$second" | diff -b "$first" - >/dev/null  &&  success=1
     else
         cmp -s "$first" "$second"  &&  success=1
     fi