Attached is a patch to correct a minor line counting issue in Template::Parser. It can end off by quite a bit under some circumstances.

- Barrie

--- c:\.cpan\build\Template-Toolkit-2.14\lib\Template\Parser.pm 2004-10-04 
06:27:39.000000000 -0400
+++ c:\cygwin\lib\perl5\site_perl\5.8\Template\Parser.pm        2005-12-18 
11:27:02.093750000 -0500
@@ -318,22 +318,21 @@
                 $dir = ($dir =~ /([-+])$/) ? $1 : '';
             }
             else {
                 $chomp = ($1 && $1 eq '+') ? 0 : ($1 || $prechomp);
 #               my $space = $prechomp == &Template::Constants::CHOMP_COLLAPSE 
                 my $space = $prechomp == CHOMP_COLLAPSE 
                     ? ' ' : '';
                 
                 # chomp off whitespace and newline preceding directive
                 $chomp and $pre =~ s/(\n|^)([ \t]*)\Z/($1||$2) ? $space : ''/me
-                    and $1 eq "\n"
-                    and $prelines++;
+                    and $1 eq "\n";
             }
             
             # remove trailing whitespace and check for a '-' chomp flag
             s/\s*([-+])?\s*$//s;
             $chomp = ($1 && $1 eq '+') ? 0 : ($1 || $postchomp);
             my $space = $postchomp == &Template::Constants::CHOMP_COLLAPSE 
                 ? ' ' : '';
             
             $postlines++ 
                 if $chomp and $text =~ s/ 
@@ -343,22 +342,22 @@
                  / 
                  (($1||$2) ? $space : '') . (defined $2 ? $2 : '')
                  /ex;
         }
             
         # any text preceding the directive can now be added
         if (length $pre) {
             push(@tokens, $interp
                  ? [ $pre, $line, 'ITEXT' ]
                  : ('TEXT', $pre) );
-            $line += $prelines;
         }
+        $line += $prelines;
             
         # and now the directive, along with line number information
         if (length $dir) {
             # the TAGS directive is a compile-time switch
             if ($dir =~ /^TAGS\s+(.*)/i) {
                 my @tags = split(/\s+/, $1);
                 if (scalar @tags > 1) {
                     ($start, $end) = map { quotemeta($_) } @tags;
                 }
                 elsif ($tags = $TAG_STYLE->{ $tags[0] }) {

Reply via email to