summaryrefslogtreecommitdiff
path: root/fml/lib/IO/Adapter
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-06-27 05:59:10 +0000
committerfukachan <fukachan>2004-06-27 05:59:10 +0000
commit6ee839b2e6c6b376e86ad0bbf2e782bf55f80f7e (patch)
tree2cad7edbd1505bab2f81fc5258e587be53fe9b62 /fml/lib/IO/Adapter
parent93dcf39535d34c1715c9d83fa636cf8cb3c44613 (diff)
downloadfml8-6ee839b2e6c6b376e86ad0bbf2e782bf55f80f7e.tar.gz
fml8-6ee839b2e6c6b376e86ad0bbf2e782bf55f80f7e.tar.bz2
fml8-6ee839b2e6c6b376e86ad0bbf2e782bf55f80f7e.zip
bug fix delete():
o not apply quotemeta() for key. o autoflush(1) o check the number of matching, return error if no any matched line.
Diffstat (limited to 'fml/lib/IO/Adapter')
-rw-r--r--fml/lib/IO/Adapter/File.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm
index 96a7a407..785bdcb5 100644
--- a/fml/lib/IO/Adapter/File.pm
+++ b/fml/lib/IO/Adapter/File.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: File.pm,v 1.55 2004/04/11 12:58:39 fukachan Exp $
+# $FML: File.pm,v 1.56 2004/05/25 04:03:06 fukachan Exp $
#
package IO::Adapter::File;
@@ -440,23 +440,32 @@ delete lines with key $key from this map.
sub delete
{
my ($self, $key) = @_;
+ my $found = 0;
$self->open("w");
my $fh = $self->{ _fh };
my $wh = $self->{ _wh };
- if (defined $fh) {
- my $key = quotemeta($key);
+ if (defined $fh && defined $wh) {
my $buf;
+ $wh->autoflush(1);
+
FILE_IO:
while ($buf = <$fh>) {
- next FILE_IO if $buf =~ /^$key\s+\S+|^$key\s*$/;
+ if ($buf =~ /^$key\s+\S+|^$key\s*$/) {
+ $found++;
+ next FILE_IO;
+ }
print $wh $buf;
}
- $fh->close;
$wh->close;
+ $fh->close;
+
+ unless ($found) {
+ $self->error_set("Error: not match");
+ }
}
else {
$self->error_set("Error: cannot open file=$self->{ _file }");