#!/bin/sh
#
# run this under Unix with 'sh dosfix' to make a DOS-friendly version
#  of the manual
#
# run with 'sh dosfix +3' to make a +3-friendly version
#
# renames files to fit in 8.3, and turns LF -> CR/LF
# ***WARNING!*** this deletes the original copies of the files!

REFORMAT="cat"
CONVERT="sed s/\$/
/"

# if for a +3, wrap at column 31 and turn tabs into spaces.
if [ "$1" = "+3" ]; then
  REFORMAT="fmt -31"
  CONVERT="tr '[\011\012]' '[\040\015]'"
fi

echo working...

cat README | $REFORMAT | $CONVERT >readme; rm -f README
cat how.to.use | $REFORMAT | $CONVERT >howtouse; rm -f how.to.use
cat introduction | $REFORMAT | $CONVERT >intro; rm -f introduction
cat transcription.guide | $REFORMAT | $CONVERT >trnsguid
rm -f transcription.guide
cat original.contents | $REFORMAT | $CONVERT >contents.org
rm -f original.contents

for i in 1 2 3 4 5 6 7 9; do
  cat chapter$i | $REFORMAT | $CONVERT >foo.tmp; mv foo.tmp chapter$i
done

cat chapter10 | $REFORMAT | $CONVERT >chaptr10; rm -f chapter10

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 \
	24 25 26 27 28 29 30 31 32 33; do
  if [ -f chapter8.part$i ]; then
    cat chapter8.part$i | $REFORMAT | $CONVERT >ch8pt$i; rm -f chapter8.part$i
  fi
done

echo done.
