[Templates-cvs] cvs commit: Template2/lib/Template Parser.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 06/05/25 11:43:40
Modified: lib/Template Parser.pm
Log:
Fixed a bug in line counting - we were counting newlines in the preceeding text twice.
Revision Changes Path
2.86 +13 -16 Template2/lib/Template/Parser.pm
Index: Parser.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Parser.pm,v
retrieving revision 2.85
retrieving revision 2.86
diff -u -r2.85 -r2.86
--- Parser.pm 2006/05/25 08:22:39 2.85
+++ Parser.pm 2006/05/25 11:43:39 2.86
@@ -30,7 +30,7 @@
# specified in the Perl README file.
#
# REVISION
-# $Id: Parser.pm,v 2.85 2006/05/25 08:22:39 abw Exp $
+# $Id: Parser.pm,v 2.86 2006/05/25 11:43:39 abw Exp $
#
#============================================================================
@@ -50,7 +50,7 @@
use constant ERROR => 2;
use constant ABORT => 3;
-our $VERSION = sprintf("%d.%02d", q$Revision: 2.85 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = sprintf("%d.%02d", q$Revision: 2.86 $ =~ /(\d+)\.(\d+)/);
our $DEBUG = 0 unless defined $DEBUG;
our $ERROR = '';
@@ -305,9 +305,9 @@
$pre = '' unless defined $pre;
$dir = '' unless defined $dir;
- $postlines = 0; # denotes lines chomped
- $prelines = ($pre =~ tr/\n//); # NULL - count only
- $dirlines = ($dir =~ tr/\n//); # ditto
+ $prelines = ($pre =~ tr/\n//); # newlines in preceeding text
+ $dirlines = ($dir =~ tr/\n//); # newlines in directive tag
+ $postlines = 0; # newlines chomped after tag
for ($dir) {
if (/^\#/) {
@@ -322,16 +322,13 @@
if ($chomp && $pre) {
# chomp off whitespace and newline preceding directive
if ($chomp == CHOMP_ALL) {
- $pre =~ s{ (\n|^) [^\S\n]* \z }{}mx
- && $1 eq "\n" && $prelines++;
+ $pre =~ s{ (\n|^) [^\S\n]* \z }{}mx;
}
elsif ($chomp == CHOMP_COLLAPSE) {
- $pre =~ s{ (\s+) \z }{ }x
- && ($prelines += $1=~y/\n//);
+ $pre =~ s{ (\s+) \z }{ }x;
}
elsif ($chomp == CHOMP_GREEDY) {
- $pre =~ s{ (\s+) \z }{}x
- && ($prelines += $1=~y/\n//);
+ $pre =~ s{ (\s+) \z }{}x;
}
}
}
@@ -1421,9 +1418,9 @@
=head1 AUTHOR
-Andy Wardley E<lt>abw@andywardley.comE<gt>
+Andy Wardley E<lt>abw@wardley.orgE<gt>
-L<http://www.andywardley.com/|http://www.andywardley.com/>
+L<http://wardley.org/|http://wardley.org/>
@@ -1432,14 +1429,14 @@
=head1 VERSION
-2.83, distributed as part of the
-Template Toolkit version 2.15, released on 30 January 2006.
+2.84, distributed as part of the
+Template Toolkit version 2.14a, released on 02 February 2006.
=head1 COPYRIGHT
- Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
+ Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or