X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=yarrg%2Fweb%2Froutetextstring;h=685b465255325fe566c6ed0f5468b51fa492c711;hp=4cec5f9d337b1f994f694857ec528887a5c2828a;hb=4a7daddbd09806e47fc3b6df9cfc42ed5eb84758;hpb=598b6371434047312704df43e69cab629e1f3a3d diff --git a/yarrg/web/routetextstring b/yarrg/web/routetextstring index 4cec5f9..685b465 100644 --- a/yarrg/web/routetextstring +++ b/yarrg/web/routetextstring @@ -31,12 +31,16 @@ if ($format =~ 'json') { success => 1, show => length $canontext ? encode_entities($canontext) : ' ', - })}; + })}; $output_wrong= sub { print to_json({ success => 0, show => $_[0], - })}; -} + })}; +} +if ($format =~ 'return') { + $output= sub { return { Error => '', Results => \@results }; }; + $output_wrong= sub { return { Error => $_[0] }; }; +} foreach my $each (split m#[/|,]#, $string) { $each =~ s/^\s*//; $each =~ s/\s*$//; $each =~ s/\s+/ /g; @@ -57,12 +61,12 @@ foreach my $each (split m#[/|,]#, $string) { } if (!$results) { if (!%m) { - $err->('no island or arch matches "%s"'); + return $err->('no island or arch matches "%s"'); } elsif (%m > 5) { - $err->(' '); + return $err->(' '); } else { - $err->('ambiguous island or arch "%s", could be '. - join(', ', sort keys %m)); + return $err->('ambiguous island or arch "%s",'. + ' could be '.join(', ', sort keys %m)); } } push @results, $results->[0]; @@ -70,6 +74,6 @@ foreach my $each (split m#[/|,]#, $string) { $canontext= join ' | ', map { $_->[2] } @results; -$output->(); +return $output->();