exodist / Term-Table

Format a header and rows into a table
Other
6 stars 9 forks source link

Line break calculation hangs #9

Closed god-of-hellfire closed 5 years ago

god-of-hellfire commented 5 years ago

If max_width is smaller than the "expected" width the calculation of the linebreak hangs in an infinite loop.

Running this script with debugger reveals that the condition in line Term::Table::LineBreak:54 is never matched. This causes the @parts array to grow instead of shrink.

This issue was produced on:

For testing: Change the max_width parameter to 12 will cause no harm.

#!/usr/bin/env perl

use warnings FATAL => 'all';
use strict;

use Term::Table;

my @rows;
my @cols = 1..1;

push(@rows, \@cols) for 1..1;

my $table = Term::Table->new(max_width => 11, collapse => 0, rows => \@rows);

print "$_\n" for $table->render;
exodist commented 5 years ago

released a new version that fixes this issue. Fixing this issue required adding an exception, and a way to override the exception. It also lead me to expose some un-documented padding that was going on. Finally I found an off-by-1 error in the border calculation, I have fixed that as well.