category
sort -k2 |
$AWK -F' ' '
BEGIN {
ChangeText ["new"] = "${NEWTAG}"
ChangeText ["update"] = "${UPDATETAG}"
NewFiles = "'"$NewFiles"'"
# Input example:
# test.sh update 2000-02-02 1.2
# testing new 2000-02-02 1.2
while ( getline < NewFiles ) {
IsNewFile [$1] = $2
}
close (NewFiles)
}
{
filename = $1
description = $2
categories = $3
haschanged = ChangeText [IsNewFile [filename]]
if ( filename ~ /\// ) {
for ( i=length (filename); i>0; --i ) {
if ( substr (filename, i, 1) == "/" ) break
}
if ( i > 0 ) {
dirname = substr (filename, 1, i-1) "/"
basename = substr (filename, i+1, length (filename) - i)
} else {
dirname = ""
basename = filename
}
}
# The description has the format
# name - descriptive text [...]
n = split (description, d, "[ ]")
cmdname = ""
for ( i=1; i<=n; i++ ) {
if ( d [i] == "-" ) {
++i; break
}
if ( i>1 ) cmdname = cmdname " "
cmdname = cmdname "" d [i]
}
descr = ""
for ( j=i; j<=n; j++ ) {
if ( j > i ) descr = descr " "
descr = descr d [j]
}
if ( basename "" != cmdname &&
length (basename) >= length (cmdname) ) {
print "WARNING: file " filename " is called " cmdname | "cat >&2"
}
# We should take "basename" instead of "cmdname", but
# with DOS the name would be truncated to 8 characters
fileurl = dirname "" cmdname
if ( fileurl == "" ) fileurl = " "
if ( descr == "" ) descr = " "
url [cmdname] = fileurl
ChangeNote [cmdname] = haschanged
descriptions [cmdname] = descr
# "category" may contain more than one category,
# separated by ";" or ","
n = split (categories, c, "[,;]")
for ( i=1; i<=n; i++ ) {
category = c [i]
if ( category == "" ) continue
# Remove leading and trailing whitespace
gsub (/^[ ]*/, "", category)
gsub (/[ ]*$/, "", category)
# Substitute blanks with "non breaking spaces"
gsub (/[ ][ ]*/, "\\ ", category)
if ( cmds [category] != "" )
cmds [category] = cmds [category] " "
cmds [category] = cmds [category] "" cmdname
}
}
END {
# Now write the HTML output.
# We will take care to write the tables in a way
# that older browsers may display the result, too.
# Copy all category texts to the vector categ[]. This
# way we can sort the vectory on the category name.
ncat = 0
for ( category in cmds ) {
categ [++ncat] = category
}
# Sort categories in categ[] using "Insertion Sort"
for ( i=1; i<=ncat; i++ ) {
smallest = i;
for ( j=i+1; j<=ncat; j++ ) {
if ( categ [j] < categ [smallest] )
smallest = j; # find position of smallest element
}
tmp = categ [i]
categ [i] = categ [smallest]
categ [smallest] = tmp
}
# At first print a list of links to directly jump to a category
print ""
print "[
"
for ( i=1; i<=ncat; i++ ) {
category = categ [i]
L = "" category ""
if ( i < ncat ) L = L " | "
print L
}
print " ]"
print "
\n"
# Now write all categories, using a table for the
# commands contained within.
for ( i=1; i<=ncat; i++ ) {
category = categ [i]
n = split (cmds [category], c, "[ ]")
# c[1..n] contains the command names
print "${SSH}${SFIXEDFONT}" category "${EFIXEDFONT}${ESH}
"
#L = ""
#L = L "Top"
#print L
print ""
for ( j=1; j<=n; j++ ) {
cmd = c [j]
viewurl = url [cmd] ".txt"
L = " "
L = L ChangeNote [cmd]
L = L "" cmd " | "
L = L " D | "
L = L " " descriptions [cmd]
# Special handling: terminate line for older browsers
L = L "
|
"
print L
}
print "
\n"
}
print "This table was generated ${DATE} using the script \"'"$PN"'\"
"
}
'