[svn r7957] Added Martin's changes to the do_link_ent function, adding error handling.

This commit is contained in:
aaron
2008-01-18 17:47:58 +01:00
parent 424b3c0deb
commit 14cfa4ef90

View File

@@ -502,39 +502,51 @@ sub parse_csv {
# 2nd arg - the entrance of the cave to which the link goes # 2nd arg - the entrance of the cave to which the link goes
# Returns nothing # Returns nothing
sub do_link_ent { sub do_link_ent {
my $linkfile = $_[0]; my $linkfile = $_[0];
my $linkent = $_[1]; my $linkent = $_[1];
my $linkname = $_[2]; my $linkname = $_[2];
my $storedoffset; my $storedoffset;
$storedoffset = tell(CSV); $storedoffset = tell(CSV);
seek(CSV, 0, 0); seek(CSV, 0, 0);
while (<CSV>) { while (<CSV>) {
chomp; chomp;
if (grep(/,\"$linkfile\",/, $_)) { if ((&parse_csv($_))[5] eq $linkfile) {
if ((&parse_csv($_))[5] eq $linkfile) { if ((&parse_csv($_))[4] eq "yes") {
while ((&parse_csv($_))[2] ne $linkent) {
if ((&parse_csv($_))[4] eq "yes") { $_ = <CSV>;
while ((&parse_csv($_))[2] ne $linkent) { chomp;
$_ = <CSV>; if ((&parse_csv($_))[4] eq
chomp; "last entrance" && (&parse_csv($_))[2] ne $linkent) {
if ((&parse_csv($_))[4] eq "last entrance" && (&parse_csv($_))[2] ne $linkent) { print STDERR "Warning:
print STDERR "Warning: Link entrance for $linkname not found\n\n"; Link entrance for $linkname not found, please specify Link
$warnings = 1; Entrance\n\n";
seek(CSV, $storedoffset, 0); $warnings = 1;
return; seek(CSV, $storedoffset, 0);
} return;
} }
} }
}
my (undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $lent_name, $ltag_punkt, $lother_punkt, $ldesc_other_punkt, $lexact_punkt, $lfix_type, $lgpspresa, $lgpspostsa, $lnorthing, $leasting, $laltitude, undef, undef, undef, undef, undef, undef, $lmarking) = &parse_csv($_);
do_ent($ltag_punkt,$lother_punkt,$lexact_punkt,$lgpspostsa,$lgpspresa,$leasting,$lnorthing,$laltitude,$lent_name,$lfix_type,$ldesc_other_punkt, $lmarking); my (undef, undef, undef, undef, undef, undef,
seek(CSV, $storedoffset, 0); undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
return; undef, undef, undef, undef, undef, undef, undef, undef, undef,
} $lent_name, $ltag_punkt, $lother_punkt, $ldesc_other_punkt,
} $lexact_punkt, $lfix_type, $lgpspresa, $lgpspostsa, $lnorthing,
} $leasting, $laltitude, undef, undef, undef, undef, undef, undef,
$lmarking) = &parse_csv($_);
do_ent($ltag_punkt,$lother_punkt,$lexact_punkt,$lgpspostsa,$lgpspresa,$leasting,$lnorthing,$laltitude,$lent_name,$lfix_type,$ldesc_other_punkt,
$lmarking);
seek(CSV, $storedoffset, 0);
return;
}
}
print STDERR "Warning: Link file for $linkname not found\n\n";
$warnings = 1;
seek(CSV, $storedoffset, 0);
return;
} }
# Process the location data for the entrance # Process the location data for the entrance