- Timestamp:
- Jan 30, 1998, 3:12:57 PM (26 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- 9dac21e20830c8d04a26496a2d4e9328a8770887
- Parents:
- 90dd8df690c3da99f0983c5c64be68efe15586bc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/fex/runfex
r90dd8df ra292a29 1 #! / mnt/amd/users/urmel/insider/schmidt/bin/bash2 # $Id: runfex,v 1. 2 1997-10-28 17:18:36schmidt Exp $1 #! /home/schmidt/bin/bash 2 # $Id: runfex,v 1.3 1998-01-30 14:12:57 schmidt Exp $ 3 3 4 4 #{{{ docu … … 19 19 # XXColWidth: default width for data columns. Used by main() and 20 20 # example(). 21 # PreCharWidth: width of one preformatted character in pixels.22 # Used by printData().23 21 # EvalAlg: algorithm to read run/collection data from. Used by 24 22 # main(). … … 27 25 readonly ExecName="$0" 28 26 29 typeset -ir TBColWidth=300 30 typeset -ir XOColWidth=400 31 typeset -ir ROColWidth=400 32 33 typeset -ir PreCharWidth=6 27 typeset -ir TBColWidth=80 28 typeset -ir ROColWidth=80 34 29 35 30 readonly EvalAlg="feval" … … 41 36 # - global variables. 42 37 # 43 # runName: name of current run. Used by main() and example().44 # collectionName, collectionNote: name of current collection,45 # comment on it. Used by main() and createTable().46 38 # runOptions, collectionOptions, runEnvironment, 47 39 # collectionEnvironment: options and environment for the … … 49 41 # collectionROOptions: options to print run overview. Use by 50 42 # main(). 51 # run XXOptions, collectionXXOptions: options to print XX tables.43 # runTBOptions, collectionTBOptions: options to print XX tables. 52 44 # Used by example(). 53 45 # debugMode: do not execute anything, just print what we would … … 55 47 # runAlgorithm(). 56 48 # 57 # The run* variables, debugMode, and collectionName are set in 58 # the main program, the rest of the collection* variables in 59 # collection(). 60 # 61 #}}} 62 runName="" 49 # The run* variables and debugMode are set in the main program, 50 # the rest of the collection* variables in collection(). 51 # 52 #}}} 63 53 runOptions="" 64 54 runEnvironment="" 65 55 runTBOptions="" 66 runXOOptions="" 67 68 collectionName="" 69 collectionNote="" 56 70 57 collectionOptions="" 71 58 collectionEnvironment="" 72 59 collectionTBOptions="" 73 collectionXOOptions=""74 60 collectionROOptions="" 75 61 … … 93 79 { 94 80 echo "$ExecName:" "${@-}" >&2 95 }96 #}}}97 98 #{{{ pc ()99 #{{{ docu100 #101 # pc() - print html table cell.102 #103 # $1: cell contents104 # $2: cell format information105 #106 # Global variables used: none107 #108 #}}}109 pc()110 {111 echo "<th ${2-}><font size=+1>$1</font></th>"112 }113 #}}}114 115 #{{{ pct ()116 #{{{ docu117 #118 # pc() - print html table cell in type writer style.119 #120 # $1: cell contents121 # $2: cell format information122 #123 # Global variables used: none124 #125 #}}}126 pct()127 {128 echo "<th valign=center ${2-}><tt><font size=+2>$1</font></tt></th>"129 81 } 130 82 #}}} … … 175 127 # $1: options how to print data 176 128 # $2: default width to print data 177 # $3: initial cell178 # $4: blockheight offset179 129 # 180 130 # Global variables used: 181 131 # alg* algorithm information, 182 # PreCharWidth183 132 # 184 133 #}}} … … 193 142 options="${options//[0-9]/}" 194 143 195 typeset -i \ 196 colCharWidth=$colWidth/PreCharWidth+1 \ 197 blockHeight=$4 \ 198 i=0 n=0 199 200 # get correct block height 201 blockHeight=blockHeight+${#options} 202 case "$options" in 203 (*r*) blockHeight=blockHeight+${#algResultTags[@]}-1 ;; 204 esac 205 case "$options" in 206 (*d*) blockHeight=blockHeight+${#algDataTags[@]}-1 ;; 207 esac 208 209 #{{{ print first line 210 # for efficiency, we repeat this case statement to print the first line 211 if [ -n "$options" ]; then 212 case "$options" in 213 (*p*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Char )$( pct "$algChar" "width=$colWidth" )<!eol></tr>" 214 options="${options//p/}" ;; 215 (*s*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Switches )$( pct "$algSwitch" "width=$colWidth" )<!eol></tr>" 216 options="${options//s/}" ;; 217 (*v*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Variables )$( pct "$algVars" "width=$colWidth" )<!eol></tr>" 218 options="${options//v/}" ;; 219 (*n*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Circles )$( pct "$algCircle" "width=$colWidth" )<!eol></tr>" 220 options="${options//n/}" ;; 221 (*g*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Seed )$( pct "$algSeed" "width=$colWidth" )<!eol></tr>" 222 options="${options//g/}" ;; 223 (*f*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Version )$( pct "$algVers" "width=$colWidth" )<!eol></tr>" 224 options="${options//f/}" ;; 225 (*t*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Time )$( pct "$algTime" "width=$colWidth" )<!eol></tr>" 226 options="${options//t/}" ;; 227 (*c*) echo "<tr align=left valign=top>$( pc "$3" "rowspan=$blockHeight" )<!bol>$( pc Check )$( pct "$algCheck" "width=$colWidth" )<!eol></tr>" 228 options="${options//c/}" ;; 229 (*d*|*r*) 230 warn "first line in a table must not start with data or result information" 231 options="" ;; 232 (*) warn "unknown output type specifier '$options' in table specification" 233 options="" ;; 234 esac 235 fi 236 #}}} 237 238 #{{{ print other lines 144 typeset -i i=0 n=0 145 239 146 while [ -n "$options" ]; do 240 147 case "$options" in 241 (*p*) echo " <tr align=left valign=top><!bol>$( pc Char )$( pct "$algChar" )<!eol></tr>"148 (*p*) echo "$algChar" 242 149 options="${options//p/}" ;; 243 (*s*) echo " <tr align=left valign=top><!bol>$( pc Switches )$( pct "$algSwitch" )<!eol></tr>"150 (*s*) echo "$algSwitch" 244 151 options="${options//s/}" ;; 245 (*v*) echo " <tr align=left valign=top><!bol>$( pc Variables )$( pct "$algVars" )<!eol></tr>"152 (*v*) echo "$algVars" 246 153 options="${options//v/}" ;; 247 (*n*) echo " <tr align=left valign=top><!bol>$( pc Circles )$( pct "$algCircle" )<!eol></tr>"154 (*n*) echo "$algCircle" 248 155 options="${options//n/}" ;; 249 (*g*) echo " <tr align=left valign=top><!bol>$( pc Seed )$( pct "$algSeed" )<!eol></tr>"156 (*g*) echo "$algSeed" 250 157 options="${options//g/}" ;; 251 (*f*) echo " <tr align=left valign=top><!bol>$( pc Version )$( pct "$algVers" )<!eol></tr>"158 (*f*) echo "$algVers" 252 159 options="${options//f/}" ;; 253 (*t*) echo " <tr align=left valign=top><!bol>$( pc Time )$( pct "$algTime" )<!eol></tr>"160 (*t*) echo "$algTime" 254 161 options="${options//t/}" ;; 255 (*c*) echo " <tr align=left valign=top><!bol>$( pc Check )$( pct "$algCheck" )<!eol></tr>"162 (*c*) echo "$algCheck" 256 163 options="${options//c/}" ;; 257 (* d*)258 n=${#alg DataTags[@]}164 (*r*) 165 n=${#algResult[@]} 259 166 i=0 260 167 while [ $i -lt $n ]; do 261 cat << EOT 262 <tr align=left valign=top> 263 <!bol> 264 $( pc "${algDataTags[i]}" )<th><pre> 265 EOT 266 echo "${algData[i]}" | fold -s -w$colCharWidth 267 cat << EOT 268 </pre></th> 269 <!eol> 270 </tr> 271 EOT 272 i=i+1 273 done 274 options="${options//d/}" ;; 275 (*r*) 276 n=${#algResultTags[@]} 277 i=0 278 while [ $i -lt $n ]; do 279 cat << EOT 280 <tr align=left valign=top> 281 <!bol> 282 $( pc "${algResultTags[i]}" )<th><pre> 283 EOT 284 echo "${algResult[i]}" | fold -s -w$colCharWidth 285 cat << EOT 286 </pre></th> 287 <!eol> 288 </tr> 289 EOT 168 echo "${algResult[i]}" | fold -s -w$colWidth 290 169 i=i+1 291 170 done … … 295 174 esac 296 175 done 297 #}}}298 176 } 299 177 #}}} … … 325 203 exit 1 326 204 fi 327 #collectionName="$1"205 collectionName="$1" 328 206 shift 329 207 … … 331 209 # read options 332 210 typeset opt 333 while getopts "n:a:c:t: x:r:" opt; do211 while getopts "n:a:c:t:r:" opt; do 334 212 case "$opt" in 335 213 (n) collectionNote="${collectionNote:-$OPTARG}" ;; … … 337 215 (c) collectionOptions="$collectionOptions -c$OPTARG" ;; 338 216 (t) collectionTBOptions="${collectionTBOptions:-$OPTARG}" ;; 339 (x) collectionXOOptions="${collectionXOOptions:-$OPTARG}" ;;340 217 (r) collectionROOptions="${collectionROOptions:-$OPTARG}" ;; 341 218 (?) warn "bad collection option"; exit 1 ;; … … 354 231 done 355 232 #}}} 356 }357 #}}}358 359 #{{{ createTable ()360 #{{{ docu361 #362 # createTable() - create html file from output data.363 #364 # $1: runName365 #366 # Global variables used:367 # collectionName, collectionNote368 #369 #}}}370 createTable()371 {372 typeset runName="$1"373 374 # write header375 cat << EOT376 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">377 <! Generated by runfex>378 <html>379 <head>380 <title>Results from running $collectionName</title>381 <meta name="Author" content="Jens Schmidt">382 </head>383 <! this corresponds to burlywood1>384 <body bgcolor="#fcce8e">385 EOT386 387 388 # example table389 cat << EOT390 <h2>Examples and Runs</h2>391 <table border=1 cellpadding=5 cellspacing=1>392 <tr align=left valign=top>$( pc "Coll. Name" )$( pct "$collectionName" colspan=2 )</tr>393 <tr align=left valign=top>$( pc "Coll. Note" )$( pct "${collectionNote:-(no note)}" colspan=2 )</tr>394 <!TB>395 <tr align=left valign=top><!bol>$( pc "" )$( pc "<a name=\"TB$runName\" href=\"#RO$runName\">$runName</a>" "colspan=2")<!eol></tr>396 EOT397 cat "$runName.tb.tbl"398 399 cat << EOT400 <!/TB>401 </table>402 EOT403 404 # example overview405 cat << EOT406 <h2>Overview over Examples</h2>407 <table border=1 cellpadding=5 cellspacing=1>408 <tr align=left valign=top>$( pc "Coll. Name" )$( pct "$collectionName" colspan=2 )</tr>409 <tr align=left valign=top>$( pc "Coll. Note" )$( pct "${collectionNote:-(no note)}" colspan=2 )</tr>410 <tr align=left valign=top>$( pc "Examples" )$( pc "Data" colspan=2 )</tr>411 <!XO>412 EOT413 cat "$runName.xo.tbl"414 415 cat << EOT416 <!/XO>417 </table>418 EOT419 420 421 # run overview422 cat << EOT423 <h2>Overview over Runs</h2>424 <table border=1 cellpadding=5 cellspacing=1>425 <tr align=left valign=top>$( pc "Coll. Name" )$( pct "$collectionName" colspan=2 )</tr>426 <tr align=left valign=top>$( pc "Coll. Note" )$( pct "${collectionNote:-(no note)}" colspan=2 )</tr>427 <tr align=left valign=top>$( pc "Runs" )$( pc "Data" colspan=2 )</tr>428 <!RO>429 EOT430 cat "$runName.ro.tbl"431 432 cat << EOT433 <!/RO>434 </table>435 EOT436 437 438 # write footer439 cat << EOT440 </body>441 </html>442 EOT443 233 } 444 234 #}}} … … 517 307 # 518 308 # Global variables used: 519 # runName,debugMode,520 # runTBOptions, runXOOptions,521 # collectionTBOptions, collectionXOOptions,522 # TBColWidth , XOColWidth309 # debugMode, 310 # runTBOptions, 311 # collectionTBOptions, 312 # TBColWidth 523 313 # 524 314 #}}} … … 529 319 exampleOptions="" \ 530 320 exampleEnvironment="" \ 531 exampleTBOptions="" \ 532 exampleXOOptions="" 321 exampleTBOptions="" 533 322 534 323 typeset algorithm="" \ 535 algorithmTBOptions="" \ 536 algorithmXOOptions="" 324 algorithmTBOptions="" 537 325 538 326 #{{{ read example name and skip it if necessary … … 565 353 (c) exampleOptions="$exampleOptions -c$OPTARG" ;; 566 354 (t) exampleTBOptions="$OPTARG" ;; 567 (x) exampleXOOptions="$OPTARG" ;;568 355 (?) warn "bad example option"; exit 1 ;; 569 356 esac … … 599 386 # collect output options 600 387 algorithmTBOptions="${runTBOptions:-${exampleTBOptions:-$collectionTBOptions}}" 601 algorithmXOOptions="${runXOOptions:-${exampleXOOptions:-$collectionXOOptions}}"602 388 603 389 #{{{ read and print data … … 611 397 algCheck 612 398 613 typeset -a algData \ 614 algResult \ 615 algDataTags \ 616 algResultTags 617 618 typeset -i i=0 j=0 399 typeset -a algResult 400 401 typeset -i j=0 619 402 620 403 # read data 621 runAlgorithm "$algorithm" -oa s"$@" \404 runAlgorithm "$algorithm" -oa "$@" \ 622 405 | { 623 406 read algChar … … 632 415 # preprocess output and store result in the arrays 633 416 while read line; do 634 case "$line" in 635 (@@!*) 636 # read data lines 637 algDataTags[i]="${line#@@!}" 638 read line 639 algData[i]="$line" 640 while read line && test "$line" != "@@"; do 641 algData[i]="${algData[i]} 642 $line" 643 done 644 i=i+1 ;; 645 (@!*) 646 # read one data line 647 algDataTags[i]="${line#@!}" 648 algDataTags[i]="${algDataTags[i]%%:*}" 649 algData[i]="${line#*: }" 650 i=i+1 ;; 651 (@@*) 652 # read result lines 653 algResultTags[j]="${line#@@}" 654 read line 655 algResult[j]="$line" 656 while read line && test "$line" != "@@"; do 657 algResult[j]="${algResult[j]} 658 $line" 659 done 660 j=j+1 ;; 661 (@*) 662 # read one result line 663 algResultTags[j]="${line#@}" 664 algResultTags[j]="${algResultTags[j]%%:*}" 665 algResult[j]="${line#*: }" 666 j=j+1 ;; 667 esac 417 algResult[j]="$line" 418 j=j+1 668 419 done 669 420 670 #{{{ print table671 # print header672 cat << EOT >> "$runName.tb.tbl"673 <!TBBlock $exampleName>674 EOT675 676 421 # print table 677 printData "$algorithmTBOptions" "$TBColWidth" \ 678 "<a name=\"TB$exampleName\" href=\"#XO$exampleName\">$exampleName</a>" 0 >> "$runName.tb.tbl" 679 680 # print trailer 681 cat << EOT >> "$runName.tb.tbl" 682 <!/TBBlock $exampleName> 683 EOT 684 #}}} 685 686 #{{{ print example overview 687 # print header 688 cat << EOT >> "$runName.xo.tbl" 689 <!XOBlockX $exampleName> 690 <tr align=left valign=top>$( pc "<a name=\"XO$exampleName\" href=\"#TB$exampleName\">$exampleName</a>" )$( pc "Ex. Note" )$( pct "${exampleNote:-(no note)}" )</tr> 691 <!XOBlockR $runName> 692 EOT 693 694 # print data 695 printData "$algorithmXOOptions" "$XOColWidth" \ 696 "<a href=\"#RO$runName\">$runName</a>" 0 >> "$runName.xo.tbl" 697 698 # print trailer 699 cat << EOT >> "$runName.xo.tbl" 700 <!/XOBlockR $runName> 701 <!/XOBlockX $exampleName> 702 EOT 703 #}}} 422 printData "$algorithmTBOptions" "$TBColWidth" 704 423 } 705 424 #}}} … … 717 436 # 718 437 # Global variables used: 719 # runName, collectionName,720 438 # collectionROOptions, 721 439 # debugMode, … … 730 448 # read options 731 449 typeset opt 732 while getopts "n:a:c:t: x:r:d" opt; do450 while getopts "n:a:c:t:r:d" opt; do 733 451 case "$opt" in 734 452 (n) runNote="$OPTARG" ;; … … 736 454 (c) runOptions="$runOptions -c$OPTARG" ;; 737 455 (t) runTBOptions="$OPTARG" ;; 738 (x) runXOOptions="$OPTARG" ;;739 456 (r) runROOptions="$OPTARG" ;; 740 457 (d) debugMode="1" ;; … … 755 472 #}}} 756 473 757 #{{{ read rest of arguments758 474 # process rest of arguments 759 475 if [ "$#" = "0" ]; then … … 762 478 fi 763 479 rawCollectionName="${1%.fex}" 764 collectionName="${rawCollectionName##*/}"765 480 shift 766 481 767 if [ "$#" = "0" ]; then768 warn "no run name specified"769 exit 1770 fi771 runName="${1%.html}"772 shift773 774 482 defineSkip "$@" 775 #}}}776 483 777 484 # before going on, check for existence of collection … … 781 488 fi 782 489 783 # remove existing table files784 if [ -z "$debugMode" ]; then785 rm -f "$runName.tb.tbl"786 rm -f "$runName.xo.tbl"787 rm -f "$runName.ro.tbl"788 rm -f "$runName.html"789 fi790 791 490 # execute collection 792 491 . "$rawCollectionName.fex" 793 492 794 493 if [ -z "$debugMode" ]; then 795 #{{{ read and print data796 494 typeset algChar 797 495 typeset algSwitch … … 802 500 803 501 # read data 804 runAlgorithm "$EvalAlg" -oe s\502 runAlgorithm "$EvalAlg" -oe \ 805 503 | { 806 504 read algChar … … 811 509 read algVers 812 510 813 # create empty file814 cp /dev/null "$runName.ro.tbl"815 816 # print header817 cat << EOT >> "$runName.ro.tbl"818 <!ROBlock $runName>819 EOT820 821 511 # print data 822 512 typeset options="${runROOptions:-$collectionROOptions}" … … 824 514 options="${options//tcrd/}" 825 515 826 printData "$options" "$ROColWidth" \ 827 "<a name=\"RO$runName\" href=\"#TB$runName\">$runName</a>" 4 >> "$runName.ro.tbl" 828 829 # print trailer 830 cat << EOT >> "$runName.ro.tbl" 831 <tr align=left valign=top><!bol>$( pc Note )$( pct "${runNote:-(no note)}" )<!eol></tr> 832 <tr align=left valign=top><!bol>$( pc Date )$( pct "$( date )" )<!eol></tr> 833 <tr align=left valign=top><!bol>$( pc User )$( pct "${USER:-unknown}" )<!eol></tr> 834 <tr align=left valign=top><!bol>$( pc Computer )$( pct "$( uname -a )" )<!eol></tr> 835 <!/ROBlock $runName> 836 EOT 516 printData "$options" "$ROColWidth" 837 517 } 838 #}}}839 840 createTable "$runName" > "$runName.html"841 518 fi 842 519 #}}}
Note: See TracChangeset
for help on using the changeset viewer.