#! /bin/sh

exec 5>NONSJIS.diff

for file in src/*.[ch];
do
  if test -r ${file}.sjis; then
    infile=${file}.sjis
  else
    infile=$file
  fi
# gawk --ctype=ascii '{ gsub(/[\x81-\x9f\xe0-\xfc]\\/, "&\\"); print }' $infile |
  gawk --ctype=sjis -- '
BEGIN {
  buf = ""
  for (ch = 129; ch <= 159; ++ch)
    buf = buf sprintf("%c\\", ch)
  for (ch = 224; ch <= 252; ++ch)
    buf = buf sprintf("%c\\", ch)
  escape_kanji_group= "[" buf "]"
}
{
  gsub(escape_kanji_group, "&\\")
  print
}' $infile |
  diff -c2 $infile - | sed -e '1s/\.sjis//' -e "2s#-	#$file	#" 1>&5
done

exit 0
