Index: mttroot/mtt/bin/trans/rep_txt2sh ================================================================== --- mttroot/mtt/bin/trans/rep_txt2sh +++ mttroot/mtt/bin/trans/rep_txt2sh @@ -13,10 +13,14 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.6 2002/04/28 18:55:03 geraint +## Fixed [ 549658 ] awk should be gawk. +## Replaced calls to awk with call to gawk. +## ## Revision 1.5 2000/11/27 10:13:25 peterg ## Now passes though options as second argument ## ## Revision 1.4 1998/04/14 18:17:15 peterg ## More messages about Makefile @@ -53,15 +57,86 @@ echo "Old version saved as $1_rep.txt.SAVE" mv $1_rep.txt $1_rep.txt.SAVE strip_comments < $1_rep.txt.SAVE |\ gawk '{print "mtt", sys, $1, $2}' sys="$1" >$1_rep.txt fi + # Execute the commands - quietly and untidily! # But use switches -strip_comments< $1_rep.txt | sed "s/mtt /mtt -q -u $mtt_switches /" | tee -a JUNK | sh +# | sed "s/mtt /mtt -q -u $mtt_switches /" #| tee -a JUNK | sh + +strip_comments< $1_rep.txt | awk ' +{ + ## Add in the external switches + sub("mtt", sprintf("mtt %s", mtt_switches)); + + ## Count the switches (noting that -i -dr -dw and -de have an argument) + ## and make up a string (switches) containing them + Switches=0; switches = ""; + for (i=2;i<=NF;i++) { + if (match($i,"-")==1) { + Switches++; + switches=sprintf("%s%s", switches, $i); + } + if (match($i,"-i")==1) { + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + if (match($i,"-dr")==1){ + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + if (match($i,"-dw")==1){ + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + if (match($i,"-de")==1){ + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + } + System = $(Switches+2) + Representation = $(Switches+3); + Multiple = "odes odeso sms smso daes daeso"; + Language = $(Switches+4); + + args = $(Switches+5); + if ( (length(args)>0)&&(match(Language,"ps")>0)) { + __Args = sprintf("-%s", gensub(/_/, "-", "g", args) ); + } + else + { + __Args = ""; + } + + ## mtt command + printf("%s\n", $0); + + ## Add in the main mtt switches + __Args = sprintf("%s%s", switches, __Args); + + ## Zap -q -u + gsub("-[qu]","", __Args); + + ## Zap blanks + gsub(" ","", __Args); + + ## copy result to long name file + SysRepLang = sprintf("%s_%s.%s", System, Representation, Language); + if (length(__Args)==0) + __Args = "-noargs"; + SysRepArgLang = sprintf("%s_%s%s.%s", System, Representation, __Args, Language); + printf("echo Creating %s\n", SysRepArgLang); + printf("cp %s %s\n", SysRepLang, SysRepArgLang); + +}' mtt_switches="${mtt_switches}" | sh echo "Done creating representations for $1_rep.tex" Index: mttroot/mtt/bin/trans/rep_txt2tex ================================================================== --- mttroot/mtt/bin/trans/rep_txt2tex +++ mttroot/mtt/bin/trans/rep_txt2tex @@ -12,10 +12,14 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.2 2002/04/28 18:55:03 geraint +## Fixed [ 549658 ] awk should be gawk. +## Replaced calls to awk with call to gawk. +## ## Revision 1.1 2000/12/27 15:57:31 peterg ## Initial revision ## ## Revision 1.15 2000/04/06 10:57:12 peterg ## Removed debug line @@ -65,10 +69,14 @@ # Initial revision # ############################################################### documenttype=$2; +mtt_switches=$4 + +## Remove -u and -q +mtt_switches=`echo ${mtt_switches} | sed 's/-[qu]//g'` if [ "$documenttype" = "book" ]; then # do book version # Inform user echo "Creating $1_rep.tex (directory version)" strip_comments < $1_rep.txt|\ @@ -109,17 +117,43 @@ # Create the LaTeX file strip_comments <$1_rep.txt |\ gawk ' { - ## Count the switches (noting that -i has an argument) - Switches=0; + ## Add in the external switches + sub("mtt", sprintf("mtt %s", mtt_switches)); + + ## Count the switches (noting that -i -dr -dw and -de have an argument) + ## and make up a string (switches) containing them + Switches=0; switches = ""; for (i=2;i<=NF;i++) { - if (match($i,"-")==1) Switches++; - if (match($i,"-i")==1) Switches++; + if (match($i,"-")==1) { + Switches++; + switches=sprintf("%s%s", switches, $i); + } + if (match($i,"-i")==1) { + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + if (match($i,"-dr")==1){ + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + if (match($i,"-dw")==1){ + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } + if (match($i,"-de")==1){ + Switches++; + j=i+1; + switches=sprintf("%s%s", switches, $j); + } } - + print "%%%" switches System = $(Switches+2) Representation = $(Switches+3); Multiple = "odes odeso sms smso daes daeso"; Language = $(Switches+4); Languages = "tex txt r m c h ps icad"; @@ -138,22 +172,39 @@ { _Args = ""; __Args = ""; ___Args = ""; } + + ## Add in the mtt args + __Args = sprintf("%s%s", switches, __Args); + + ## Treat no arguments as -noargs + if (length(__Args)==0){ + __Args = "-noargs"; + header_args = ""; + } + else { + header_args = __Args; + gsub("-", " -", header_args); + header_args = sprintf("(%s)", header_args); + } + +print "%%" __Args "%%" # print "DEBUG", Language, args, _Args, __Args RepLang = sprintf("%s%s.%s", Representation, __Args, Language); SysRepLang = sprintf("%s_%s", System, RepLang); - SysRep = sprintf("%s_%s%s", System, Representation, _Args); + SysRepLangArgs = sprintf("%s_%s", System, RepLang, __Args); + SysRep = sprintf("%s_%s%s", System, Representation, __Args); filename = gensub(/,/, "-", "g", SysRep); - section_head = sprintf("\\textbf{%s.%s}: System %s, representation \\textbf{%s%s}, language \\textbf{%s}", - Representation,Language,System,Representation,__Args,Language); + section_head = sprintf("\\textbf{%s\\_%s.%s} \\emph{%s}", + System,Representation,Language, header_args); # section headings if (match(Languages,Language)>0) { print "\n\n\\section{" section_head "}"; - print "\\label{sec:" SysRepLang "}"; + print "\\label{sec:" SysRepLangArgs "}"; print "\\index{\\textbf{" System "} -- " Representation "}"; print "\n\nMTT command:"; print "\\begin{verbatim}"; for (i=1;i<=NF;i++) printf("%s ", $i); @@ -168,30 +219,23 @@ } # text files if( match("txt r m c h icad",Language)>0) { print " \\begin{verbatim}"; - command = sprintf("cat %s_%s.%s", System, Representation, Language); + command = sprintf("cat %s.txt", filename); system(command); print " \\end{verbatim}"; } # ps files if( match("ps",Language)>0) { - printf("This representation is given as Figure \\Ref{fig:%s}.\n", SysRepLang); + printf("This representation is given as Figure \\Ref{fig:%s}.\n", SysRepLangArgs); FileName = sprintf("%s/%s", PWD, filename); - Label = sprintf("%s", SysRepLang); - Caption = sprintf("System \\textbf{%s}, representation %s%s", System, Representation, __Args); + Label = sprintf("%s", SysRepLangArgs); + Caption = sprintf("System \\textbf{%s}, representation %s (%s)", System, Representation, __Args); printf("\\fig{%s}\n {%s}\n {0.9}\n {%s}\n",FileName,Label,Caption); } } END { -}' system=$1 Directory=$directory PWD=`pwd` > $1_rep.tex +}' mtt_switches="${mtt_switches}" system=$1 Directory=$directory PWD=`pwd` > $1_rep.tex fi - - - - - - -