#! /bin/bash
# Convert ttm.lex which is a main function to ttmfunc.lex a function.
sed -e '/fprintf(tth_fdout,/ s/fprintf(tth_fdout,/snprintf(tth_outstring+strlen(tth_outstring),tth_htmllen-strlen(tth_outstring),/g 
s/fprintf(stderr/snprintf(tth_errstring+strlen(tth_errstring),tth_errlen-strlen(tth_errstring)/g 
s/define STATIC/define STATIC static/g 
s/\/\*Function returns here\*\//else if(\!tth_stack_ptr)return 0;/ 
s/yyterminate()/tth_stack_ptr=0;return 0/
/\*\*End of TtH\*\*/ r thefunction.c'\
 -e "/main(argc,argv)/,/* end main */c\\" -e ""\
 -e "/*Global string pointer and length*/a\\" -e "char *tth_outstring;\\
int tth_htmllen;\\
char *tth_errstring;\\
int tth_errlen;
"  ../ttm.lex  | sed  -e "s/tth_/ttm_/g"\
 -e "/oa_removes/ d"\
 -e "s/mathitalic=1/mathitalic=0/g"\
 - > ttmfunc.lex

