chiark / gitweb /
Much tidying; preserve query type etc. in query_commod
[ypp-sc-tools.web-live.git] / yarrg / web / qtextstringcheck
index 337ed31f2deb156e831b491f1d6883abda40900a..5ef8971f644b63991af5d6eb5379be7fec1da596 100755 (executable)
@@ -56,11 +56,11 @@ use HTML::Entities;
 use CommodsWeb;
 
 die if $what =~ m/[^a-z]/;
-my $specifics= "check_${what}";
-my $specific= $m->fetch_comp($specifics);
+my $chk= $m->fetch_comp("check_${what}");
 
 my $dbh= dbw_connect($ocean);
-my $sqlstmt= $specific->scall_method("sqlstmt");
+
+my $sqlstmt= $chk->scall_method("sqlstmt");
 my $sth= $dbh->prepare($sqlstmt);
 my @sqlstmt_qs= $sqlstmt =~ m/\?/g;
 
@@ -69,7 +69,9 @@ my @sqlstmt_qs= $sqlstmt =~ m/\?/g;
 my $emsg= '';
 my @results;
 
-my @specs= $specific->attr('multiple') ? (split m#[/|,]#, $string) : ($string);
+my @specs= $chk->attr('multiple') ? (split m#[/|,]#, $string) : ($string);
+
+no warnings qw(exiting);
 
 foreach my $each (@specs) {
        $each =~ s/^\s*//;  $each =~ s/\s*$//;  $each =~ s/\s+/ /g;
@@ -86,12 +88,12 @@ foreach my $each (@specs) {
        }
        if (!$results) {
                if (!%m) {
-                       $err->($specific->scall_method("nomatch",
+                       $err->($chk->scall_method("nomatch",
                                spec => $each));
-               } elsif (keys(%m) > 5) {
-                       $err->(' ');
+               } elsif (keys(%m) > $chk->attr('maxambig')) {
+                       $err->($chk->scall_method("manyambig"));
                } else {
-                       $err->($specific->scall_method("ambiguous",
+                       $err->($chk->scall_method("ambiguous",
                                spec => $each,
                                couldbe => join(', ', sort keys %m)));
                }