ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/Switcher.pm
(Generate patch)

Comparing COMP/SCRAM/src/ActiveDoc/Switcher.pm (file contents):
Revision 1.13 by williamc, Wed Mar 1 11:48:11 2000 UTC vs.
Revision 1.16 by williamc, Tue Nov 14 15:20:55 2000 UTC

# Line 105 | Line 105 | sub parse {
105           } # end char while
106          } # End String while loop
107          undef $filehandle;
108 <        $self->_printstream();
108 >        # make sure we close the last buffer
109 >        $self->_calltag($self->{textcontext}, $self->{textcontext},
110 >                                                        $self->_getstore());
111 >        #$self->_printstream();
112   }
113  
114   #
# Line 146 | Line 149 | sub _checkchar {
149  
150          # ---- In a tag
151          if ( $self->{tagcontext}=~/tag/ ) {
152 +           $self->{tagbuff}=$self->{tagbuff}.$char;
153             if ( ! $self->_quotetest($char) ) {
154              if ( ! $self->_labeltest($char) ) {
155               if ( $char eq ">") { $self->_closetag(); }
# Line 168 | Line 172 | sub _nextchar() {
172          my $self=shift;
173          my $char;
174          $char=substr($self->{currentline},$self->{stringpos}++,1);
175 < #       print "Debug : Fetching character $char\n";
175 >        #print "Debug : Fetching character $char\n";
176  
177          # Keep a record for any stream processes
178          $self->{streamstore}=$self->{streamstore}.$char;
# Line 192 | Line 196 | sub _opentag {
196  
197          # Do we have an opening or closing tag?
198          if ( ($char=$self->_nextchar()) eq "/" ) { #we have a closing tag
199 +          $self->{tagbuff}="<".$char;
200            $self->{tagcontext}="endtag";
201          }
202          else { # an opening tag
203 +          $self->{tagbuff}="<";
204            $self->{tagcontext}="starttag";
205            $self->_checkchar($char);
206          }
# Line 220 | Line 226 | sub _closetag {
226  
227           # -- Now make sure the text context is set for calling routines to
228           # -- deal with text portions outside of tags
229 <         if ( $self->{tagcontext} eq "starttag" ) {
230 <          push @{$self->{textstack}} , $self->{textcontext};
231 <          $self->{textcontext}=$self->{tagname};
229 >         if ( ($self->{tagcontext} eq "starttag") ) {
230 >           if ( $self->{tagcontainer}->definescontext($self->{tagname}) ) {
231 >              push @{$self->{textstack}} , $self->{textcontext};
232 >              $self->{textcontext}=$self->{tagname};
233 >           }
234           }
235           else {
236            if ( $#{$self->{textstack}} > -1 ) {
237 <            if ( $self->{textcontext} eq $self->{tagname} ) {  
238 <               $self->{textcontext}=pop @{$self->{textstack}};
239 <            }
237 >           if ( $self->{textcontext} eq $self->{tagname} ) {    
238 >            if ( $self->{tagcontainer}->definescontext($self->{tagname}) ) {
239 >              # -- watch out for valid tags we ignore in this parse
240 >              $self->{textcontext}=pop @{$self->{textstack}};
241 >            }
242 >           }
243              else { #The tag we are closing is not the last one so
244                     # we keep our current context.
245                 $self->_removefromstack($self->{tagname},$self->{textstack});
# Line 236 | Line 247 | sub _closetag {
247  
248            }
249            else { # more close tags than open ones
250 +            if ( $self->{tagcontainer}->definescontext($self->{tagname}) ) {
251               print "Warning : Unmatched </...> tag on line ".
252                                          $self->line()."\n";    
253 +            }
254            }
255           }
256          }
# Line 375 | Line 388 | sub _closelabel {
388  
389          # Do we have a label name?
390          if ( $self->{lastlabel} ne "" ) {
391 <         $self->{tagvar}{$self->{lastlabel}}=$self->_getstore();
391 >         (my $label=$self->{lastlabel})=~tr[A-Z][a-z];
392 >         $self->{tagvar}{$label}=$self->_getstore();
393           $self->{lastlabel}="";
394          }
395          elsif ( $self->_getstore() ne "") {
# Line 384 | Line 398 | sub _closelabel {
398              ($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/;
399           }
400           else {
401 <            die ">Tag syntax error in $self->{tagname} on line ".
402 <                $self->line()." of file \n$self->{filename}";
401 >            # do not die anymore - breaks non tag documents
402 >            #die ">Tag syntax error in $self->{tagname} on line ".
403 >            #   $self->line()." of file \n$self->{filename}";
404 >            # -- assume that this is plain text
405 >            $self->{tagcontext}="text";
406 >            $self->_resetstore();
407 >            $self->_unshiftstore($self->{tagbuff});
408 >            $self->{tagbuff}="";
409 >            return;
410           }
411          }
412          $self->_resetstore();
# Line 401 | Line 422 | sub _putstore() {
422          $self->{stringbuff}=$self->{stringbuff}.$char;
423   }
424  
425 + sub _unshiftstore() {
426 +        my $self=shift;
427 +        my $char=shift;
428 +
429 +        $self->{stringbuff}=$char.$self->{stringbuff};
430 + }
431 +
432   sub _getstore() {
433          my $self=shift;
434  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines