Fixed line number reporting when removing comments.

This commit is contained in:
andrey
2001-09-25 21:34:08 +00:00
parent b52e7d9c68
commit f77824eef5
3 changed files with 17 additions and 11 deletions

4
NEWS
View File

@@ -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 Version 1.4.5
------------- -------------

View File

@@ -80,11 +80,9 @@ class Smarty_Compiler extends Smarty {
$rdq = preg_quote($this->right_delimiter, '!'); $rdq = preg_quote($this->right_delimiter, '!');
/* Annihilate the comments. */ /* Annihilate the comments. */
if (preg_match_all("!{$ldq}\*.*?\*{$rdq}!s", $template_source, $match)) { $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
foreach ($match[0] as $comment) "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
$this->_current_line_no += substr_count($comment, "\n"); $template_source);
$template_source = preg_replace("!{$ldq}\*.*?\*{$rdq}!s", '', $template_source);
}
/* Pull out the literal blocks. */ /* Pull out the literal blocks. */
preg_match_all("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $template_source, $match); 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) function _compile_tag($template_tag)
{ {
/* Matched comment. */
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
return '';
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; $qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
/* Split tag into two parts: command and the arguments. */ /* Split tag into two parts: command and the arguments. */

View File

@@ -80,11 +80,9 @@ class Smarty_Compiler extends Smarty {
$rdq = preg_quote($this->right_delimiter, '!'); $rdq = preg_quote($this->right_delimiter, '!');
/* Annihilate the comments. */ /* Annihilate the comments. */
if (preg_match_all("!{$ldq}\*.*?\*{$rdq}!s", $template_source, $match)) { $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
foreach ($match[0] as $comment) "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
$this->_current_line_no += substr_count($comment, "\n"); $template_source);
$template_source = preg_replace("!{$ldq}\*.*?\*{$rdq}!s", '', $template_source);
}
/* Pull out the literal blocks. */ /* Pull out the literal blocks. */
preg_match_all("!{$ldq}literal{$rdq}(.*?){$ldq}/literal{$rdq}!s", $template_source, $match); 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) function _compile_tag($template_tag)
{ {
/* Matched comment. */
if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
return '';
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; $qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
/* Split tag into two parts: command and the arguments. */ /* Split tag into two parts: command and the arguments. */