Skip to content

Commit 6ec3f23

Browse files
committed
genhtml: Fix warning with small genhtml_line_field_width
On systems with Perl versions 5.21 and above, genhtml prints a warning similar to the following during processing: genhtml: Negative repeat count does nothing at bin/genhtml line 3854, <SOURCE_HANDLE> line 4. This is due to size calculations resulting in a negative number of padding characters when genhtml_line_field_width is lower than the size of the strings to pad (9). Fix this by disabling padding in these cases. Reported-by: [email protected] Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent d7cc759 commit 6ec3f23

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bin/genhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,8 +3851,8 @@ sub fmt_centered($$)
38513851
{
38523852
my ($width, $text) = @_;
38533853
my $w0 = length($text);
3854-
my $w1 = int(($width - $w0) / 2);
3855-
my $w2 = $width - $w0 - $w1;
3854+
my $w1 = $width > $w0 ? int(($width - $w0) / 2) : 0;
3855+
my $w2 = $width > $w0 ? $width - $w0 - $w1 : 0;
38563856

38573857
return (" "x$w1).$text.(" "x$w2);
38583858
}

0 commit comments

Comments
 (0)