683572
From a4e94e39cfa6852b1d57e61ee122c8083ab9d82e Mon Sep 17 00:00:00 2001
683572
From: Hauke D <haukex@zero-g.net>
683572
Date: Mon, 20 Nov 2017 15:31:57 +0100
683572
Subject: [PATCH] Tie::StdHandle::BINMODE: handle layer argument
683572
MIME-Version: 1.0
683572
Content-Type: text/plain; charset=UTF-8
683572
Content-Transfer-Encoding: 8bit
683572
683572
Fixes #16262
683572
683572
BINMODE was not handling the LAYER argument.
683572
Also bump the version number.
683572
683572
(cherry picked from commit 479d04b98e5b747e5c9ead7368d3e132f524a2b7)
683572
Signed-off-by: Nicolas R <atoomic@cpan.org>
683572
Signed-off-by: Petr Písař <ppisar@redhat.com>
683572
---
683572
 lib/Tie/Handle/stdhandle.t | 13 ++++++++++++-
683572
 lib/Tie/StdHandle.pm       |  4 ++--
683572
 2 files changed, 14 insertions(+), 3 deletions(-)
683572
683572
diff --git a/lib/Tie/Handle/stdhandle.t b/lib/Tie/Handle/stdhandle.t
683572
index d2f04bcc5c..6c20d90f2b 100644
683572
--- a/lib/Tie/Handle/stdhandle.t
683572
+++ b/lib/Tie/Handle/stdhandle.t
683572
@@ -5,7 +5,7 @@ BEGIN {
683572
     @INC = '../lib';
683572
 }
683572
 
683572
-use Test::More tests => 27;
683572
+use Test::More tests => 29;
683572
 
683572
 use_ok('Tie::StdHandle');
683572
 
683572
@@ -72,6 +72,17 @@ is($b, "rhubarbX\n", "b eq rhubarbX");
683572
 $b = <$f>;
683572
 is($b, "89\n", "b eq 89");
683572
 
683572
+# binmode should pass through layer argument
683572
+
683572
+binmode $f, ':raw';
683572
+ok !grep( $_ eq 'utf8', PerlIO::get_layers(tied(*$f)) ),
683572
+    'no utf8 in layers after binmode :raw';
683572
+binmode $f, ':utf8';
683572
+ok grep( $_ eq 'utf8', PerlIO::get_layers(tied(*$f)) ),
683572
+    'utf8 is in layers after binmode :utf8';
683572
+
683572
+# finish up
683572
+
683572
 ok(eof($f), "eof");
683572
 ok(close($f), "close");
683572
 
683572
diff --git a/lib/Tie/StdHandle.pm b/lib/Tie/StdHandle.pm
683572
index dfb86634f0..fb79a986c6 100644
683572
--- a/lib/Tie/StdHandle.pm
683572
+++ b/lib/Tie/StdHandle.pm
683572
@@ -4,7 +4,7 @@ use strict;
683572
 
683572
 use Tie::Handle;
683572
 our @ISA = 'Tie::Handle';
683572
-our $VERSION = '4.5';
683572
+our $VERSION = '4.6';
683572
 
683572
 =head1 NAME
683572
 
683572
@@ -48,7 +48,7 @@ sub TELL    { tell($_[0]) }
683572
 sub FILENO  { fileno($_[0]) }
683572
 sub SEEK    { seek($_[0],$_[1],$_[2]) }
683572
 sub CLOSE   { close($_[0]) }
683572
-sub BINMODE { binmode($_[0]) }
683572
+sub BINMODE { &CORE::binmode(shift, @_) }
683572
 
683572
 sub OPEN
683572
 {
683572
-- 
683572
2.21.0
683572