/[wait]/trunk/lib/WAIT/Document/Nroff.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WAIT/Document/Nroff.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 93 by dpavlin, Mon May 24 13:44:01 2004 UTC revision 94 by dpavlin, Tue May 25 19:13:11 2004 UTC
# Line 16  package WAIT::Document::Nroff; Line 16  package WAIT::Document::Nroff;
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;
# Line 51  sub nroff { Line 52  sub nroff {
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;
# Line 59  sub nroff { Line 65  sub nroff {
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  }  }
# Line 81  sub FETCH { Line 93  sub FETCH {
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);

Legend:
Removed from v.93  
changed lines
  Added in v.94

  ViewVC Help
Powered by ViewVC 1.1.26