summaryrefslogtreecommitdiff
path: root/fml/lib/IO
diff options
context:
space:
mode:
authorfukachan <fukachan>2005-12-11 13:10:25 +0000
committerfukachan <fukachan>2005-12-11 13:10:25 +0000
commitff3ef020f2fc880d891f4b5539c3183f546bda1f (patch)
tree7bba13a4fcec91e6c2648bb72bf783a0e71fa76c /fml/lib/IO
parent4784de984374a89ddfa8963f3acf6f5e3d4bdfec (diff)
downloadfml8-ff3ef020f2fc880d891f4b5539c3183f546bda1f.tar.gz
fml8-ff3ef020f2fc880d891f4b5539c3183f546bda1f.tar.bz2
fml8-ff3ef020f2fc880d891f4b5539c3183f546bda1f.zip
pass hints to IO::Adapter to return matched address.
Diffstat (limited to 'fml/lib/IO')
-rw-r--r--fml/lib/IO/Adapter/PCRE.pm39
1 files changed, 36 insertions, 3 deletions
diff --git a/fml/lib/IO/Adapter/PCRE.pm b/fml/lib/IO/Adapter/PCRE.pm
index a19c1f0b..131878cc 100644
--- a/fml/lib/IO/Adapter/PCRE.pm
+++ b/fml/lib/IO/Adapter/PCRE.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML$
+# $FML: PCRE.pm,v 1.1 2005/12/08 10:05:58 fukachan Exp $
#
package IO::Adapter::PCRE;
@@ -60,7 +60,8 @@ sub md_find
{
my ($self, $regexp, $args) = @_;
my $case_sensitive = $args->{ case_sensitive } ? 1 : 0;
- my $want = $args->{ want } || 'key,value';
+ my $want = $args->{ want } || 'key,value';
+ my $hints = $args->{ hints } || [];
my $show_all = $args->{ all } ? 1 : 0;
my (@buf, $x);
@@ -74,21 +75,37 @@ sub md_find
};
}
+ $self->open();
+
my $pcre;
LINE:
while ($pcre = $self->get_next_key()) {
- print "($regexp =~ /$pcre/)\n";
+ if ($debug) {
+ print "SEARCH: ($regexp|[@$hints]) =~ /$pcre/\n";
+ }
if ($show_all) {
if ($case_sensitive) {
if ($regexp =~ /$pcre/) {
push(@buf, $regexp);
}
+
+ for my $hint (@$hints) {
+ if ($hint =~ /$pcre/) {
+ push(@buf, $hint);
+ }
+ }
}
else {
if ($regexp =~ /$pcre/i) {
push(@buf, $regexp);
}
+
+ for my $hint (@$hints) {
+ if ($hint =~ /$pcre/i) {
+ push(@buf, $hint);
+ }
+ }
}
}
else {
@@ -97,16 +114,32 @@ sub md_find
$x = $regexp;
last LINE;
}
+
+ for my $hint (@$hints) {
+ if ($hint =~ /$pcre/) {
+ $x = $regexp;
+ last LINE;
+ }
+ }
}
else {
if ($regexp =~ /$pcre/i) {
$x = $regexp;
last LINE;
}
+
+ for my $hint (@$hints) {
+ if ($hint =~ /$pcre/i) {
+ $x = $regexp;
+ last LINE;
+ }
+ }
}
}
}
+ $self->close();
+
return( $show_all ? \@buf : $x );
}