Fix an embarassing off-by-one bug that prevented "Also listed in"

cross references from being generated for ports with exactly two
categories.

Added a couple comments and changed the output format slightly.
This commit is contained in:
John Fieber 1997-02-04 15:17:47 +00:00
parent 4484dc9f35
commit d9673d368a
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=1120
2 changed files with 32 additions and 38 deletions

View file

@ -44,61 +44,58 @@ sub footer {
sub main {
$sep = "<B>:</B>";
while (<>) {
chop;
s/&/&amp;/g;
s/</&lt;/g;
s/>/&gt;/g;
# Read a record
($name, $loc, $prefix, $desc, $ldesc, $owner, $cats,
$keys, $bdep, $rdep) = split('\|');
@cat = split(" ", $cats);
# Split the categories into an array
@cat = split("[ \t]+", $cats);
$catkey{$name} = $cat[0];
$sep = "<B>:</B>";
foreach $i (@cat) {
$stats{$i}++;
# figure out the FTP url
$loc =~ s/\/usr/$base/;
# $loc =~ s/\/$name$//;
$ldesc =~ s/\/usr/$base/;
# The name description and maintainer
$data{$i} .= "<DT><B><A NAME=\"$name\">$name</A></B> <DD>$desc<BR>";
$data{$i} .= "<DT><B><A NAME=\"$name\"></A><A HREF=\"$loc.tar.gz\">$name</A></B> ";
$data{$i} .= "<DD>$desc<BR><I><A HREF=\"$ldesc\">Long description</A></I>";
$ownerurl = $owner;
$ownerurl =~ s/&lt;/</g;
$owenrurl =~ s/&gt;/>/g;
$data{$i} .=
"<I>Maintained by:</I> <A HREF=\"mailto:$ownerurl\">$owner</A><BR>";
"<BR><I>Maintained by:</I> <A HREF=\"mailto:$ownerurl\">$owner</A>";
# If there are any dependencies, list them
if ($bdep ne "" || $rdep ne "") {
$data{$i} .= "<I>Requires:</I> ";
$data{$i} .= "<BR><I>Requires:</I> ";
@dep = split(/ /, "$bdep $rdep");
foreach $j (@dep) {
$data{$i} .= " <A HREF=\"##$j##.html#$j\">$j</A>,";
}
# remove the trailing comma
chop $data{$i};
$data{$i} .= "<BR>";
}
# Links for browsing and downloading
$data{$i} .= "<A HREF=\"$ldesc\">Description</A> $sep ";
$data{$i} .= "<A HREF=\"$loc\">Browse</A> $sep ";
$data{$i} .= "<A HREF=\"$loc.tar.gz\">Download</A>";
# If the port is listed in more than one category, throw
# in some cross references
if ($#cat > 1) {
if ($#cat > 0) {
$data{$i} .= "<BR><EM>Also listed in:</EM> ";
foreach $j (@cat) {
if ($j ne $i) {
$data{$i} .= " <A HREF=\"$j.html\">\u$j</A>,";
$data{$i} .= " <A HREF=\"$j.html#$name\">\u$j</A>,";
}
}
# remove the trailing comma
@ -119,9 +116,9 @@ sub main {
&header(MOUTF, "FreeBSD Ports");
# print MOUTF "<!--#include virtual=\"./ports.inc\" -->\n";
print MOUTF "&blurb;";
print MOUTF "<hr><P>There are currently $portnumber ports is the
print MOUTF "<hr noshade><P>There are currently $portnumber ports is the
FreeBSD Ports Collection.<br> <A HREF=\"$base/ports.tar.gz\">Download
a gzip'd tar file of all $portnumber ports</A> (about 2 megabytes) or
a gzip'd tar file of all $portnumber ports</A> (about 3 megabytes) or
browse the following categories:\n";
print MOUTF "<UL>\n";
@ -140,7 +137,7 @@ browse the following categories:\n";
$d =~ s/##([^#]*)##/$catkey{$1}/g;
print OUTF $d;
print OUTF "</DL>\n";
&footer(OUTF, "<HR><A HREF=\"index.html\">Port Categories</A>" .
&footer(OUTF, "<HR NOSHADE><A HREF=\"index.html\">Port Categories</A>" .
" -- <A HREF=\"master-index.html\">Index</A>");
close(OUTF);
@ -157,7 +154,7 @@ browse the following categories:\n";
print MINDEX "<P>\n";
print MINDEX sort @master;
print MINDEX "</P>";
&footer(MINDEX, "<HR><A HREF=\"index.html\">Port Categories</A>");
&footer(MINDEX, "<HR NOSHADE><A HREF=\"index.html\">Port Categories</A>");
close(MINDEX);
}

View file

@ -44,61 +44,58 @@ sub footer {
sub main {
$sep = "<B>:</B>";
while (<>) {
chop;
s/&/&amp;/g;
s/</&lt;/g;
s/>/&gt;/g;
# Read a record
($name, $loc, $prefix, $desc, $ldesc, $owner, $cats,
$keys, $bdep, $rdep) = split('\|');
@cat = split(" ", $cats);
# Split the categories into an array
@cat = split("[ \t]+", $cats);
$catkey{$name} = $cat[0];
$sep = "<B>:</B>";
foreach $i (@cat) {
$stats{$i}++;
# figure out the FTP url
$loc =~ s/\/usr/$base/;
# $loc =~ s/\/$name$//;
$ldesc =~ s/\/usr/$base/;
# The name description and maintainer
$data{$i} .= "<DT><B><A NAME=\"$name\">$name</A></B> <DD>$desc<BR>";
$data{$i} .= "<DT><B><A NAME=\"$name\"></A><A HREF=\"$loc.tar.gz\">$name</A></B> ";
$data{$i} .= "<DD>$desc<BR><I><A HREF=\"$ldesc\">Long description</A></I>";
$ownerurl = $owner;
$ownerurl =~ s/&lt;/</g;
$owenrurl =~ s/&gt;/>/g;
$data{$i} .=
"<I>Maintained by:</I> <A HREF=\"mailto:$ownerurl\">$owner</A><BR>";
"<BR><I>Maintained by:</I> <A HREF=\"mailto:$ownerurl\">$owner</A>";
# If there are any dependencies, list them
if ($bdep ne "" || $rdep ne "") {
$data{$i} .= "<I>Requires:</I> ";
$data{$i} .= "<BR><I>Requires:</I> ";
@dep = split(/ /, "$bdep $rdep");
foreach $j (@dep) {
$data{$i} .= " <A HREF=\"##$j##.html#$j\">$j</A>,";
}
# remove the trailing comma
chop $data{$i};
$data{$i} .= "<BR>";
}
# Links for browsing and downloading
$data{$i} .= "<A HREF=\"$ldesc\">Description</A> $sep ";
$data{$i} .= "<A HREF=\"$loc\">Browse</A> $sep ";
$data{$i} .= "<A HREF=\"$loc.tar.gz\">Download</A>";
# If the port is listed in more than one category, throw
# in some cross references
if ($#cat > 1) {
if ($#cat > 0) {
$data{$i} .= "<BR><EM>Also listed in:</EM> ";
foreach $j (@cat) {
if ($j ne $i) {
$data{$i} .= " <A HREF=\"$j.html\">\u$j</A>,";
$data{$i} .= " <A HREF=\"$j.html#$name\">\u$j</A>,";
}
}
# remove the trailing comma
@ -119,9 +116,9 @@ sub main {
&header(MOUTF, "FreeBSD Ports");
# print MOUTF "<!--#include virtual=\"./ports.inc\" -->\n";
print MOUTF "&blurb;";
print MOUTF "<hr><P>There are currently $portnumber ports is the
print MOUTF "<hr noshade><P>There are currently $portnumber ports is the
FreeBSD Ports Collection.<br> <A HREF=\"$base/ports.tar.gz\">Download
a gzip'd tar file of all $portnumber ports</A> (about 2 megabytes) or
a gzip'd tar file of all $portnumber ports</A> (about 3 megabytes) or
browse the following categories:\n";
print MOUTF "<UL>\n";
@ -140,7 +137,7 @@ browse the following categories:\n";
$d =~ s/##([^#]*)##/$catkey{$1}/g;
print OUTF $d;
print OUTF "</DL>\n";
&footer(OUTF, "<HR><A HREF=\"index.html\">Port Categories</A>" .
&footer(OUTF, "<HR NOSHADE><A HREF=\"index.html\">Port Categories</A>" .
" -- <A HREF=\"master-index.html\">Index</A>");
close(OUTF);
@ -157,7 +154,7 @@ browse the following categories:\n";
print MINDEX "<P>\n";
print MINDEX sort @master;
print MINDEX "</P>";
&footer(MINDEX, "<HR><A HREF=\"index.html\">Port Categories</A>");
&footer(MINDEX, "<HR NOSHADE><A HREF=\"index.html\">Port Categories</A>");
close(MINDEX);
}