15 |
|
# file() : return the filename corresponding to url of the document |
16 |
|
# ProcessedFile() : return the filename corresponding to processed url |
17 |
|
# of the document |
18 |
< |
# line(number) : Return the line and fileobj corresponding to number in |
18 |
> |
# realline(number): Return the line and fileobj corresponding to number in |
19 |
|
# processed file |
20 |
|
# update() : update the preprocessed file as required. |
21 |
|
# store(filename) : |
36 |
|
"", $self, "", $self); |
37 |
|
} |
38 |
|
|
39 |
< |
sub line { |
39 |
> |
sub realline { |
40 |
|
my $self=shift; |
41 |
|
my $origline=shift; |
42 |
|
|
45 |
|
for(my $i=0; $i<=$#{$self->{includesdesc}}; $i++ ) { |
46 |
|
$inc=$self->{includesdesc}[$i]; |
47 |
|
$startline=$inc->startline(); |
48 |
< |
last if ( $line < $startline ); |
49 |
< |
if ( $line > ($inc->lines()+$startline) ) { |
50 |
< |
$line=$line-$inc->lines()+1+($inc->endline()-$startline); |
48 |
> |
last if ( $line <= $startline ); |
49 |
> |
if ( $line >= ($inc->lines()+$startline+2) ) { |
50 |
> |
# take out the 2 carriage returns added |
51 |
> |
$line=$line-($inc->lines()+$startline-$inc->endline())-2; |
52 |
|
# n lines in original map to m lines in expanded |
53 |
|
} |
54 |
|
else { # must be in the include file |
55 |
< |
($line, $fileob)=$self->{includes}[$i]-> |
56 |
< |
line($line-$startline+1); |
55 |
> |
($line, $fileob)=$self->{includes}[$i]->realline($line-$startline); |
56 |
> |
last; |
57 |
|
} |
58 |
|
} |
59 |
|
|
60 |
|
return ($line, $fileob); |
61 |
|
} |
62 |
|
|
63 |
+ |
sub line { |
64 |
+ |
my $self=shift; |
65 |
+ |
my $line=$self->{currentparser}->line(); |
66 |
+ |
return $line, $self; |
67 |
+ |
} |
68 |
+ |
|
69 |
|
sub url { |
70 |
|
my $self=shift; |
71 |
|
|
72 |
|
if ( @_ ) { |
73 |
< |
my $url=shift; |
74 |
< |
($self->{url}, $file)=$self->{urlhandler}->get($url); |
75 |
< |
} |
76 |
< |
else { |
77 |
< |
$self->{url}; |
78 |
< |
} |
73 |
> |
my $url=shift; |
74 |
> |
($self->{url}, $file)=$self->{urlhandler}->get($url); |
75 |
> |
} |
76 |
> |
else { |
77 |
> |
$self->{url}; |
78 |
> |
} |
79 |
|
} |
80 |
|
|
81 |
|
sub ProcessedFile { |
87 |
|
my $self=shift; |
88 |
|
|
89 |
|
my ($url, $file)=$self->{urlhandler}->get($self->url()); |
90 |
+ |
$self->verbose("Getting file ".$self->url()." = $file"); |
91 |
|
return $file; |
92 |
|
} |
93 |
|
|
94 |
+ |
sub ProcessFile { |
95 |
+ |
my $self=shift; |
96 |
+ |
return $self->file(); |
97 |
+ |
} |
98 |
|
|
99 |
|
sub update { |
100 |
|
my $self=shift; |
126 |
|
} |
127 |
|
|
128 |
|
if ( $rv != 0 ) { |
129 |
< |
print " Need to Update ".$self->url()."\n"; |
129 |
> |
$self->verbose(" Need to Update ".$self->url()); |
130 |
|
# ---- sort out the preprocessed file in the cache |
131 |
< |
my $newfile=$self->config()->cache()-> |
120 |
< |
filename($outfile); |
131 |
> |
my $newfile=$self->config()->cache()->filename($outfile); |
132 |
|
$self->config()->cache()->store($outfile,$newfile); |
133 |
|
|
134 |
|
$self->process($self->config()->cache()->file($self->url()),$newfile); |
137 |
|
$self->config->store($self,$self->url()); |
138 |
|
} |
139 |
|
else { |
140 |
< |
print "No Need to Update ".$self->url()."\n"; |
140 |
> |
$self->verbose("No Need to Update ".$self->url()); |
141 |
|
} |
142 |
|
return $rv; |
143 |
|
} |
162 |
|
$self->parse("include", $self->{fileout}, "include_starttag"); |
163 |
|
|
164 |
|
$self->{fileout}->close(); |
165 |
+ |
$self->verbose("$fileout Created"); |
166 |
|
} |
167 |
|
|
168 |
|
sub store { |