#! /bin/bash
# Convert tth.lex which is a main function to tthfunc.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 "/*Global string pointer and length*/a\\" -e "char *tth_outstring;\\
int tth_htmllen;\\
char *tth_errstring;\\
int tth_errlen;
"\
 -e "/main(argc,argv)/,/* end main */c\\" -e "" ../tth.lex  > tthfunc.lex
