chiark / gitweb /
Fix nonunique island/arch name reporting
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Aug 2009 11:15:54 +0000 (12:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Aug 2009 11:15:54 +0000 (12:15 +0100)
yarrg/web/routetextstring

index 70d614483d4efe3de4888af97413388628d2061d..4cec5f9d337b1f994f694857ec528887a5c2828a 100644 (file)
@@ -46,23 +46,23 @@ foreach my $each (split m#[/|,]#, $string) {
                $output_wrong->($msg);
                $m->abort();
        };
                $output_wrong->($msg);
                $m->abort();
        };
-       my @m;
+       my %m;
        my $results;
        foreach my $pat ("$each\%", "\%$each\%") {
                $sth->execute($pat,$pat);
                $results= $sth->fetchall_arrayref();
                last if @$results==1;
        my $results;
        foreach my $pat ("$each\%", "\%$each\%") {
                $sth->execute($pat,$pat);
                $results= $sth->fetchall_arrayref();
                last if @$results==1;
-               push @m, @$results;
+               map { $m{ $_->[2] }=1 } @$results;
                $results= undef;
        }
        if (!$results) {
                $results= undef;
        }
        if (!$results) {
-               if (!@m) {
+               if (!%m) {
                        $err->('no island or arch matches "%s"');
                        $err->('no island or arch matches "%s"');
-               } elsif (@m > 3) {
+               } elsif (%m > 5) {
                        $err->('&nbsp;');
                } else {
                        $err->('ambiguous island or arch "%s", could be '.
                        $err->('&nbsp;');
                } else {
                        $err->('ambiguous island or arch "%s", could be '.
-                               join(', ', map { $_->[2] } @m));
+                               join(', ', sort keys %m));
                }
        }
        push @results, $results->[0];
                }
        }
        push @results, $results->[0];