Changeset a292a29 in git for factory


Ignore:
Timestamp:
Jan 30, 1998, 3:12:57 PM (26 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
Children:
9dac21e20830c8d04a26496a2d4e9328a8770887
Parents:
90dd8df690c3da99f0983c5c64be68efe15586bc
Message:
	* runfex: totally rewritten.  Does not print html-code any longer,
	  only ASCII-information.


git-svn-id: file:///usr/local/Singular/svn/trunk@1110 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/fex/runfex

    r90dd8df ra292a29  
    1 #! /mnt/amd/users/urmel/insider/schmidt/bin/bash
    2 # $Id: runfex,v 1.2 1997-10-28 17:18:36 schmidt Exp $
     1#! /home/schmidt/bin/bash
     2# $Id: runfex,v 1.3 1998-01-30 14:12:57 schmidt Exp $
    33
    44#{{{ docu
     
    1919# XXColWidth: default width for data columns.  Used by main() and
    2020#   example().
    21 # PreCharWidth: width of one preformatted character in pixels.
    22 #   Used by printData().
    2321# EvalAlg: algorithm to read run/collection data from.  Used by
    2422#   main().
     
    2725readonly ExecName="$0"
    2826
    29 typeset -ir TBColWidth=300
    30 typeset -ir XOColWidth=400
    31 typeset -ir ROColWidth=400
    32 
    33 typeset -ir PreCharWidth=6
     27typeset -ir TBColWidth=80
     28typeset -ir ROColWidth=80
    3429
    3530readonly EvalAlg="feval"
     
    4136# - global variables.
    4237#
    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().
    4638# runOptions, collectionOptions, runEnvironment,
    4739# collectionEnvironment: options and environment for the
     
    4941# collectionROOptions: options to print run overview.  Use by
    5042#   main().
    51 # runXXOptions, collectionXXOptions: options to print XX tables.
     43# runTBOptions, collectionTBOptions: options to print XX tables.
    5244#   Used by example().
    5345# debugMode: do not execute anything, just print what we would
     
    5547#   runAlgorithm().
    5648#
    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#}}}
    6353runOptions=""
    6454runEnvironment=""
    6555runTBOptions=""
    66 runXOOptions=""
    67 
    68 collectionName=""
    69 collectionNote=""
     56
    7057collectionOptions=""
    7158collectionEnvironment=""
    7259collectionTBOptions=""
    73 collectionXOOptions=""
    7460collectionROOptions=""
    7561
     
    9379{
    9480    echo "$ExecName:" "${@-}" >&2
    95 }
    96 #}}}
    97 
    98 #{{{ pc ()
    99 #{{{ docu
    100 #
    101 # pc() - print html table cell.
    102 #
    103 # $1: cell contents
    104 # $2: cell format information
    105 #
    106 # Global variables used: none
    107 #
    108 #}}}
    109 pc()
    110 {
    111     echo "<th ${2-}><font size=+1>$1</font></th>"
    112 }
    113 #}}}
    114 
    115 #{{{ pct ()
    116 #{{{ docu
    117 #
    118 # pc() - print html table cell in type writer style.
    119 #
    120 # $1: cell contents
    121 # $2: cell format information
    122 #
    123 # Global variables used: none
    124 #
    125 #}}}
    126 pct()
    127 {
    128     echo "<th valign=center ${2-}><tt><font size=+2>$1</font></tt></th>"
    12981}
    13082#}}}
     
    175127# $1: options how to print data
    176128# $2: default width to print data
    177 # $3: initial cell
    178 # $4: blockheight offset
    179129#
    180130# Global variables used:
    181131#   alg* algorithm information,
    182 #   PreCharWidth
    183132#
    184133#}}}
     
    193142    options="${options//[0-9]/}"
    194143
    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
    239146    while [ -n "$options" ]; do
    240147        case "$options" in
    241             (*p*) echo "<tr align=left valign=top><!bol>$( pc Char )$( pct "$algChar" )<!eol></tr>"
     148            (*p*) echo "$algChar"
    242149                 options="${options//p/}" ;;
    243             (*s*) echo "<tr align=left valign=top><!bol>$( pc Switches )$( pct "$algSwitch" )<!eol></tr>"
     150            (*s*) echo "$algSwitch"
    244151                 options="${options//s/}" ;;
    245             (*v*) echo "<tr align=left valign=top><!bol>$( pc Variables )$( pct "$algVars" )<!eol></tr>"
     152            (*v*) echo "$algVars"
    246153                 options="${options//v/}" ;;
    247             (*n*) echo "<tr align=left valign=top><!bol>$( pc Circles )$( pct "$algCircle" )<!eol></tr>"
     154            (*n*) echo "$algCircle"
    248155                 options="${options//n/}" ;;
    249             (*g*) echo "<tr align=left valign=top><!bol>$( pc Seed )$( pct "$algSeed" )<!eol></tr>"
     156            (*g*) echo "$algSeed"
    250157                 options="${options//g/}" ;;
    251             (*f*) echo "<tr align=left valign=top><!bol>$( pc Version )$( pct "$algVers" )<!eol></tr>"
     158            (*f*) echo "$algVers"
    252159                 options="${options//f/}" ;;
    253             (*t*) echo "<tr align=left valign=top><!bol>$( pc Time )$( pct "$algTime" )<!eol></tr>"
     160            (*t*) echo "$algTime"
    254161                 options="${options//t/}" ;;
    255             (*c*) echo "<tr align=left valign=top><!bol>$( pc Check )$( pct "$algCheck" )<!eol></tr>"
     162            (*c*) echo "$algCheck"
    256163                 options="${options//c/}" ;;
    257             (*d*)
    258                 n=${#algDataTags[@]}
     164            (*r*)
     165                n=${#algResult[@]}
    259166                i=0
    260167                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
    290169                    i=i+1
    291170                done
     
    295174        esac
    296175    done
    297     #}}}
    298176}
    299177#}}}
     
    325203        exit 1
    326204    fi
    327     #collectionName="$1"
     205    collectionName="$1"
    328206    shift
    329207
     
    331209    # read options
    332210    typeset opt
    333     while getopts "n:a:c:t:x:r:" opt; do
     211    while getopts "n:a:c:t:r:" opt; do
    334212        case "$opt" in
    335213            (n) collectionNote="${collectionNote:-$OPTARG}" ;;
     
    337215            (c) collectionOptions="$collectionOptions -c$OPTARG" ;;
    338216            (t) collectionTBOptions="${collectionTBOptions:-$OPTARG}" ;;
    339             (x) collectionXOOptions="${collectionXOOptions:-$OPTARG}" ;;
    340217            (r) collectionROOptions="${collectionROOptions:-$OPTARG}" ;;
    341218            (?) warn "bad collection option"; exit 1 ;;
     
    354231    done
    355232    #}}}
    356 }
    357 #}}}
    358 
    359 #{{{ createTable ()
    360 #{{{ docu
    361 #
    362 # createTable() - create html file from output data.
    363 #
    364 # $1: runName
    365 #
    366 # Global variables used:
    367 #   collectionName, collectionNote
    368 #
    369 #}}}
    370 createTable()
    371 {
    372     typeset runName="$1"
    373 
    374     # write header
    375     cat << EOT
    376 <!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 EOT
    386 
    387 
    388     # example table
    389     cat << EOT
    390 <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 EOT
    397     cat  "$runName.tb.tbl"
    398 
    399     cat << EOT
    400 <!/TB>
    401 </table>
    402 EOT
    403 
    404     # example overview
    405     cat << EOT
    406 <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 EOT
    413     cat  "$runName.xo.tbl"
    414 
    415     cat << EOT
    416 <!/XO>
    417 </table>
    418 EOT
    419 
    420 
    421     # run overview
    422     cat << EOT
    423 <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 EOT
    430     cat  "$runName.ro.tbl"
    431 
    432     cat << EOT
    433 <!/RO>
    434 </table>
    435 EOT
    436 
    437 
    438     # write footer
    439     cat << EOT
    440 </body>
    441 </html>
    442 EOT
    443233}
    444234#}}}
     
    517307#
    518308# Global variables used:
    519 #   runName, debugMode,
    520 #   runTBOptions, runXOOptions,
    521 #   collectionTBOptions, collectionXOOptions,
    522 #   TBColWidth, XOColWidth
     309#   debugMode,
     310#   runTBOptions,
     311#   collectionTBOptions,
     312#   TBColWidth
    523313#
    524314#}}}
     
    529319            exampleOptions="" \
    530320            exampleEnvironment="" \
    531             exampleTBOptions="" \
    532             exampleXOOptions=""
     321            exampleTBOptions=""
    533322
    534323    typeset algorithm="" \
    535             algorithmTBOptions="" \
    536             algorithmXOOptions=""
     324            algorithmTBOptions=""
    537325
    538326    #{{{ read example name and skip it if necessary
     
    565353            (c) exampleOptions="$exampleOptions -c$OPTARG" ;;
    566354            (t) exampleTBOptions="$OPTARG" ;;
    567             (x) exampleXOOptions="$OPTARG" ;;
    568355            (?) warn "bad example option"; exit 1 ;;
    569356        esac
     
    599386    # collect output options
    600387    algorithmTBOptions="${runTBOptions:-${exampleTBOptions:-$collectionTBOptions}}"
    601     algorithmXOOptions="${runXOOptions:-${exampleXOOptions:-$collectionXOOptions}}"
    602388
    603389    #{{{ read and print data
     
    611397            algCheck
    612398   
    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
    619402
    620403    # read data
    621     runAlgorithm "$algorithm" -oas "$@" \
     404    runAlgorithm "$algorithm" -oa "$@" \
    622405        | {
    623406        read algChar
     
    632415        # preprocess output and store result in the arrays
    633416        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
    668419        done
    669420
    670         #{{{ print table
    671         # print header
    672         cat << EOT >> "$runName.tb.tbl"
    673 <!TBBlock $exampleName>
    674 EOT
    675        
    676421        # 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"
    704423    }
    705424    #}}}
     
    717436#
    718437# Global variables used:
    719 #   runName, collectionName,
    720438#   collectionROOptions,
    721439#   debugMode,
     
    730448# read options
    731449typeset opt
    732 while getopts "n:a:c:t:x:r:d" opt; do
     450while getopts "n:a:c:t:r:d" opt; do
    733451    case "$opt" in
    734452        (n)  runNote="$OPTARG" ;;
     
    736454        (c)  runOptions="$runOptions -c$OPTARG" ;;
    737455        (t)  runTBOptions="$OPTARG" ;;
    738         (x)  runXOOptions="$OPTARG" ;;
    739456        (r)  runROOptions="$OPTARG" ;;
    740457        (d)  debugMode="1" ;;
     
    755472#}}}
    756473
    757 #{{{ read rest of arguments
    758474# process rest of arguments
    759475if [ "$#" = "0" ]; then
     
    762478fi
    763479rawCollectionName="${1%.fex}"
    764 collectionName="${rawCollectionName##*/}"
    765480shift
    766481
    767 if [ "$#" = "0" ]; then
    768     warn "no run name specified"
    769     exit 1
    770 fi
    771 runName="${1%.html}"
    772 shift
    773 
    774482defineSkip "$@"
    775 #}}}
    776483
    777484# before going on, check for existence of collection
     
    781488fi
    782489
    783 # remove existing table files
    784 if [ -z "$debugMode" ]; then
    785     rm -f "$runName.tb.tbl"
    786     rm -f "$runName.xo.tbl"
    787     rm -f "$runName.ro.tbl"
    788     rm -f "$runName.html"
    789 fi
    790 
    791490# execute collection
    792491. "$rawCollectionName.fex"
    793492
    794493if [ -z "$debugMode" ]; then
    795     #{{{ read and print data
    796494    typeset algChar
    797495    typeset algSwitch
     
    802500
    803501    # read data
    804     runAlgorithm "$EvalAlg" -oes \
     502    runAlgorithm "$EvalAlg" -oe \
    805503        | {
    806504        read algChar
     
    811509        read algVers
    812510
    813         # create empty file
    814         cp /dev/null "$runName.ro.tbl"
    815 
    816         # print header
    817         cat << EOT >> "$runName.ro.tbl"
    818 <!ROBlock $runName>
    819 EOT
    820 
    821511        # print data
    822512        typeset options="${runROOptions:-$collectionROOptions}"
     
    824514        options="${options//tcrd/}"
    825515
    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"
    837517    }
    838     #}}}
    839 
    840     createTable "$runName" > "$runName.html"
    841518fi
    842519#}}}
Note: See TracChangeset for help on using the changeset viewer.