X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/55bcb773a386a09ea456ea40bc479b34b4227fe8..43a65e9777214029046fe7a1427493e6e503a717:/test/common.sh.in diff --git a/test/common.sh.in b/test/common.sh.in index 1d55dff5..6c9652ce 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -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,28 @@ check_for_hard_links () { set -e } +#### Filter that squeezes blank lines, partially emulating GNU cat -s, +#### but sufficient for our purpose. +#### From http://www-rohan.sdsu.edu/doc/sed.html, compiled by Eric Pement. +squeeze_lines() { + sed '/^$/N;/\n$/D' +} + +#### Filter that converts non-breakable space U+00A0 to an ASCII space. +prepare_space() { + sed '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 +165,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