#! /pkg/gnu/bin/gawk -f BEGIN { print "Content-type: text/html\n" FS = " +" while (getline < "math" > 0) { name = $1 $1 = "" gsub(/&/,"\\\\&") macro[name] = substr($0,2) } fname = ENVIRON["QUERY_STRING"] if (!fname) print "Call this program e.g., show.cgi?test" while (getline < fname > 0) { if (strip(tolower($0)) == "") storingmacros = 0 if (storingmacros) { name = $1 $1 = "" gsub(/&/,"\\\\&") macro[name] = substr($0,2) continue } if (strip(tolower($0)) == "") storingmacros = 1 for (i in macro) if (i) gsub(i,macro[i]) # gsub(/[a-zA-Z][\-a-z0-9A-Z]*.gif/,"") while (match($0,/ [a-zA-Z][\-a-z0-9A-Z]*.gif /)) { $0 = substr($0,1,RSTART-1) "" substr($0,RSTART+RLENGTH) } while (match($0,/[a-zA-Z][\-a-z0-9A-Z]*.gif /)) { $0 = substr($0,1,RSTART-1) "" substr($0,RSTART+RLENGTH) } while (match($0,/ [a-zA-Z][\-a-z0-9A-Z]*.gif/)) { $0 = substr($0,1,RSTART-1) "" substr($0,RSTART+RLENGTH) } while (match($0,/[a-zA-Z][\-a-z0-9A-Z]*.gif/)) { $0 = substr($0,1,RSTART-1) "" substr($0,RSTART+RLENGTH) } gsub(/\.GIF/,".gif",$0) gsub(/\^\^\^/,"") gsub(/\^\^/,"") gsub(/\_\_\_/,"") gsub(/\_\_/,"") while (match($0,/\^[0-9a-zA-Z]+/)) { pre = substr($0,1,RSTART-1) mid = substr($0,RSTART+1,RLENGTH-1) post = substr($0,RSTART+RLENGTH) $0 = pre"" $0 = $0 mid $0 = $0 "" post } while (match($0,/\_[0-9a-zA-Z]+/)) { pre = substr($0,1,RSTART-1) mid = substr($0,RSTART+1,RLENGTH-1) post = substr($0,RSTART+RLENGTH) $0 = pre"" $0 = $0 mid $0 = $0 "" post } gsub(" underscore.sym ","_") gsub(" carat.sym ","^") opened = gsub(//,"&") if (opened > closed) { printf $0 for (i=1; i<=opened-closed; i++) printf "" print "" } else print } } func strip(x) { gsub(/[ ]*/,"",x) return x } func upsuff(x) { gsub(/\.gif/,".GIF",x) return x }