344579
From 72b821db9a1e5e25febe2f3551dcb1ef273206c9 Mon Sep 17 00:00:00 2001
344579
From: Russ Allbery <rra@cpan.org>
344579
Date: Sun, 17 Sep 2017 11:38:23 -0700
344579
Subject: [PATCH] Coerce file handle to glob for PerlIO::get_layers
344579
MIME-Version: 1.0
344579
Content-Type: text/plain; charset=UTF-8
344579
Content-Transfer-Encoding: 8bit
344579
344579
[Pod::Man] Wrap the output file descriptor in a glob before passing it
344579
to PerlIO::get_layers so that the layer check works properly.
344579
Previously, this code would throw a warning if given a scalar not
344579
wrapped in a glob and not detect layers properly.  Patch from Zefram.
344579
(#122521)
344579
344579
Petr Písař: Port to 4.09.
344579
344579
---
344579
 lib/Pod/Man.pm | 7 +++++--
344579
344579
diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm
344579
index db49bde..a737e5b 100644
344579
--- a/lib/Pod/Man.pm
344579
+++ b/lib/Pod/Man.pm
344579
@@ -800,13 +800,16 @@ sub start_document {
344579
     # has a PerlIO encoding layer set.  If it does not, we'll need to encode
344579
     # our output before printing it (handled in the output() sub).  Wrap the
344579
     # check in an eval to handle versions of Perl without PerlIO.
344579
+    #
344579
+    # PerlIO::get_layers still requires its argument be a glob, so coerce the
344579
+    # file handle to a glob.
344579
     $$self{ENCODE} = 0;
344579
     if ($$self{utf8}) {
344579
         $$self{ENCODE} = 1;
344579
         eval {
344579
             my @options = (output => 1, details => 1);
344579
-            my $flag = (PerlIO::get_layers ($$self{output_fh}, @options))[-1];
344579
-            if ($flag & PerlIO::F_UTF8 ()) {
344579
+            my @layers = PerlIO::get_layers (*{$$self{output_fh}}, @options);
344579
+            if ($layers[-1] & PerlIO::F_UTF8 ()) {
344579
                 $$self{ENCODE} = 0;
344579
             }
344579
         }
344579
-- 
344579
2.13.6
344579