#! /bin/csh -f # Last edited on 1999-01-06 08:35:28 by stolfi set usage = "$0 [ -title TITLE ] [ -prev NUM ] [ -next NUM ] [ -lengths LFT STR RHT ] < INFILE.hoc > OUTFILE.html" # Each line of INFILE represents one occurrence of some string # in the text, in the format # # LOC TRANS START LENGTH LCTX STRING RCTX PATT STAG PNUM HNUM # 1 2 3 4 5 6 7 8 9 10 11 # # See Note-037.txt for explanation of the fields. set title = "Concordance" set maxlft = 30 set maxstr = 20 set maxrht = 30 set prev = "" set next = "" while ( ( $#argv >= 1) && ( "x$1" =~ x-* ) ) if ( ( $#argv >= 2) && ( "x$1" == "x-title" ) ) then set title = "$2"; shift; shift; else if ( ( $#argv >= 4) && ( "x$1" == "x-lengths" ) ) then set maxlft = "$2"; set maxstr = "$3"; set maxrht = "$4"; shift; shift; shift; shift; else if ( ( $#argv >= 2) && ( "x$1" == "x-prev" ) ) then set prev = "$2"; shift; shift; else if ( ( $#argv >= 2) && ( "x$1" == "x-next" ) ) then set next = "$2"; shift; shift; else echo "bad option $1"; echo "usage: ${usage}"; exit 1 endif end # Prepare the motion buttons: if ( "x$prev" != "x" ) then set prevbt = '[PREV] ' else set prevbt = '[ ] ' endif set indexbt = '[INDEX] ' if ( "x$next" != "x" ) then set nextbt = '[NEXT] ' else set nextbt = '[ ] ' endif # Output the HTML file: cat < ${title}

${title}

${prevbt} ${indexbt} ${nextbt} EOF gawk \ -v maxlft=${maxlft} \ -v maxstr=${maxstr} \ -v maxrht=${maxrht} \ ' BEGIN { ppat = " @@@ "; \ dashes = "-------------------------------------------------------------"; \ } \ /./ { \ loc = $1; tran = $2; \ lft = $5; str = $6; rht = $7; \ pat = $8; sec = $9; \ if (pat != ppat) { \ printf "\n%.*s %s %.*s\n\n", \ pat, \ 21+maxlft-1, dashes, \ pat, \ 80-(21+maxlft-1)-length(pat)-1, dashes; \ ppat = pat; \ } \ gsub(/[.]/, " ", lft); gsub(/[.]/, " ", str); gsub(/[.]/, " ", rht); \ str = ("" str ""); \ n = length(lft); if (n > maxlft) { lft = substr(lft, 1+n-maxlft); } \ printf "%3s %s %*s%-s\n", \ sec, loc, maxlft, lft, (str rht); \ } \ ' cat < ${prevbt} ${indexbt} ${nextbt}
EOF