#! /bin/bash PATH=$PATH:/usr/local/bin; export PATH # For gunzip on church... bin=/home/users/hallgren/cgi AUTOHEADER=no . $bin/cgistart.sh datefmt=${datefmt-"+%b %d"} ### Locations ################################################################## self_url=pfe.cgi #modulesourcefiles=hi/modules # old modulesourcefiles=hi/ModuleSourceFiles.txt # new revgraph=hi/ModuleGraphRev.txt htmldir=hi/html ifacedir=hi/iface ### Functions ################################################################## modulelink() { link "$self_url?$1" "${2-$1}" } plainsrclink() { echo "${2-Plain source file}:" link "$1" "$1" wrap small " (`filedate "$datefmt" "$1"`)" } cvsloglink() { if [ -x cvs.cgi ]; then link "cvs.cgi?$1" "cvs log" fi } optdoclink() { doc="${1%.hs}.doc" if [ -n "$manpage_url" ] && [ -r "$doc" ] ; then sep="
Related manual pages: "
grep '^\$Doc ' <$doc | while read doc manentry rest ; do
echo "$sep"
link "${manpage_url}$manentry.html" "$manentry"
sep=", "
done
fi
}
optifacelink() {
if [ -r "$1" ] ; then
echo_n "$2"
link "$1" "Interface"
echo_n "$3"
if [ -n "$4" ] ; then
wrap small " (`filedate "$datefmt" "$1"`)"
fi
fi
}
generated() {
if [ "$1" = "$3" ] ; then
plainsrclink "$1" "Plain source file for $2"
p
else
wrap code "$1"
echo "is actually generated by $2 from"
wrap code `link "$3" "$3"`
echo "which is shown below."
fi
}
plainfile() {
grep "^$1 " $modulesourcefiles | awk '{print $2}'
}
importedby() {
m="$1"
if [ -r $revgraph ] ; then
grep "^$m " <$revgraph | { read this imports && {
echo "$m is imported"
sep="by:"
for i in $imports ; do
echo "$sep"
modulelink "$i"
sep=","
done
echo "."
p
}
}
else
echo "Don't know who imports this module."
p
fi
}
uptodatecheck() {
gen="$1" # existing generated file
src="$2" # maybe missing source file
if [ -r "$src" ] && [ "$src" -nt "$gen" ] ; then
echo "Warning: the plain source file is newer than the generated HTML version shown below!"
fi
}
showsourcefile() {
m="$1"
hm=`echo "$m" | sed 's%/%-%g'`
h="$htmldir/$hm.html"
hgz="$h.gz"
#pfe all2html "$m" >/dev/null
f=`plainfile "$m"`
d=""
if [ -r "$h" ] || [ -r "$hgz" ] ; then
if [ -r "$f" ] ; then
plainsrclink "$f"
optifacelink "$ifacedir/$hm.hs" "
" " (experimental)" d
optdoclink "$f"
#br;cvsloglink "$f"
p;importedby "$m"
else
echo "The plain source file for module $m is not available."
fi
if [ -r "$h" ] ; then
uptodatecheck "$h" "$f"
cat "$h"
d="`filedate "$datefmt" "$h"`"
elif [ -r "$hgz" ] ; then
uptodatecheck "$hgz" "$f"
gunzip <"$hgz"
d="`filedate "$datefmt" "$hgz"`"
fi
else
echo "The source file for module $m is not available."
fi
hr
link "$self_url" Index
p
[ -n "$d" ] && {
begin small
echo "(HTML for this module was generated on $d."
link "//www.cse.ogi.edu/~hallgren/h2h.html" "About the conversion tool"
echo ".)"
}
}
showsubdirs() {
h2 Subdirectories
begin ol
p="*/"
[ -n "$1" ] && p="$1*/"
for d in $p ; do
li; link "$self_url?$d" $d; nl
done
end
}
adddir() {
while read m d f ; do
[ -n "$f" ] || { f="$d"; d="."; }
echo "$m" "$d" "$f"
done
}
buggymoduleroot() {
if [ -n "$related" ] ; then
echo "$1" | sed "s/\($related\)\$//"
else
echo "$1"
fi
}
moduleroot() {
case "$1" in
*BaseStruct) echo "${1%BaseStruct}" ;;
*RecPretty) echo "${1%RecPretty}" ;;
*Base) echo "${1%Base}" ;;
*Maps) echo "${1%Maps}" ;;
*Pretty) echo "${1%Pretty}" ;;
*Struct) echo "${1%Struct}" ;;
*Util) echo "${1%Util}" ;;
*Rec) echo "${1%Rec}" ;;
*MT) echo "${1%T}" ;;
*) echo "$1"
esac
}
showstructureindex() {
grep " $1" <$modulesourcefiles | sed 's%/\([^/]*\)$% \1%' |
adddir | sort -f -k 2 | {
files=""
d0=""
m0=""
while read m d f; do
h="$htmldir/$m.html"
path="$d/$f"
if [ -r "$path" ] ; then
case "$path" in
hi/libs/*Libraries/*) ;; # exclude Prelude & standard libraries
*) if [ "$d" != "$d0" ] ; then
nl
[ -z "$d0" ] || end
nl
desc=""
if [ -r titles ] ; then
escd=`echo "$d" | sed 's/\./\\\\./g'`
desc="`sed -n "s%^$escd \(.*\)\$%\1%p"