summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-04-16 14:57:47 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-04-16 14:57:47 +0000
commit79d9a4d753ef0c0dd9ae193f48a2f22228f03b23 (patch)
tree4a0a0d8eaebc79719cb0b0c5407426c9612a5b12
parent7c91f47780c6b4923bae37d60b9019a6a770cdf2 (diff)
downloadperl-79d9a4d753ef0c0dd9ae193f48a2f22228f03b23.tar.gz
Try to get the layers.t working also for dosish platforms.
p4raw-id: //depot/perl@19239
-rw-r--r--lib/PerlIO.pm18
-rw-r--r--t/io/layers.t22
2 files changed, 32 insertions, 8 deletions
diff --git a/lib/PerlIO.pm b/lib/PerlIO.pm
index 61a748aa05..678a79dd2c 100644
--- a/lib/PerlIO.pm
+++ b/lib/PerlIO.pm
@@ -233,7 +233,23 @@ The following returns the B<names> of the PerlIO layers on a filehandle.
The layers are returned in the order an open() or binmode() call would
use them. Note that the stack begins (normally) from C<stdio> or from
C<perlio>. Under C<stdio> the platform specific low-level I/O (like
-C<unix>) is not part of the stack, but under C<perlio> it is.
+C<unix>) is not part of the stack, but under C<perlio> (and the
+experimental C<mmap>) it is.
+
+In platforms of DOS progeny (Win32 being the most prominent) the
+lowest level layers are C<unix crlf>, meaning that Perl first uses the
+UNIX-style low-level fd layer, and then on top of that a layer that
+handles the CRLF translation.
+
+The following table summarizes the default layers on UNIX-like and
+DOS-like platforms and depending on the setting of the C<$ENV{PERLIO}>:
+
+ PERLIO UNIX-like DOS-like
+
+ none stdio unix crlf
+ stdio stdio stdio
+ perlio unix perlio unix perlio
+ mmap unix mmap unix mmap
By default the layers from the input side of the filehandle is
returned, to get the output side use the optional C<output> argument:
diff --git a/t/io/layers.t b/t/io/layers.t
index 6f161cd8b0..0da804c33f 100644
--- a/t/io/layers.t
+++ b/t/io/layers.t
@@ -18,6 +18,7 @@ plan tests => 43;
use Config;
+my $DOSISH = $^O =~ /^(?:MSWin32|cygwin|os2|dos|NetWare|mint)$/;
my $NONSTDIO = exists $ENV{PERLIO} && $ENV{PERLIO} ne 'stdio';
SKIP: {
@@ -26,14 +27,18 @@ SKIP: {
sub check {
my ($result, $expected, $id) = @_;
- my $n = scalar @$expected;
- is($n, scalar @$expected, "$id - layers = $n");
if ($NONSTDIO) {
- # Get rid of "unix" and similar OS-specific low lever layer.
- shift(@$result);
+ # Get rid of "unix".
+ shift @$result if $result->[0] eq "unix";
# Change expectations.
$expected->[0] = $ENV{PERLIO} if $expected->[0] eq "stdio";
+ } elsif ($DOSISH) {
+ splice(@$result, 0, 2, "stdio")
+ if $result->[0] eq "unix" &&
+ $result->[1] eq "crlf";
}
+ my $n = scalar @$expected;
+ is($n, scalar @$expected, "$id - layers = $n");
for (my $i = 0; $i < $n; $i++) {
my $j = $expected->[$i];
if (ref $j eq 'CODE') {
@@ -74,6 +79,7 @@ SKIP: {
[ "stdio" ],
":raw");
+ binmode(F, ":pop") if $DOSISH; # Drop one extra :crlf.
binmode(F, ":utf8");
check([ PerlIO::get_layers(F) ],
@@ -100,11 +106,13 @@ SKIP: {
binmode(F, ":raw :encoding(latin1)"); # "latin1" will be canonized
- {
+ SKIP: {
+ skip("too complex layer coreography", 7) if $DOSISH;
+
my @results = PerlIO::get_layers(F, details => 1);
- # Get rid of "unix" and undef.
- splice(@results, 0, 2) if $NONSTDIO;
+ # Get rid of the args and the flags.
+ splice(@results, 1, 2) if $NONSTDIO;
check([ @results ],
[ "stdio", undef, sub { $_[0] > 0 },