diff --git a/en/gallery/gengallery.pl b/en/gallery/gengallery.pl
index 68f226b4ce..c5a38a78dd 100755
--- a/en/gallery/gengallery.pl
+++ b/en/gallery/gengallery.pl
@@ -1,70 +1,82 @@
#!/usr/local/bin/perl
#
# gengallery.pl - script to convert tab-delimited gallery db file to
# a section of an SGML list (not a full SGML file!) for inclusion
# into another SGML file where the
list element pair is
# already in existence.
#
-# Syntax: dump.pl type < galleryfile.db > galleryfile.inc
+# Syntax: gengallery.pl type < galleryfile.db > galleryfile.inc
# where type is one of: commerical, nonprofit, personal
#
# yymmdd own comments
# ------ --- ------------------------------------------------
# 980311 nsj First pass
# 980312 jrf Added sorting
# 980313 nsj Wrapped file input routine with error checking
+# 981229 nsj Tried to be more intelligent in eliminating any
+# possible blank entries in the .db file and
+# malformed url entries (missing http://).
# Setup
# Which sort program are we using?
$sort = "/usr/bin/sort";
# What gallery are we processing?
$type = $ARGV[0];
if ($type =~ m/commercial/i) {
$type = "commercial";
} elsif ($type =~ m/nonprofit/i) {
$type = "nonprofit";
} elsif ($type =~ m/personal/i) {
$type = "personal";
} else {
die "I don't understand type $type";
}
# Open a pipe from a unix sort of the db file (case insensitive)
if (-f $ARGV[1])
{
$infile = $ARGV[1];
} else {
die "File $ARGV[1] is unreadable or does not exist";
}
# Open the (sorted) file
open(DBFILE, "$sort -f $infile |");
# Iterate through each line, throwing out those that don't
# go in this gallery. Output each entry as list elements.
while ()
{
# We only want entries of type $type; throw the rest out.
next unless m/^$type/;
# Translate out characters special to SGML (and HTML)
s/&/&/g;
s/</g;
# Split the db line into its component parts.
($dummy, $name, $url, $description, $email, $dateadd, $datever) =
m/([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]*)\t([^\t]+)\t([^\t]+)\t([^\t]+)/;
+ # Skip bogus entries (in lieu of actually checking to
+ # eliminate them from the .db file.)
+ next if ($name =~ m/^$|^\s+$/);
+ next if ($url =~ m/^$|^\s+$|^http:\/\/\s+$/);
+
+ # Be semi-intelligent about entries without "http://" in front
+ # by prepending that to any that are missing it.
+ $url = "http://" . $url unless ($url =~ m/^http:\/\/.*$/);
+
# Dump it out to the file, in SGML format
if ($description ne "")
{
print "$name -- $description\n";
} else {
print "$name\n";
};
};
# Close the pipe like good little daemons.
close(DBFILE);