01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Index: clsearch.cgi
===================================================================
RCS file: /home/masao/.cvsroot/public_html/d/clsearch.cgi,v
retrieving revision 1.2
diff -u -b -r1.2 clsearch.cgi
--- clsearch.cgi 26 Apr 2006 16:12:32 -0000 1.2
+++ clsearch.cgi 29 Apr 2006 06:57:18 -0000
@@ -67,6 +67,9 @@
my $outstr = "";
my $cnt = 0;
+my $ascii = '[\x00-\x7F]';
+my $twoBytes = '[\x8E\xA1-\xFE][\xA1-\xFE]';
+my $threeBytes = '\x8F[\xA1-\xFE][\xA1-\xFE]';
sub clean {
local ($_) = @_;
@@ -101,7 +104,8 @@
$match_num++ if ($c =~ /^.+\[$tmp\].*\t.*$/);
} else {
my $tmp = clean($k);
- $match_num++ if ($c =~ m|$tmp|i);
+ $match_num++
+ if $c =~ /^(?:$ascii|$twoBytes|$threeBytes)*?(?:$tmp)/i;
push @regular_keys, $tmp;
}
}
@@ -128,7 +132,7 @@
$pos =~ s!^(([\x80-\xff]{2})*?)[\x80-\xff]$!$1!;
$c = qq($pre$k$pos);
my $p = join('|', @regular_keys);
- $c =~ s!($p)!$open_tag$1$close_tag!gi;
+ $c =~ s!\G((?:$ascii|$twoBytes|$threeBytes)*?)($p)!$1$open_tag$2$close_tag!gi;
}
} elsif ($mode == 1) { # アイテムモード
my ($file, $id) = ($date =~ /href="(.*?.html).*?">\[(.+?)\]/);