summaryrefslogtreecommitdiff
path: root/ext/PerlIO
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-11-15 14:35:55 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-15 14:35:55 +0000
commited53a2bb7f04bc2b3b8eb8450d6e00842e9d7680 (patch)
tree10062f2208f919244a92f310db85dea6bcbfd6df /ext/PerlIO
parent313c9f5cdd9c2881025ae80733bae6b0f1cb11f9 (diff)
downloadperl-ed53a2bb7f04bc2b3b8eb8450d6e00842e9d7680.tar.gz
Fix for "perlio bug in koi8-r encoding". The problem
seemed to be that binmode() always flushed the handle, which is not so good when switching encodings. Fixed, added Matt Sergeant's testcase, documented in perlfunc/binmode, also added a pointer about disciplines to perlfunc/open, and in general cleaned up and reformatted the open entry. p4raw-id: //depot/perl@13019
Diffstat (limited to 'ext/PerlIO')
-rw-r--r--ext/PerlIO/t/encoding.t28
1 files changed, 26 insertions, 2 deletions
diff --git a/ext/PerlIO/t/encoding.t b/ext/PerlIO/t/encoding.t
index 590fc00266..e30e270535 100644
--- a/ext/PerlIO/t/encoding.t
+++ b/ext/PerlIO/t/encoding.t
@@ -9,11 +9,12 @@ BEGIN {
}
}
-print "1..10\n";
+print "1..11\n";
my $grk = "grk$$";
my $utf = "utf$$";
my $fail1 = "fail$$";
+my $russki = "koi8r$$";
if (open(GRK, ">$grk")) {
# alpha beta gamma in ISO 8859-7
@@ -73,6 +74,29 @@ if (!defined $warn) {
print "not ok 10 # warning is '$warn'";
}
+if (open(RUSSKI, ">$russki")) {
+ print RUSSKI "\x3c\x3f\x78";
+ close RUSSKI;
+ open(RUSSKI, "$russki");
+ binmode(RUSSKI, ":raw");
+ my $buf1;
+ read(RUSSKI, $buf1, 1);
+ eof(RUSSKI);
+ binmode(RUSSKI, ":encoding(koi8-r)");
+ my $buf2;
+ read(RUSSKI, $buf2, 1);
+ my $offset = tell(RUSSKI);
+ if (ord($buf1) == 0x3c && ord($buf2) == 0x3f && $offset == 2) {
+ print "ok 11\n";
+ } else {
+ printf "not ok 11 # %#x %#x %d\n",
+ ord($buf1), ord($buf2), $offset;
+ }
+ close(RUSSKI);
+} else {
+ print "not ok 11 # open failed: $!\n";
+}
+
END {
- unlink($grk, $utf, $fail1);
+ unlink($grk, $utf, $fail1, $russki);
}