#!/bin/sh
#
#  This is a part of ChiTeX.
#  This script is created by 
#    Hung-Yih Chen ()  (yih@math.ncu.edu.tw)
#               (Dept. of Mathematics, National Central Univ.)
#           Last updated  April. 19, 2000
# 
#                All rights preserved   
#

#quickmode="y"

echo "y" > tmp@

gawkbin="gawk"


filename=$1

if test "$filename" = ".tex"; then 
   exit
fi


echo "yes" > tmp@


  bname=`basename $filename`                    

  filea=`echo $bname|cut -d. -f 1` 


rm -f maintemp*@ maintmpb@

  echoprompt=`echo -n "."`
  if test "$echoprompt" = "."; then
     echomode="-n ."
  else
     echoprompt=`echo  ".\c"`
     if test "$echoprompt" = "."; then
        echomode=" .\c"
     else 
        echomode="-e .\c"
     fi
  fi

echo $echomode


dos2unix -n $filename maintempp@ 2> /dev/null

#cp $filename maintemp@


rm -f *.tmp@@


if test "$chbold" = ""; then
 if test -s chbold@; then
   chbold=`echo "y"`
   export chbold
 fi
fi

rm -f nextrun@

chitranutf -v preaddpercent=$preaddpercent maintempp@ > maintemp@
#gawk -f /usr/bin/chitranutf.awk -v preaddpercent=$preaddpercent maintempp@ > maintemp@


#gawk -f /usr/bin/chitranutf.awk $filename > maintemp@



#  if test "$stexf" != ""; then
#     mv maintemp@ $filea.tmp00
#  else
     if test "$2" = "input"; then
        mv maintemp@ $filea.tmp@
     else
        mv maintemp@ $filea".tex"
     fi    
#  fi


  if test -s nextrun@; then
     chmod +x nextrun@
     ./nextrun@
  fi   


exit

