Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line break calculation hangs #9

Closed
god-of-hellfire opened this issue Dec 4, 2018 · 1 comment
Closed

Line break calculation hangs #9

god-of-hellfire opened this issue Dec 4, 2018 · 1 comment

Comments

@god-of-hellfire
Copy link

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:

  • AIX with Perl 5.14.2 and Term::Table 0.012
  • Centos 7, Perl 5.16.3 and Term::Table 0.012

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 added a commit that referenced this issue Dec 4, 2018
 * Throw exception if table cannot fit in bounds
 * Allow override of that exception via allow_overflow
 * Allow control over 'arbitrary' padding, but keep default for legacy
 * Fix off-by-one error when calculating the border (accidentally dded 3 columns)
 * Document new parameters
@exodist
Copy link
Owner

exodist commented Dec 4, 2018

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.

@exodist exodist closed this as completed Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants