X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fqtextstringcheck;h=686a506aa4c348bfefbc2b0f73fd2e160785937a;hp=a6c84fe44ba9775f434bc5ff3ac06aad64bc36a6;hb=0759b42dbad7715339b0dceb5e910ea7698fa90a;hpb=70f23c42b325a1463fe8a9d76cb967b7df1260df diff --git a/yarrg/web/qtextstringcheck b/yarrg/web/qtextstringcheck index a6c84fe..686a506 100755 --- a/yarrg/web/qtextstringcheck +++ b/yarrg/web/qtextstringcheck @@ -74,8 +74,10 @@ if ($chk->method_exists('sqlstmt')) { my $emsg= ''; my @results; my @specs; +my $canontext; my $hooks = { Emsg => \$emsg, String => \$string, Results => \@results, Specs => \@specs, + Canon => \$canontext }; if ($chk->method_exists('preparse')) { @@ -92,7 +94,11 @@ foreach my $each (@specs) { my $err= sub { $emsg= $_[0]; last; }; my %m; my $results; - foreach my $pat ("$each", "$each\%", "\%$each\%") { + my @pats= ("$each", "$each\%", "\%$each\%"); + if ($chk->attr_exists('abbrev_initials')) { + push @pats, join ' ', map { "$_%" } split //, $each; + } + foreach my $pat (@pats) { $sth->execute(($pat) x @sqlstmt_qs); $results= $sth->fetchall_arrayref(); last if @$results==1; @@ -114,9 +120,10 @@ foreach my $each (@specs) { push @results, $results->[0]; }; -my $canontext= join ' | ', map { $_->[0] } @results; +if (!defined $canontext) { + $canontext= join ' | ', map { $_->[0] } @results; +} if ($chk->method_exists('postquery')) { - $hooks->{Canon}= \$canontext; $chk->call_method('postquery', h => $hooks); }