Skip Menu |

This queue is for tickets about the podlators CPAN distribution.

Report information
The Basics
Id: 124447
Status: resolved
Priority: 0/
Queue: podlators

People
Owner: RRA [...] cpan.org
Requestors: eponymousalias [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 4.10
Fixed in: 4.11



Subject: Pod::Text::Termcap explicit width control is faulty
In the Termcap.pm file of Pod::Text::Termcap version 4.10, this line: unless (defined $$self{width}) { should read like this instead: unless (defined $$self{opt_width}) { in order to properly use the documented constructor "width" parameter. Currently, that parameter is just being ignored, because the parent class creates an "opt_width" hash key with it, not a "width" hash key.
Subject: Re: [rt.cpan.org #124447] Pod::Text::Termcap explicit width control is faulty
Date: Sat, 17 Feb 2018 14:30:39 -0800
To: "eponymous alias via RT" <bug-podlators [...] rt.cpan.org>
From: Russ Allbery <rra [...] cpan.org>
"eponymous alias via RT" <bug-podlators@rt.cpan.org> writes: Show quoted text
> In the Termcap.pm file of Pod::Text::Termcap version 4.10, this line:
Show quoted text
> unless (defined $$self{width}) {
Show quoted text
> should read like this instead:
Show quoted text
> unless (defined $$self{opt_width}) {
Show quoted text
> in order to properly use the documented constructor "width" parameter. > Currently, that parameter is just being ignored, because the parent > class creates an "opt_width" hash key with it, not a "width" hash key.
Wow, this has been broken since the 2.0.0 release. Nice find! Fixed in Git for the next release, which should be fairly soon. -- #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD, 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{ rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
From: eponymousalias [...] yahoo.com
On Sat Feb 17 17:39:04 2018, RRA wrote: Show quoted text
> "eponymous alias via RT" <bug-podlators@rt.cpan.org> writes: >
> > In the Termcap.pm file of Pod::Text::Termcap version 4.10, this line:
>
> > unless (defined $$self{width}) {
>
> > should read like this instead:
>
> > unless (defined $$self{opt_width}) {
>
> > in order to properly use the documented constructor "width" parameter. > > Currently, that parameter is just being ignored, because the parent > > class creates an "opt_width" hash key with it, not a "width" hash key.
> > Wow, this has been broken since the 2.0.0 release. Nice find! Fixed in > Git for the next release, which should be fairly soon.
There is a further problem with the width option in Pod::Text::Termcap, this one involving how wrapping is implemented. I am using Pod::Text::Termcap v4.10 modified with the simple change described in bug #124447 (this one) to get the package to pay attention to the width parameter. I have a bunch of =item lines that contain multi-word tags with many embedded color changes (generated by B<words> and I<words> elements). I observe that when my formatted POD is output to an xterm, text in open paragraphs manages to use the Pod::Text::Termcap::wrap() routine, and the characters comprising escape sequences for color changes embedded in that text do not cause early wrapping. However, for some reason the text in my =item tags seems to be processed instead by Pod::Text::wrap(), meaning I get wrapping much too soon in this text. I don't understand the internals of these two packages well enough to know why the one case is working while the other is not, nor to understand how to force the wrap() override to work in the second case. Here is a small test item, wherein on an 80-character terminal, I get the ellipsis at the end wrapped onto the next line when it shouldn't be (and isn't, if the terminal is say 100 characters wide). =over 4 =item B<autosetup print analysis> [B<-e>|B<-f>|B<-u>] I<hostname> ... =back
Subject: Re: [rt.cpan.org #124447] Pod::Text::Termcap explicit width control is faulty
Date: Sun, 18 Feb 2018 12:45:02 -0800
To: "eponymous alias via RT" <bug-podlators [...] rt.cpan.org>
From: Russ Allbery <rra [...] cpan.org>
"eponymous alias via RT" <bug-podlators@rt.cpan.org> writes: Show quoted text
> I have a bunch of =item lines that contain multi-word tags with many > embedded color changes (generated by B<words> and I<words> elements).
Show quoted text
> I observe that when my formatted POD is output to an xterm, text in open > paragraphs manages to use the Pod::Text::Termcap::wrap() routine, and > the characters comprising escape sequences for color changes embedded in > that text do not cause early wrapping. However, for some reason the > text in my =item tags seems to be processed instead by > Pod::Text::wrap(), meaning I get wrapping much too soon in this text.
Thank you, and thanks for the reproducible test case! I tracked this one down too, although it was elusive. The correct wrap routine was being called, but due to a subtle error in the rather complicated regex used to wrap text with embeded escape sequences, it wasn't recognizing the end of the string and thought it had to wrap. This problem also affected Pod::Text::Color, since it used a very similar regex, and will be fixed in the next release. -- #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD, 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{ rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
From: eponymousalias [...] yahoo.com
On Sun Feb 18 15:45:47 2018, RRA wrote: Show quoted text
> "eponymous alias via RT" <bug-podlators@rt.cpan.org> writes: >
> > I have a bunch of =item lines that contain multi-word tags with many > > embedded color changes (generated by B<words> and I<words> elements).
>
> > I observe that when my formatted POD is output to an xterm, text in open > > paragraphs manages to use the Pod::Text::Termcap::wrap() routine, and > > the characters comprising escape sequences for color changes embedded in > > that text do not cause early wrapping. However, for some reason the > > text in my =item tags seems to be processed instead by > > Pod::Text::wrap(), meaning I get wrapping much too soon in this text.
> > Thank you, and thanks for the reproducible test case! I tracked this one > down too, although it was elusive. The correct wrap routine was being > called, but due to a subtle error in the rather complicated regex used to > wrap text with embeded escape sequences, it wasn't recognizing the end of > the string and thought it had to wrap. > > This problem also affected Pod::Text::Color, since it used a very similar > regex, and will be fixed in the next release.
I'm very happy to see these corrections going in. So much so, that I just downloaded the current GitHub copy (pre-v4.11) and tried it out. It's working well now for the reported problems. That said, I observe a residual issue, that of sometimes losing color when a long =item line is wrapped and the output is run through certain pagers. Here is a variety of test lines so you can see when the problem does and does not occur. =over 4 =item B<autosetup status> [B<-t>] {B<-a>|[B<-e>|B<-f>|B<-u>] I<hostname> ...} =item B<autosetup validate> I<hostname> ... =item B<autosetup install -p> I<patternfile> I<hostname> ... =item B<autosetup print analysis> [B<-e>|B<-f>|B<-u>] I<hostname> ... =item B<autosetup install -p standard_test_only_trigger host1 host2 host3> =back When that last item in particular gets wrapped because the terminal window is not wide enough to contain the entire item (say, only 60 characters wide, set by an explicit width option in the Pod::Text::Termcap constructor), the second and later lines of that item may lose their coloring. The issue seems to be that if the content enclosed in my B<> formatting code contains a space character, then if the wrapping breaks on such a space, the coloring may be lost. I suppose the same would be true with I<>. Here is the raw wrapped text being displayed, with escape characters made visible as ESC: ESC[1mautosetup install -p standard_test_only_trigger host1 host2 host3ESC[0m I'm using an xterm and piping the output to "less -R", and that's the context where the problem shows up. "more -f" doesn't have this problem. This is clearly an issue most directly attributable to the pager, not to Pod::Text::Termcap. But you may want to consider some defensive measures, namely if a wrap occurs while $$self{BOLD} or $$self{UNDL} is in effect, close out that line with $$self{NORM} and start the next line (after leading spaces) with the $$self{BOLD} or $$self{UNDL} that was previously in effect. To be precise, this problem is happening with both less version 436, which is present in both RHEL 5.11 and CentOS 6.9, and with less version 458, which is present in CentOS 7.4.1708 (the most current CentOS release). I have also downloaded, compiled, and tested less version 530, the current upstream release (2018-02-17), and it behaves the same way. I suppose a bug could be filed on that end as well. But these older versions of the pager will be with us for a long time, so having the Perl package be extra-careful seems like a sensible precaution.
Subject: Re: [rt.cpan.org #124447] Pod::Text::Termcap explicit width control is faulty
Date: Sun, 18 Mar 2018 13:13:06 -0700
To: "eponymous alias via RT" <bug-podlators [...] rt.cpan.org>
From: Russ Allbery <eagle [...] eyrie.org>
"eponymous alias via RT" <bug-podlators@rt.cpan.org> writes: Show quoted text
> That said, I observe a residual issue, that of sometimes losing color > when a long =item line is wrapped and the output is run through certain > pagers. Here is a variety of test lines so you can see when the problem > does and does not occur.
[...] Show quoted text
> I'm using an xterm and piping the output to "less -R", and that's the > context where the problem shows up. "more -f" doesn't have this > problem. This is clearly an issue most directly attributable to the > pager, not to Pod::Text::Termcap. But you may want to consider some > defensive measures, namely if a wrap occurs while $$self{BOLD} or > $$self{UNDL} is in effect, close out that line with $$self{NORM} and > start the next line (after leading spaces) with the $$self{BOLD} or > $$self{UNDL} that was previously in effect.
Thanks for this report! Indeed, this is a know property of some pagers: they clear all text attributes at the end of each line. I think it's a tradeoff between accurately showing the document and avoiding corrupted output. It took me a few weeks to get to this, but I've now put in place the fix you suggest, for both Pod::Text::Termcap and Pod::Text::Color, and have pushed the patch up to GitHub. (I'm not 100% happy with the text surgery that I used to do it, but I couldn't quickly think of a better approach and it should work.) -- Russ Allbery (eagle@eyrie.org) <http://www.eyrie.org/~eagle/>
Subject: Re: [rt.cpan.org #124447] Pod::Text::Termcap explicit width control is faulty
Date: Tue, 1 May 2018 06:41:06 +0000 (UTC)
To: <bug-podlators [...] rt.cpan.org>
From: eponymous alias <eponymousalias [...] yahoo.com>
On Sun, 3/18/18, Russ Allbery via RT <bug-podlators@rt.cpan.org> wrote: Show quoted text
> > That said, I observe a residual issue, that of sometimes losing color > > when a long =item line is wrapped and the output is run through certain > > pagers.
> > [...] > > It took me a few weeks to get to this, but I've now put in place the fix > you suggest, for both Pod::Text::Termcap and Pod::Text::Color, and have > pushed the patch up to GitHub. (I'm not 100% happy with the text surgery > that I used to do it, but I couldn't quickly think of a better approach > and it should work.)
I have downloaded and installed the current GitHub code and run a few quick tests. It's not a full test suite or anything, but it's at least working fine in the context I see.
Fixed in 4.11.