Now that trailing whitespace should no longer appear in POD files,
enhance podwrapper to detect this and error out.
I had to modify podwrapper so it doesn't introduce trailing whitespace
when it encounters a blank line in a --verbatim include.
Acked-by: Laszlo Ersek <lersek(a)redhat.com>
Acked-by: Eric Blake <eblake(a)redhat.com>
---
podwrapper.pl.in | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/podwrapper.pl.in b/podwrapper.pl.in
index bd0cf3ee..e28020a0 100755
--- a/podwrapper.pl.in
+++ b/podwrapper.pl.in
@@ -286,6 +286,10 @@ die "$progname: $input: is not valid utf8" unless
utf8::is_utf8 ($content);
die "$progname: $input: =encoding must not be present in input\n"
if $content =~ /^=encoding/m;
+# Don't permit trailing whitespace.
+die "$progname: $input: trailing whitespace in input\n"
+ if $content =~ /[ \t]$/m;
+
# We may add an encoding line, but this breaks RHEL 6-era Pod::Simple
# with the error "Cannot decode string with wide characters".
$content =~ s/^=(.*)/\n=encoding utf8\n\n=$1/m
@@ -576,14 +580,15 @@ sub read_whole_file
sub read_verbatim_file
{
my $input = shift;
- my $r = "";
+ my @r = ();
open FILE, "<:encoding(UTF-8)", $input or die "$progname: $input:
$!";
while (<FILE>) {
- $r .= " $_";
+ chomp;
+ if (length) { push @r, " $_" } else { push @r, "" }
}
close FILE;
- $r;
+ return join ("\n", @r) . "\n";
}
=head1 SEE ALSO
--
2.35.1