From: Jarkko Hietaniemi Date: Wed, 16 Apr 2003 14:57:47 +0000 (+0000) Subject: Try to get the layers.t working also for dosish platforms. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=79d9a4d753ef0c0dd9ae193f48a2f22228f03b23;p=p5sagit%2Fp5-mst-13.2.git Try to get the layers.t working also for dosish platforms. p4raw-id: //depot/perl@19239 --- diff --git a/lib/PerlIO.pm b/lib/PerlIO.pm index 61a748a..678a79d 100644 --- a/lib/PerlIO.pm +++ b/lib/PerlIO.pm @@ -233,7 +233,23 @@ The following returns the B 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 or from C. Under C the platform specific low-level I/O (like -C) is not part of the stack, but under C it is. +C) is not part of the stack, but under C (and the +experimental C) it is. + +In platforms of DOS progeny (Win32 being the most prominent) the +lowest level layers are C, 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 argument: diff --git a/t/io/layers.t b/t/io/layers.t index 6f161cd..0da804c 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 },