Blob Blame History Raw
From 2b37a985ccd71d1a88e23cefd789a54d690d3761 Mon Sep 17 00:00:00 2001
From: Russ Allbery <rra@cpan.org>
Date: Sat, 27 May 2017 18:44:06 -0700
Subject: [PATCH] Properly diagnose empty input to pod2man and pod2text
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Produce a proper diagnostic when given empty input on standard input
with no other arguments to pod2man or pod2text.  Reported by Guillem
Jover.

Fixes #5

Petr Písař: Ported to 4.09.

---
 scripts/pod2man.PL  | 10 +++++++---
 scripts/pod2text.PL | 10 +++++++---

diff --git a/scripts/pod2man.PL b/scripts/pod2man.PL
index b70057b..3f19b79 100755
--- a/scripts/pod2man.PL
+++ b/scripts/pod2man.PL
@@ -47,7 +47,7 @@ print {$out} <<'SCRIPT_BODY' or die "Cannot write to $file: $!\n";
 # pod2man -- Convert POD data to formatted *roff input.
 #
 # Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014, 2015,
-#     2016 Russ Allbery <rra@cpan.org>
+#     2016, 2017 Russ Allbery <rra@cpan.org>
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
@@ -113,7 +113,11 @@ do {
     $parser->parse_from_file (@files);
     if ($parser->{CONTENTLESS}) {
         $status = 1;
-        warn "$0: unable to format $files[0]\n";
+        if (defined $files[0]) {
+            warn "$0: unable to format $files[0]\n";
+        } else {
+            warn "$0: unable to format standard input\n";
+        }
         if (defined ($files[1]) and $files[1] ne '-') {
             unlink $files[1] unless (-s $files[1]);
         }
@@ -428,7 +432,7 @@ B<pod2man> by Larry Wall and Tom Christiansen.
 =head1 COPYRIGHT AND LICENSE
 
 Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014,
-2015, 2016 Russ Allbery <rra@cpan.org>
+2015, 2016, 2017 Russ Allbery <rra@cpan.org>
 
 This program is free software; you may redistribute it and/or modify it
 under the same terms as Perl itself.
diff --git a/scripts/pod2text.PL b/scripts/pod2text.PL
index f6c8071..d1a146e 100755
--- a/scripts/pod2text.PL
+++ b/scripts/pod2text.PL
@@ -47,7 +47,7 @@ print {$out} <<'SCRIPT_BODY' or die "Cannot write to $file: $!\n";
 # pod2text -- Convert POD data to formatted ASCII text.
 #
 # Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014, 2015,
-#     2016 Russ Allbery <rra@cpan.org>
+#     2016, 2017 Russ Allbery <rra@cpan.org>
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
@@ -123,7 +123,11 @@ do {
     $parser->parse_from_file ($input, $output);
     if ($parser->{CONTENTLESS}) {
         $status = 1;
-        warn "$0: unable to format $input\n";
+        if (defined $input) {
+            warn "$0: unable to format $input\n";
+        } else {
+            warn "$0: unable to format standard input\n";
+        }
         if (defined ($output) and $output ne '-') {
             unlink $output unless (-s $output);
         }
@@ -358,7 +362,7 @@ Russ Allbery <rra@cpan.org>.
 =head1 COPYRIGHT AND LICENSE
 
 Copyright 1999, 2000, 2001, 2004, 2006, 2008, 2010, 2012, 2013, 2014, 2015,
-2016 Russ Allbery <rra@cpan.org>
+2016, 2017 Russ Allbery <rra@cpan.org>
 
 This program is free software; you may redistribute it and/or modify it
 under the same terms as Perl itself.
-- 
2.13.6