Skip to content

Commit

Permalink
Merge branch 'openbsd'
Browse files Browse the repository at this point in the history
  • Loading branch information
briandfoy committed Dec 18, 2011
2 parents a9d61b4 + 6d0f641 commit ef28e6a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 21 deletions.
19 changes: 11 additions & 8 deletions lib/Pod/Perldoc/BaseTo.pm
Expand Up @@ -25,13 +25,14 @@ sub TRUE () {1}
sub FALSE () {return}

BEGIN {
*is_vms = $^O eq 'VMS' ? \&TRUE : \&FALSE unless defined &is_vms;
*is_mswin32 = $^O eq 'MSWin32' ? \&TRUE : \&FALSE unless defined &is_mswin32;
*is_dos = $^O eq 'dos' ? \&TRUE : \&FALSE unless defined &is_dos;
*is_os2 = $^O eq 'os2' ? \&TRUE : \&FALSE unless defined &is_os2;
*is_cygwin = $^O eq 'cygwin' ? \&TRUE : \&FALSE unless defined &is_cygwin;
*is_linux = $^O eq 'linux' ? \&TRUE : \&FALSE unless defined &is_linux;
*is_hpux = $^O =~ m/hpux/ ? \&TRUE : \&FALSE unless defined &is_hpux;
*is_vms = $^O eq 'VMS' ? \&TRUE : \&FALSE unless defined &is_vms;
*is_mswin32 = $^O eq 'MSWin32' ? \&TRUE : \&FALSE unless defined &is_mswin32;
*is_dos = $^O eq 'dos' ? \&TRUE : \&FALSE unless defined &is_dos;
*is_os2 = $^O eq 'os2' ? \&TRUE : \&FALSE unless defined &is_os2;
*is_cygwin = $^O eq 'cygwin' ? \&TRUE : \&FALSE unless defined &is_cygwin;
*is_linux = $^O eq 'linux' ? \&TRUE : \&FALSE unless defined &is_linux;
*is_hpux = $^O =~ m/hpux/ ? \&TRUE : \&FALSE unless defined &is_hpux;
*is_openbsd = $^O =~ m/openbsd/ ? \&TRUE : \&FALSE unless defined &is_openbsd;
}

sub _perldoc_elem {
Expand All @@ -44,7 +45,9 @@ sub _perldoc_elem {
}

sub debugging {
defined(&Pod::Perldoc::DEBUG) and &Pod::Perldoc::DEBUG()
my( $self, @messages ) = @_;

( defined(&Pod::Perldoc::DEBUG) and &Pod::Perldoc::DEBUG() )
}

sub debug {
Expand Down
51 changes: 38 additions & 13 deletions lib/Pod/Perldoc/ToMan.pm
Expand Up @@ -61,12 +61,10 @@ sub init {
}

sub _roffer_candidates {
# OpenBSD is weird, and I'm punting for the moment. Using
# nroff will work just like it did before, but openbsd
# people won't get the benefit of the UTF-8 fixes.
#
if( $^O eq 'openbsd' ) { qw( nroff ) }
else { qw( groff nroff mandoc ) }
my( $self ) = @_;

if( $self->is_openbsd ) { qw( mandoc groff nroff ) }
else { qw( groff nroff mandoc ) }
}

sub _find_roffer {
Expand Down Expand Up @@ -172,9 +170,10 @@ sub _save_pod_man_output {

$fh = do {
my $file = "podman.out.$$.txt";
$self->debug( "Writing $file with Pod::Man output\n" );
open my $fh2, '>', $file;
$fh2;
} unless $fh;
$self->debug( "Writing $file with Pod::Man output\n" );

print { $fh } ${ $self->{_text_ref} };
}
Expand All @@ -196,13 +195,38 @@ sub _have_groff_with_utf8 {
$self->warn(
"You have an old groff." .
" Update to version $minimum_groff_version for good Unicode support.\n" .
"If you don't upgrade, wide characters may come out oddly.\n",
"If you don't upgrade, wide characters may come out oddly.\n"
);
}

$version gt $minimum_groff_version;
}

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 gt $minimum_mandoc_version;
}

sub _collect_nroff_switches {
my( $self ) = shift;

Expand All @@ -229,11 +253,12 @@ sub _collect_nroff_switches {
sub _get_device_switches {
my( $self ) = @_;

if( $self->_is_nroff ) { qw() }
elsif( $self->_have_groff_with_utf8 ) { qw(-Kutf8 -Tutf8) }
elsif( $self->_is_mandoc ) { qw(-Tutf8) }
elsif( $self->_is_ebcdic ) { qw(-Tcp1047) }
else { qw(-Tlatin1) }
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->_is_mandoc ) { qw() }
else { qw(-Tlatin1) }
}

sub _is_roff {
Expand Down

0 comments on commit ef28e6a

Please sign in to comment.