344579
From 2b37a985ccd71d1a88e23cefd789a54d690d3761 Mon Sep 17 00:00:00 2001
344579
From: Russ Allbery <rra@cpan.org>
344579
Date: Sat, 27 May 2017 18:44:06 -0700
344579
Subject: [PATCH] Properly diagnose empty input to pod2man and pod2text
344579
MIME-Version: 1.0
344579
Content-Type: text/plain; charset=UTF-8
344579
Content-Transfer-Encoding: 8bit
344579
344579
Produce a proper diagnostic when given empty input on standard input
344579
with no other arguments to pod2man or pod2text.  Reported by Guillem
344579
Jover.
344579
344579
Fixes #5
344579
344579
Petr Písař: Ported to 4.09.
344579
344579
---
344579
 scripts/pod2man.PL  | 10 +++++++---
344579
 scripts/pod2text.PL | 10 +++++++---
344579
344579
diff --git a/scripts/pod2man.PL b/scripts/pod2man.PL
344579
index b70057b..3f19b79 100755
344579
--- a/scripts/pod2man.PL
344579
+++ b/scripts/pod2man.PL
344579
@@ -47,7 +47,7 @@ print {$out} <<'SCRIPT_BODY' or die "Cannot write to $file: $!\n";
344579
 # pod2man -- Convert POD data to formatted *roff input.
344579
 #
344579
 # Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014, 2015,
344579
-#     2016 Russ Allbery <rra@cpan.org>
344579
+#     2016, 2017 Russ Allbery <rra@cpan.org>
344579
 #
344579
 # This program is free software; you may redistribute it and/or modify it
344579
 # under the same terms as Perl itself.
344579
@@ -113,7 +113,11 @@ do {
344579
     $parser->parse_from_file (@files);
344579
     if ($parser->{CONTENTLESS}) {
344579
         $status = 1;
344579
-        warn "$0: unable to format $files[0]\n";
344579
+        if (defined $files[0]) {
344579
+            warn "$0: unable to format $files[0]\n";
344579
+        } else {
344579
+            warn "$0: unable to format standard input\n";
344579
+        }
344579
         if (defined ($files[1]) and $files[1] ne '-') {
344579
             unlink $files[1] unless (-s $files[1]);
344579
         }
344579
@@ -428,7 +432,7 @@ B<pod2man> by Larry Wall and Tom Christiansen.
344579
 =head1 COPYRIGHT AND LICENSE
344579
 
344579
 Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014,
344579
-2015, 2016 Russ Allbery <rra@cpan.org>
344579
+2015, 2016, 2017 Russ Allbery <rra@cpan.org>
344579
 
344579
 This program is free software; you may redistribute it and/or modify it
344579
 under the same terms as Perl itself.
344579
diff --git a/scripts/pod2text.PL b/scripts/pod2text.PL
344579
index f6c8071..d1a146e 100755
344579
--- a/scripts/pod2text.PL
344579
+++ b/scripts/pod2text.PL
344579
@@ -47,7 +47,7 @@ print {$out} <<'SCRIPT_BODY' or die "Cannot write to $file: $!\n";
344579
 # pod2text -- Convert POD data to formatted ASCII text.
344579
 #
344579
 # Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014, 2015,
344579
-#     2016 Russ Allbery <rra@cpan.org>
344579
+#     2016, 2017 Russ Allbery <rra@cpan.org>
344579
 #
344579
 # This program is free software; you may redistribute it and/or modify it
344579
 # under the same terms as Perl itself.
344579
@@ -123,7 +123,11 @@ do {
344579
     $parser->parse_from_file ($input, $output);
344579
     if ($parser->{CONTENTLESS}) {
344579
         $status = 1;
344579
-        warn "$0: unable to format $input\n";
344579
+        if (defined $input) {
344579
+            warn "$0: unable to format $input\n";
344579
+        } else {
344579
+            warn "$0: unable to format standard input\n";
344579
+        }
344579
         if (defined ($output) and $output ne '-') {
344579
             unlink $output unless (-s $output);
344579
         }
344579
@@ -358,7 +362,7 @@ Russ Allbery <rra@cpan.org>.
344579
 =head1 COPYRIGHT AND LICENSE
344579
 
344579
 Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014, 2015,
344579
-2016 Russ Allbery <rra@cpan.org>
344579
+2016, 2017 Russ Allbery <rra@cpan.org>
344579
 
344579
 This program is free software; you may redistribute it and/or modify it
344579
 under the same terms as Perl itself.
344579
-- 
344579
2.13.6
344579