Change 19643 by [EMAIL PROTECTED] on 2003/05/31 05:28:56
Upgrade to Tie::File 0.96.
Affected files ...
... //depot/perl/lib/Tie/File.pm#26 edit
... //depot/perl/lib/Tie/File/t/00_version.t#11 edit
... //depot/perl/lib/Tie/File/t/09_gen_rs.t#11 edit
Differences ...
==== //depot/perl/lib/Tie/File.pm#26 (text) ====
Index: perl/lib/Tie/File.pm
--- perl/lib/Tie/File.pm#25~19512~ Tue May 13 06:28:42 2003
+++ perl/lib/Tie/File.pm Fri May 30 22:28:56 2003
@@ -7,7 +7,7 @@
sub O_ACCMODE () { O_RDONLY | O_RDWR | O_WRONLY }
-$VERSION = "0.95";
+$VERSION = "0.96";
my $DEFAULT_MEMORY_SIZE = 1<<21; # 2 megabytes
my $DEFAULT_AUTODEFER_THRESHHOLD = 3; # 3 records
my $DEFAULT_AUTODEFER_FILELEN_THRESHHOLD = 65536; # 16 disk blocksful
@@ -901,8 +901,7 @@
$rec = <$fh>;
}
return unless defined $rec;
- if (! $self->{sawlastrec} &&
- substr($rec, -$self->{recseplen}) ne $self->{recsep}) {
+ if (substr($rec, -$self->{recseplen}) ne $self->{recsep}) {
# improperly terminated final record --- quietly fix it.
# my $ac = substr($rec, -$self->{recseplen});
# $ac =~ s/\n/\\n/g;
@@ -1994,7 +1993,7 @@
=head1 SYNOPSIS
- # This file documents Tie::File version 0.95
+ # This file documents Tie::File version 0.96
use Tie::File;
tie @array, 'Tie::File', filename or die ...;
@@ -2304,6 +2303,11 @@
filehandle, and are responsible for closing it after you have untied
the @array.
+Note that Tie::File will only close any filehandles that it opened
+internally. If you passed it a filehandle as above, you "own" the
+filehandle, and are responsible for closing it after you have untied
+the @array.
+
=head1 Deferred Writing
(This is an advanced feature. Skip this section on first reading.)
@@ -2517,7 +2521,7 @@
=head1 LICENSE
-C<Tie::File> version 0.95 is copyright (C) 2002 Mark Jason Dominus.
+C<Tie::File> version 0.96 is copyright (C) 2002 Mark Jason Dominus.
This library is free software; you may redistribute it and/or modify
it under the same terms as Perl itself.
@@ -2545,7 +2549,7 @@
=head1 WARRANTY
-C<Tie::File> version 0.95 comes with ABSOLUTELY NO WARRANTY.
+C<Tie::File> version 0.96 comes with ABSOLUTELY NO WARRANTY.
For details, see the license.
=head1 THANKS
@@ -2567,7 +2571,9 @@
Additional thanks to:
Edward Avis /
Mattia Barbon /
+Tom Christiansen /
Gerrit Haase /
+Gurusamy Sarathy /
Jarkko Hietaniemi (again) /
Nikola Knezevic /
John Kominetz /
==== //depot/perl/lib/Tie/File/t/00_version.t#11 (text) ====
Index: perl/lib/Tie/File/t/00_version.t
--- perl/lib/Tie/File/t/00_version.t#10~19450~ Thu May 8 10:46:26 2003
+++ perl/lib/Tie/File/t/00_version.t Fri May 30 22:28:56 2003
@@ -2,7 +2,7 @@
print "1..1\n";
-my $testversion = "0.95";
+my $testversion = "0.96";
use Tie::File;
if ($Tie::File::VERSION != $testversion) {
==== //depot/perl/lib/Tie/File/t/09_gen_rs.t#11 (text) ====
Index: perl/lib/Tie/File/t/09_gen_rs.t
--- perl/lib/Tie/File/t/09_gen_rs.t#10~19511~ Tue May 13 06:08:47 2003
+++ perl/lib/Tie/File/t/09_gen_rs.t Fri May 30 22:28:56 2003
@@ -1,8 +1,9 @@
#!/usr/bin/perl
+use lib '/home/mjd/src/perl/Tie-File2/lib';
my $file = "tf$$.txt";
-print "1..58\n";
+print "1..59\n";
my $N = 1;
use Tie::File;
@@ -128,7 +129,7 @@
check_contents("x", "y");
}
-# (57-58) 20020402 The modifiaction would have failed if $\ were set wrong.
+# (57-58) 20020402 The modification would have failed if $\ were set wrong.
# I hate $\.
if (setup_badly_terminated_file(2)) {
$o = tie @a, 'Tie::File', $file,
@@ -138,6 +139,23 @@
my $z = $a[0];
}
check_contents($badrec);
+}
+
+# (59) 20030527 Tom Christiansen pointed out that FETCH returns the wrong
+# data on the final record of an unterminated file if the file is opened
+# in read-only mode. Note that the $#a is necessary here.
+# There's special-case code to fix the final record when it is read normally.
+# But the $#a forces it to be read from the cache, which skips the
+# termination.
+$badrec = "world\nhello";
+if (setup_badly_terminated_file(1)) {
+ tie(@a, "Tie::File", $file, mode => 0, recsep => $RECSEP)
+ or die "Couldn't tie file: $!";
+ my $z = $#a;
+ $z = $a[1];
+ print $z eq "hello" ? "ok $N\n" :
+ "not ok $N \# got $z, expected hello\n";
+ $N++;
}
sub setup_badly_terminated_file {
End of Patch.