Skip Menu |

This queue is for tickets about the Pod-Perldoc CPAN distribution.

Report information
The Basics
Id: 85844
Status: resolved
Priority: 0/
Queue: Pod-Perldoc

People
Owner: Nobody in particular
Requestors: schwarze [...] usta.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Let mandoc(1) produce UTF-8 output only if the user's locale asks for it.
Date: Tue, 4 Jun 2013 03:13:55 +0200
To: bug-Pod-Perldoc [...] rt.cpan.org
From: Ingo Schwarze <schwarze [...] usta.de>
Hello, when using mandoc(1) as its groffer, perldoc(1) unconditionally uses the -Tutf8 output mode. That mode is defined to produce UTF-8 output no matter what the user's locale is. So there is no way for a user to have perldoc(1) _not_ throw UTF-8 at him or her... I just committed a minimal fix to OpenBSD's in-tree perl to use -Tlocale instead of -Tutf8, which will only use UTF-8 when the user's locale requests it, and ASCII otherwise. Reading the mandoc-related code in Pod::Perldoc::ToMan, i noticed some more opportunity for cleanup, so i will likely send a larger patch shortly. Feel free to either pull this minimal fix straight away or to wait for the larger patch, as you like. Thanks for maintaining Perldoc, Ingo P.S. Appending some info about my system, just in case, even though i don't expect it to be relevant in this context... -- Ingo Schwarze <schwarze@openbsd.org> mandoc co-author and maintainer ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 ----- From: Ingo Schwarze <schwarze@openbsd.org> Date: Mon, 3 Jun 2013 19:24:16 -0400 Subject: [PATCH] Let mandoc(1) produce UTF-8 output only if the user's locale asks for it. --- lib/Pod/Perldoc/ToMan.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Pod/Perldoc/ToMan.pm b/lib/Pod/Perldoc/ToMan.pm index 80a944c..52fc2e8 100644 --- a/lib/Pod/Perldoc/ToMan.pm +++ b/lib/Pod/Perldoc/ToMan.pm @@ -263,7 +263,7 @@ sub _get_device_switches { if( $self->_is_nroff ) { qw() } elsif( $self->_have_groff_with_utf8 ) { qw(-Kutf8 -Tutf8) } elsif( $self->_is_ebcdic ) { qw(-Tcp1047) } - elsif( $self->_have_mandoc_with_utf8 ) { qw(-Tutf8) } + elsif( $self->_have_mandoc_with_utf8 ) { qw(-Tlocale) } elsif( $self->_is_mandoc ) { qw() } else { qw(-Tlatin1) } } -- 1.8.2.2 ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 ----- ischwarze@isnote $ pwd /usr/src/gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod ischwarze@isnote $ grep 'VERSION =' Perldoc.pm $VERSION = '3.17'; ischwarze@isnote $ perl -v | head -n2 | tail -n1 This is perl 5, version 16, subversion 3 (v5.16.3) built for i386-openbsd ischwarze@isnote $ uname -a OpenBSD isnote.usta.de 5.3 GENERIC.MP#5 i386 However, the above patch has been prepared using git clone and then working on branch master.
On Mon Jun 03 21:14:20 2013, schwarze@usta.de wrote: Show quoted text
> I just committed a minimal fix to OpenBSD's in-tree perl > to use -Tlocale instead of -Tutf8, which will only use UTF-8 > when the user's locale requests it, and ASCII otherwise.
Thanks. I didn't know about that behavior. Show quoted text
> Reading the mandoc-related code in Pod::Perldoc::ToMan, i noticed > some more opportunity for cleanup, so i will likely send a larger > patch shortly. Feel free to either pull this minimal fix straight > away or to wait for the larger patch, as you like.
I have several other things to fix up, so if you don't mind I would like to wait for the larger patch. Show quoted text
> Thanks for maintaining Perldoc,
Thanks for sending me a patch to maintain perldoc :)
On Mon Jun 03 21:14:20 2013, schwarze@usta.de wrote: Show quoted text
> Reading the mandoc-related code in Pod::Perldoc::ToMan, i noticed > some more opportunity for cleanup, so i will likely send a larger > patch shortly. Feel free to either pull this minimal fix straight > away or to wait for the larger patch, as you like.
Hi - just following up on this ticket. I committed your minimal patch to the tree tonight as f433439 (I haven't pushed it yet) Did you ever get around to the larger clean up patch you referenced last summer? Thanks. Mark
Subject: Re: [rt.cpan.org #85844] [PATCH] Let mandoc(1) produce UTF-8 output only if the user's locale asks for it.
Date: Fri, 24 Jan 2014 10:22:39 +0100
To: Mark Allen via RT <bug-Pod-Perldoc [...] rt.cpan.org>
From: Ingo Schwarze <schwarze [...] usta.de>
Hi Mark, Mark Allen via RT wrote on Mon, Jan 13, 2014 at 10:38:03PM -0500: Show quoted text
Show quoted text
> On Mon Jun 03 21:14:20 2013, schwarze@usta.de wrote:
Show quoted text
>> Reading the mandoc-related code in Pod::Perldoc::ToMan, i noticed >> some more opportunity for cleanup, so i will likely send a larger >> patch shortly. Feel free to either pull this minimal fix straight >> away or to wait for the larger patch, as you like.
Show quoted text
> Hi - just following up on this ticket. I committed your minimal patch to > the tree tonight as f433439 (I haven't pushed it yet) > > Did you ever get around to the larger clean up patch you referenced > last summer?
Oh, i actually wrote the patch but got distracted and failed to send it. Sorry about that. So i just rebased and retested it, here it is. I think the commit message says it all. In case of doubt, please just ask! Thank you for the reminder, Ingo P.S. Weird. Now i end up sending you a patch i wrote in Toronto - from Dunedin... ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 ----- commit 34a6a4845206bffa99adb38c8f595ae7c818a19f Author: Ingo Schwarze <schwarze@openbsd.org> Date: Tue Jun 4 16:59:55 2013 -0400 Cleanup code related to mandoc(1). * No need to parse mandoc versions, just ask the program itself whether it can handle -Tlocale. * Remove some dubious advice. Mandoc is only preferred on OpenBSD, and in that environment, i don't think using the groff from ports is better for formatting pod2man(1)-generated manuals than using the mandoc(1) from the base system. * No need to pass -mandoc to mandoc(1), it's the default and will ever be. * No harm done passing -man to mandoc(1), it just works. diff --git a/lib/Pod/Perldoc/ToMan.pm b/lib/Pod/Perldoc/ToMan.pm index 86f45f8..7961ace 100644 --- a/lib/Pod/Perldoc/ToMan.pm +++ b/lib/Pod/Perldoc/ToMan.pm @@ -212,34 +212,13 @@ sub _have_groff_with_utf8 { sub _have_mandoc_with_utf8 { my( $self ) = @_; - return 0 unless $self->_is_mandoc; - my $roffer = $self->__nroffer; - - my $minimum_mandoc_version = '1.11'; - - my $version_string = `$roffer -V`; - my( $version ) = $version_string =~ /mandoc ((\d+)\.(\d+))/; - $self->debug( "Found mandoc $version\n" ); - - # is a string comparison good enough? - if( $version lt $minimum_mandoc_version ) { - $self->warn( - "You have an older mandoc." . - " Update to version $minimum_mandoc_version for better Unicode support.\n" . - "If you don't upgrade, wide characters may come out oddly.\n" . - "Your results still might be odd. If you have groff, that's even better.\n" - ); - } - - $version ge $minimum_mandoc_version; + $self->_is_mandoc and not system 'mandoc -Tlocale -V > /dev/null 2>&1'; } sub _collect_nroff_switches { my( $self ) = shift; - my @render_switches = $self->_is_mandoc ? qw(-mandoc) : qw(-man); - - push @render_switches, $self->_get_device_switches; + my @render_switches = ('-man', $self->_get_device_switches); # Thanks to Brendan O'Dea for contributing the following block if( $self->_is_roff and -t STDOUT and my ($cols) = $self->_get_columns ) {
On Fri Jan 24 04:22:59 2014, schwarze@usta.de wrote: Show quoted text
> Oh, i actually wrote the patch but got distracted and failed > to send it. Sorry about that.
No problem. Committed as 81f3e8c in my tree. (Not pushed yet.) Thanks again. Mark