#! /bin/bash
# Convert ttmgold.lex which is a main function to ttmdynamic.lex a function.
sed -e '/fprintf(tth_fdout,/ s/fprintf(tth_fdout,/add_output(/g 
/*Global string pointer and length*/ r topdynamic.c
s/fprintf(stderr,/add_error(/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 thedynamic.c'\
 -e "/main(argc,argv)/,/* end main */c\\" -e ""\
 -e "/*start executable statements*/ r tthreinitialize.c"\
  ../ttm.lex  | sed  -e "s/tth_/ttm_/g
s/textohtml/textomathml/" -e "/oa_removes/ d"\
 -e "s/mathitalic=1/mathitalic=0/g"  - > ttmdynamic.lex
