1e6d6c189SCody Peter Mello#!/bin/bash 2e6d6c189SCody Peter Mello 3e6d6c189SCody Peter Melloif [[ -z "$AWK" || -z "$WORKDIR" ]]; then 4e6d6c189SCody Peter Mello printf '$AWK and $WORKDIR must be set\n' >&2 5e6d6c189SCody Peter Mello exit 1 6e6d6c189SCody Peter Mellofi 7e6d6c189SCody Peter Mello 8e6d6c189SCody Peter MelloTEMP0=$WORKDIR/test.temp.0 9e6d6c189SCody Peter MelloTEMP1=$WORKDIR/test.temp.1 10e6d6c189SCody Peter MelloTEMP2=$WORKDIR/test.temp.2 11e6d6c189SCody Peter Mello 12e6d6c189SCody Peter MelloRESULT=0 13e6d6c189SCody Peter Mello 14e6d6c189SCody Peter Mellofail() { 15e6d6c189SCody Peter Mello echo "$1" >&2 16e6d6c189SCody Peter Mello RESULT=1 17e6d6c189SCody Peter Mello} 18e6d6c189SCody Peter Mello 19e6d6c189SCody Peter Melloecho T.latin1: tests of 8-bit input 20e6d6c189SCody Peter Mello 21e6d6c189SCody Peter Mello$AWK ' 22e6d6c189SCody Peter Mello{ print $0 } 23e6d6c189SCody Peter Mello' latin1 > $TEMP1 24e6d6c189SCody Peter Mello 25e6d6c189SCody Peter Mellodiff latin1 $TEMP1 || fail 'BAD: T.latin1 1' 26e6d6c189SCody Peter Mello 27e6d6c189SCody Peter MelloLC_ALL=C grep '[�-�]' latin1 > $TEMP0 28e6d6c189SCody Peter Mello$AWK '/[�-�]/' latin1 > $TEMP1 29e6d6c189SCody Peter Mellodiff $TEMP0 $TEMP1 || fail 'BAD: T.latin1 2' 30e6d6c189SCody Peter Mello 31e6d6c189SCody Peter Mello$AWK '{ gsub(/\351/, "\370"); print }' latin1 > $TEMP0 32e6d6c189SCody Peter Mello$AWK '{ gsub(/�/, "�"); print }' latin1 > $TEMP1 33e6d6c189SCody Peter Mellodiff $TEMP0 $TEMP1 || fail 'BAD: T.latin1 3' 34e6d6c189SCody Peter Mello 35*3ee4fc2aSCody Peter Mello$AWK '{ gsub(/[^\300-\370]/, ""); print }' latin1 > $TEMP0 36*3ee4fc2aSCody Peter Mello$AWK '{ gsub(/[^�-�]/, ""); print } ' latin1 > $TEMP1 37*3ee4fc2aSCody Peter Mellodiff $TEMP0 $TEMP1 || fail 'BAD: T.latin1 4' 38*3ee4fc2aSCody Peter Mello 39e6d6c189SCody Peter Melloecho '/�/' > $TEMP1 40e6d6c189SCody Peter Mello$AWK -f $TEMP1 $TEMP1 > $TEMP2 41e6d6c189SCody Peter Mellodiff $TEMP1 $TEMP2 || fail 'BAD: T.latin1 5' 42e6d6c189SCody Peter Mello 43e6d6c189SCody Peter Melloecho /[��]/ > $TEMP1 44e6d6c189SCody Peter Mello$AWK -f $TEMP1 $TEMP1 > $TEMP2 45e6d6c189SCody Peter Mellodiff $TEMP1 $TEMP2 || fail 'BAD: T.latin1 6' 46e6d6c189SCody Peter Mello 47e6d6c189SCody Peter Mello 48e6d6c189SCody Peter Melloecho 'This is a line. 49e6d6c189SCody Peter MelloPatterns like /[��]/ do not work yet. Example, run awk /[��]/ 50e6d6c189SCody Peter Melloover a file containing just �. 51e6d6c189SCody Peter MelloThis is another line.' > $TEMP0 52e6d6c189SCody Peter Melloecho 'Patterns like /[��]/ do not work yet. Example, run awk /[��]/ 53e6d6c189SCody Peter Melloover a file containing just �.' > $TEMP1 54e6d6c189SCody Peter Mello$AWK '/[��]/' $TEMP0 > $TEMP2 55e6d6c189SCody Peter Mellodiff $TEMP1 $TEMP2 || fail 'BAD: T.latin1 7' 56e6d6c189SCody Peter Mello 57e6d6c189SCody Peter Melloexit $RESULT 58