Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
(perl #133604) fix binmode on Win32 :crlf layers
Browse files Browse the repository at this point in the history
On Win32 the :crlf layer is special - it replaces the use of the normal
:perlio buffering layer.

So while binmode :raw with :crlf present on non-Win32 removes the
CRLF layer, on Win32 it simply switches the :crlf layer's CRLF flag off
to prevent translation.

Unfortunately the :crlf skipped doing something else expected by :raw -
it didn't turn off the layer UTF8 flag.  This broke the tests I added
in 9704d77.

(cherry picked from commit dda4a47)
  • Loading branch information
tonycoz authored and rurban committed Apr 13, 2019
1 parent ecb8a23 commit ff545dd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion perlio.c
Expand Up @@ -4968,7 +4968,7 @@ PerlIOCrlf_binmode(pTHX_ PerlIO *f)
PerlIO_pop(aTHX_ f);
#endif
}
return 0;
return PerlIOBase_binmode(aTHX_ f);
}

PERLIO_FUNCS_DECL(PerlIO_crlf) = {
Expand Down
6 changes: 6 additions & 0 deletions pod/perlcdelta.pod
Expand Up @@ -655,6 +655,12 @@ C<grok_atoUV> supports that too now.

=item *

C<binmode($fh);> or C<binmode($fh, ':raw');> now properly removes the
C<:utf8> flag from the default C<:crlf> I/O layer on Win32.
L<[perl #133604]|https://rt.perl.org/Public/Bug/Display.html?id=133604>

=item *

C<pack "u", "invalid uuencoding"> now properly NUL terminates the
zero-length SV produced.
L<[perl #132655]|https://rt.perl.org/Public/Bug/Display.html?id=132655>
Expand Down
1 change: 0 additions & 1 deletion t/io/crlf.t
Expand Up @@ -98,7 +98,6 @@ my $ungetc_count = 8200; # Somewhat over the likely buffer size
ok((() = grep($_ eq "utf8", PerlIO::get_layers($fh))),
"check :utf8 set");
ok(binmode($fh), "remove :utf8");
local $TODO = "this fails without the fix";
ok(!(() = grep($_ eq "utf8", PerlIO::get_layers($fh))),
"check :utf8 removed");
close $fh;
Expand Down
2 changes: 0 additions & 2 deletions t/io/socket.t
Expand Up @@ -141,8 +141,6 @@ SKIP: {
# separate to avoid interfering with the data expected above
$local or skip("No localhost", 1);
$fork or skip("No fork", 1);
$^O eq "MSWin32"
and skip("binmode acting strangely here on Win32", 1);

note "recv/send :utf8 tests";
ok(socket(my $serv, PF_INET, SOCK_STREAM, $tcp), "make a tcp socket (recv/send :utf8 handling)");
Expand Down

0 comments on commit ff545dd

Please sign in to comment.