[Templates-cvs] cvs commit: TT3/lib/Template Scanner.pm

cvs@template-toolkit.org cvs@template-toolkit.org
Thu, 18 Nov 2004 17:03:55 +0000


cvs         04/11/18 17:03:55

  Modified:    lib/Template Scanner.pm
  Log:
  * added code at end of scan() to unwind any nested handlers (e.g. unterminated
    blocks) back to where we started
  
  Revision  Changes    Path
  1.7       +15 -4     TT3/lib/Template/Scanner.pm
  
  Index: Scanner.pm
  ===================================================================
  RCS file: /template-toolkit/TT3/lib/Template/Scanner.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Scanner.pm	2004/11/18 13:39:01	1.6
  +++ Scanner.pm	2004/11/18 17:03:55	1.7
  @@ -20,7 +20,7 @@
   #   Handle multiple lines for nested calls.
   #
   # REVISION
  -#   $Id: Scanner.pm,v 1.6 2004/11/18 13:39:01 abw Exp $
  +#   $Id: Scanner.pm,v 1.7 2004/11/18 17:03:55 abw Exp $
   #
   #========================================================================
   
  @@ -32,7 +32,7 @@
   use Template::Tagset;
   use base qw( Template::Base );
   
  -our $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/);
  +our $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/);
   our $DEBUG   = 0 unless defined $DEBUG;
   our $ERROR   = '';
   our $TAGSET  = 'Template::Tagset';
  @@ -135,6 +135,7 @@
       my $textref = ref $text ? $text : \$text;
       my $lineref = ref $line ? $line : \$line;
       my $texttag = $self->{ text };
  +    my $root    = $handler;
   
       # clear reset flag and initialise start position for first pass 
       $self->{ reset } = 0;
  @@ -272,7 +273,17 @@
           $$lineref += $lines;
       }
   
  -    return $handler;
  +    if ($handler == $root) {
  +        return $handler;
  +    }
  +    else {
  +        # unwind handlers back to where we started
  +        my @errors;
  +        while ($handler && $handler != $root) {
  +            $handler = $handler->terminate(\@errors);
  +        }
  +        return $self->error(join("\n", @errors));
  +    }
   }
   
   
  @@ -380,7 +391,7 @@
   
   =head1 VERSION
   
  -$Revision: 1.6 $
  +$Revision: 1.7 $
   
   =head1 COPYRIGHT