mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
Fixed line number reporting when removing comments.
This commit is contained in:
4
NEWS
4
NEWS
@@ -1,4 +1,6 @@
|
||||
- made html_options output xhtml compatible (Monte, Arnaud Limbourg)
|
||||
- added fix for removing comments so that the line numbers are reported
|
||||
correctly in case of errors. (patch from Anders Janson)
|
||||
- made html_options output xhtml compatible code. (Monte, Arnaud Limbourg)
|
||||
|
||||
Version 1.4.5
|
||||
-------------
|
||||
|
@@ -80,11 +80,9 @@ class Smarty_Compiler extends Smarty {
|
||||
$rdq = preg_quote($this->right_delimiter, '!');
|
||||
|
||||
/* Annihilate the comments. */
|
||||
if (preg_match_all("!{$ldq}\*.*?\*{$rdq}!s", $template_source, $match)) {
|
||||
foreach ($match[0] as $comment)
|
||||
$this->_current_line_no += substr_count($comment, "\n");
|
||||
$template_source = preg_replace("!{$ldq}\*.*?\*{$rdq}!s", '', $template_source);
|
||||
}
|
||||
$template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
|
||||
"'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
|
||||
$template_source);
|
||||
|
||||
/* Pull out the literal blocks. */
|
||||
preg_match_all("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $template_source, $match);
|
||||
@@ -175,6 +173,10 @@ class Smarty_Compiler extends Smarty {
|
||||
\*======================================================================*/
|
||||
function _compile_tag($template_tag)
|
||||
{
|
||||
/* Matched comment. */
|
||||
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
|
||||
return '';
|
||||
|
||||
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
|
||||
|
||||
/* Split tag into two parts: command and the arguments. */
|
||||
|
@@ -80,11 +80,9 @@ class Smarty_Compiler extends Smarty {
|
||||
$rdq = preg_quote($this->right_delimiter, '!');
|
||||
|
||||
/* Annihilate the comments. */
|
||||
if (preg_match_all("!{$ldq}\*.*?\*{$rdq}!s", $template_source, $match)) {
|
||||
foreach ($match[0] as $comment)
|
||||
$this->_current_line_no += substr_count($comment, "\n");
|
||||
$template_source = preg_replace("!{$ldq}\*.*?\*{$rdq}!s", '', $template_source);
|
||||
}
|
||||
$template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
|
||||
"'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
|
||||
$template_source);
|
||||
|
||||
/* Pull out the literal blocks. */
|
||||
preg_match_all("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $template_source, $match);
|
||||
@@ -175,6 +173,10 @@ class Smarty_Compiler extends Smarty {
|
||||
\*======================================================================*/
|
||||
function _compile_tag($template_tag)
|
||||
{
|
||||
/* Matched comment. */
|
||||
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
|
||||
return '';
|
||||
|
||||
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
|
||||
|
||||
/* Split tag into two parts: command and the arguments. */
|
||||
|
Reference in New Issue
Block a user