12 |
|
# to the desired routines |
13 |
|
# usegroupchecker(groupchecker) : Set a groupchecker |
14 |
|
# parse() : Parse the file |
15 |
– |
# checkparam($name,$par) : Exit with an error message if parameter |
16 |
– |
# is undefined in tag $name |
15 |
|
# line() : return the current line number of the parse |
16 |
|
# stream(filehandle) : stream output to the filehandle if not handled |
17 |
|
# in any other way |
38 |
|
$self->{stream}=shift; |
39 |
|
} |
40 |
|
|
41 |
+ |
sub streamexclude { |
42 |
+ |
my $self=shift; |
43 |
+ |
my $tag=shift; |
44 |
+ |
|
45 |
+ |
$tag=~tr/A-Z/a-z/; |
46 |
+ |
$self->{streamexclude}{$tag}=1; |
47 |
+ |
} |
48 |
+ |
|
49 |
|
sub _initialise (hash1) { |
50 |
|
my $self=shift; |
51 |
|
$self->{filename}=shift; |
82 |
|
$self->{linecount}=0; |
83 |
|
$self->_resetvars(); |
84 |
|
$self->{streamstore}=""; |
85 |
+ |
$self->{streamtmp}=""; |
86 |
|
|
87 |
|
# Open the file |
88 |
|
use FileHandle; |
106 |
|
$self->_printstream(); |
107 |
|
} |
108 |
|
|
102 |
– |
sub checkparam($name, $key) { |
103 |
– |
my $self=shift; |
104 |
– |
my $name=shift; |
105 |
– |
my $key=shift; |
106 |
– |
|
107 |
– |
if ( ! defined $self->{tagvar}{$key} ) { |
108 |
– |
print "Switcher: Badly formed $name tag -". |
109 |
– |
" undefined $key parameter\n"; |
110 |
– |
exit 1; |
111 |
– |
} |
112 |
– |
} |
113 |
– |
|
109 |
|
# |
110 |
|
# return the current line number |
111 |
|
# |
173 |
|
my $char; |
174 |
|
|
175 |
|
# Close the last text segment |
176 |
+ |
$self->{streamtmp}=$self->_popstream(); |
177 |
|
$self->_calltag($self->{textcontext}, $self->{textcontext}, |
178 |
|
$self->_getstore()); |
179 |
|
$self->_resetstore(); |
180 |
|
$self->_resetlabels(); |
181 |
|
|
186 |
– |
$self->{scramtmp}=$self->_popstream(); |
182 |
|
# Do we have an opening or closing tag? |
183 |
|
if ( ($char=$self->_nextchar()) eq "/" ) { #we have a closing tag |
184 |
|
$self->{tagcontext}="endtag"; |
253 |
|
} |
254 |
|
} |
255 |
|
|
256 |
< |
if ( ! $found ) { |
256 |
> |
# stream function |
257 |
> |
if ( ! exists $self->{streamexclude}{$tagroutine} ) { |
258 |
|
$self->_printstream(); |
259 |
|
} |
260 |
|
$self->_clearstream(); |
354 |
|
sub _resetlabels { |
355 |
|
my $self=shift; |
356 |
|
undef $self->{tagvar}; |
357 |
+ |
undef $self->{tagname}; |
358 |
|
} |
359 |
|
|
360 |
|
sub _closelabel { |
366 |
|
$self->{lastlabel}=""; |
367 |
|
} |
368 |
|
elsif ( $self->_getstore() ne "") { |
369 |
< |
#Then it must be the tag name |
370 |
< |
($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/; |
369 |
> |
# Then it must be the tag name |
370 |
> |
if ( ! defined $self->{tagname} ) { |
371 |
> |
($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/; |
372 |
> |
} |
373 |
> |
else { |
374 |
> |
die "Tag syntax error in $self->{tagname} on ".$self->line()."\n". |
375 |
> |
"of file $self->{filename}"; |
376 |
> |
} |
377 |
|
} |
378 |
|
$self->_resetstore(); |
379 |
|
} |