#! /bin/bash

function add_last_linefeed {
# $1 = file
  if [ "`tail -c 1 $1`" != "" ]; then
    echo "" >> $1
  fi
}

function delete_last_linefeed {
# $1 = file
  if [ "`tail -c 1 $1`" = "" ]; then
    xxx=$1;
    set yyyy `/bin/ls -l $xxx`
    head -c $(( $6 - 1 )) $xxx >$xxx.___
    mv -f $xxx.___ $xxx
  fi
}

for i in 1 2; do
  patch -p1 -s < tmp/patch-0.99.11.$i
done

patch -p1 -s < tmp/patch-0.99.12

rm -f core `find . -name '*.orig'`
rm -f core `find . -size 0`
sh set-permissions
rm -rf tmp
