16 |
@ISA = qw(WAIT::Document::Base); |
@ISA = qw(WAIT::Document::Base); |
17 |
require WAIT::Document::Base; |
require WAIT::Document::Base; |
18 |
|
|
19 |
use FileHandle; |
use IO::File; |
20 |
|
use IO::Zlib; |
21 |
use strict; |
use strict; |
22 |
#use diagnostics; |
#use diagnostics; |
23 |
use Carp; |
use Carp; |
52 |
|
|
53 |
return undef unless -f $path; |
return undef unless -f $path; |
54 |
|
|
55 |
my $fh = new FileHandle "< $path"; |
my $fh; |
56 |
|
if ($path =~ m/\.gz$/i) { |
57 |
|
$fh = new IO::Zlib("$path","rb"); |
58 |
|
} else { |
59 |
|
$fh = new IO::File "< $path"; |
60 |
|
} |
61 |
return undef unless defined $fh; |
return undef unless defined $fh; |
62 |
my $first = <$fh>; |
my $first = <$fh>; |
63 |
$fh->close; |
$fh->close; |
65 |
return undef unless defined $first; |
return undef unless defined $first; |
66 |
$first =~ /\'\\\"\s.*((e)|(t))+/; |
$first =~ /\'\\\"\s.*((e)|(t))+/; |
67 |
my @pre; |
my @pre; |
68 |
|
my $pipe; |
69 |
|
if ($path =~ m/\.gz$/i) { |
70 |
|
$pipe .= 'gzip -cd'; |
71 |
|
} else { |
72 |
|
$pipe .= 'cat'; |
73 |
|
} |
74 |
|
$pipe .= " $path |"; |
75 |
push @pre, 'eqn -Tascii' if $2; |
push @pre, 'eqn -Tascii' if $2; |
76 |
push @pre, 'tbl' if $3; |
push @pre, 'tbl' if $3; |
77 |
push @pre, $self->{Pipe}; |
push @pre, $self->{Pipe}; |
|
my $pipe = pop(@pre) . " $path |"; |
|
78 |
if (@pre) { |
if (@pre) { |
79 |
$pipe .= join ('|', @pre) . '|';; |
$pipe .= join ('|', @pre) . '|';; |
80 |
} |
} |
81 |
local($/) = undef; |
local($/) = undef; |
82 |
$fh = new FileHandle "$pipe"; |
$fh = new IO::File "$pipe"; |
83 |
return unless defined $fh; |
return unless defined $fh; |
84 |
<$fh>; |
<$fh>; |
85 |
} |
} |
93 |
local($/) = undef; |
local($/) = undef; |
94 |
|
|
95 |
if (-e $catp) { |
if (-e $catp) { |
96 |
my $fh = new FileHandle "< $catp"; |
my $fh; |
97 |
|
if ($path =~ m/\.gz$/) { |
98 |
|
$fh = new IO::Zlib("$path","rb"); |
99 |
|
} else { |
100 |
|
$fh = new IO::File "< $path"; |
101 |
|
} |
102 |
return <$fh>; |
return <$fh>; |
103 |
} |
} |
104 |
my $cont = $self->nroff($path); |
my $cont = $self->nroff($path); |
105 |
if ($cont) { |
if ($cont) { |
106 |
my $fh = new FileHandle "> $catp"; |
my $fh = new IO::File "> $catp"; |
107 |
if ($fh) { |
if ($fh) { |
108 |
warn "Generating $catp\n"; |
warn "Generating $catp\n"; |
109 |
$fh->print($cont); |
$fh->print($cont); |