Clean up whitespace.

This commit is contained in:
andrey
2001-10-26 14:15:30 +00:00
parent e5f8cb1e5a
commit 7bb141a0ce
2 changed files with 48 additions and 48 deletions

View File

@@ -47,7 +47,7 @@ class Smarty_Compiler extends Smarty {
var $_current_file = null; // the current template being compiled var $_current_file = null; // the current template being compiled
var $_current_line_no = 1; // line number for error messages var $_current_line_no = 1; // line number for error messages
var $_capture_stack = array(); // keeps track of nested capture buffers var $_capture_stack = array(); // keeps track of nested capture buffers
/*======================================================================*\ /*======================================================================*\
Function: _compile_file() Function: _compile_file()
@@ -62,7 +62,7 @@ class Smarty_Compiler extends Smarty {
$this->php_handling = SMARTY_PHP_PASSTHRU; $this->php_handling = SMARTY_PHP_PASSTHRU;
} }
} }
// run template source through prefilter functions // run template source through prefilter functions
if (is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) { if (is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) {
foreach ($this->prefilter_funcs as $prefilter) { foreach ($this->prefilter_funcs as $prefilter) {
@@ -73,7 +73,7 @@ class Smarty_Compiler extends Smarty {
} }
} }
} }
$this->_current_file = $tpl_file; $this->_current_file = $tpl_file;
$this->_current_line_no = 1; $this->_current_line_no = 1;
$ldq = preg_quote($this->left_delimiter, '!'); $ldq = preg_quote($this->left_delimiter, '!');
@@ -83,7 +83,7 @@ class Smarty_Compiler extends Smarty {
$template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
"'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'", "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
$template_source); $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);
$this->_literal_blocks = $match[1]; $this->_literal_blocks = $match[1];
@@ -94,8 +94,8 @@ class Smarty_Compiler extends Smarty {
preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $match); preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $match);
$this->_php_blocks = $match[1]; $this->_php_blocks = $match[1];
$template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s",
$this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source); $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source);
/* Gather all template tags. */ /* Gather all template tags. */
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $match); preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $match);
$template_tags = $match[1]; $template_tags = $match[1];
@@ -163,10 +163,10 @@ class Smarty_Compiler extends Smarty {
$template_header .= " compiled from ".$tpl_file." */ ?>\n"; $template_header .= " compiled from ".$tpl_file." */ ?>\n";
$template_compiled = $template_header.$template_compiled; $template_compiled = $template_header.$template_compiled;
// remove \n from the end of the file, if any // remove \n from the end of the file, if any
if ( $template_compiled{strlen($template_compiled)-1} == "\n" ) { if ($template_compiled{strlen($template_compiled) - 1} == "\n" ) {
$template_compiled = substr($template_compiled,0,-1); $template_compiled = substr($template_compiled, 0, -1);
} }
// run compiled template through postfilter functions // run compiled template through postfilter functions
if (is_array($this->postfilter_funcs) && count($this->postfilter_funcs) > 0) { if (is_array($this->postfilter_funcs) && count($this->postfilter_funcs) > 0) {
@@ -178,7 +178,7 @@ class Smarty_Compiler extends Smarty {
} }
} }
} }
return true; return true;
} }
@@ -232,10 +232,10 @@ class Smarty_Compiler extends Smarty {
case 'capture': case 'capture':
return $this->_compile_capture_tag(true, $tag_args); return $this->_compile_capture_tag(true, $tag_args);
case '/capture': case '/capture':
return $this->_compile_capture_tag(false); return $this->_compile_capture_tag(false);
case 'ldelim': case 'ldelim':
return $this->left_delimiter; return $this->left_delimiter;
@@ -276,7 +276,7 @@ class Smarty_Compiler extends Smarty {
list (,$php_block) = each($this->_php_blocks); list (,$php_block) = each($this->_php_blocks);
$this->_current_line_no += substr_count($php_block, "\n"); $this->_current_line_no += substr_count($php_block, "\n");
return '<?php '.$php_block.' ?>'; return '<?php '.$php_block.' ?>';
case 'insert': case 'insert':
return $this->_compile_insert_tag($tag_args); return $this->_compile_insert_tag($tag_args);
@@ -355,8 +355,8 @@ class Smarty_Compiler extends Smarty {
} }
return "<?php echo \$this->_run_insert_handler(array(".implode(', ', (array)$arg_list).")); ?>\n"; return "<?php echo \$this->_run_insert_handler(array(".implode(', ', (array)$arg_list).")); ?>\n";
} }
/*======================================================================*\ /*======================================================================*\
Function: _compile_config_load_tag Function: _compile_config_load_tag
@@ -401,7 +401,7 @@ class Smarty_Compiler extends Smarty {
function _compile_include_tag($tag_args) function _compile_include_tag($tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
if (empty($attrs['file'])) { if (empty($attrs['file'])) {
$this->_syntax_error("missing 'file' attribute in include tag"); $this->_syntax_error("missing 'file' attribute in include tag");
} }
@@ -485,7 +485,7 @@ class Smarty_Compiler extends Smarty {
$output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
else else
$output .= "if ({$section_props}['max'] < 0)\n" . $output .= "if ({$section_props}['max'] < 0)\n" .
" {$section_props}['max'] = {$section_props}['loop'];\n"; " {$section_props}['max'] = {$section_props}['loop'];\n";
if (!isset($attrs['step'])) if (!isset($attrs['step']))
$output .= "{$section_props}['step'] = 1;\n"; $output .= "{$section_props}['step'] = 1;\n";
@@ -568,7 +568,7 @@ class Smarty_Compiler extends Smarty {
$is_arg_stack = array(); $is_arg_stack = array();
for ($i = 0; $i < count($tokens); $i++) { for ($i = 0; $i < count($tokens); $i++) {
$token = &$tokens[$i]; $token = &$tokens[$i];
switch ($token) { switch ($token) {
case 'eq': case 'eq':
@@ -644,13 +644,13 @@ class Smarty_Compiler extends Smarty {
current position for the next iteration. */ current position for the next iteration. */
$i = $is_arg_start; $i = $is_arg_start;
break; break;
default: default:
if($this->security && if($this->security &&
$tokens[$i+1] == '(' && $tokens[$i+1] == '(' &&
preg_match('!^[a-zA-Z_]\w+$!', $tokens[$i]) && preg_match('!^[a-zA-Z_]\w+$!', $tokens[$i]) &&
!in_array($tokens[$i], $this->security_settings['IF_FUNCS'])) { !in_array($tokens[$i], $this->security_settings['IF_FUNCS'])) {
$this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement"); $this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement");
} }
break; break;
} }
@@ -731,7 +731,7 @@ class Smarty_Compiler extends Smarty {
function _parse_attrs($tag_args, $quote = true) function _parse_attrs($tag_args, $quote = true)
{ {
/* Tokenize tag attributes. */ /* Tokenize tag attributes. */
preg_match_all('/(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | preg_match_all('/(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\'=\s]+) \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\'=\s]+)
)+ | )+ |
[=] [=]
@@ -797,14 +797,14 @@ class Smarty_Compiler extends Smarty {
return $attrs; return $attrs;
} }
/*======================================================================*\ /*======================================================================*\
Function: _parse_vars_props Function: _parse_vars_props
Purpose: compile variables and section properties tokens into Purpose: compile variables and section properties tokens into
PHP code PHP code
\*======================================================================*/ \*======================================================================*/
function _parse_vars_props(&$tokens) function _parse_vars_props(&$tokens)
{ {
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; $qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
$var_exprs = preg_grep('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); $var_exprs = preg_grep('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens);

View File

@@ -47,7 +47,7 @@ class Smarty_Compiler extends Smarty {
var $_current_file = null; // the current template being compiled var $_current_file = null; // the current template being compiled
var $_current_line_no = 1; // line number for error messages var $_current_line_no = 1; // line number for error messages
var $_capture_stack = array(); // keeps track of nested capture buffers var $_capture_stack = array(); // keeps track of nested capture buffers
/*======================================================================*\ /*======================================================================*\
Function: _compile_file() Function: _compile_file()
@@ -62,7 +62,7 @@ class Smarty_Compiler extends Smarty {
$this->php_handling = SMARTY_PHP_PASSTHRU; $this->php_handling = SMARTY_PHP_PASSTHRU;
} }
} }
// run template source through prefilter functions // run template source through prefilter functions
if (is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) { if (is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) {
foreach ($this->prefilter_funcs as $prefilter) { foreach ($this->prefilter_funcs as $prefilter) {
@@ -73,7 +73,7 @@ class Smarty_Compiler extends Smarty {
} }
} }
} }
$this->_current_file = $tpl_file; $this->_current_file = $tpl_file;
$this->_current_line_no = 1; $this->_current_line_no = 1;
$ldq = preg_quote($this->left_delimiter, '!'); $ldq = preg_quote($this->left_delimiter, '!');
@@ -83,7 +83,7 @@ class Smarty_Compiler extends Smarty {
$template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se",
"'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'", "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'",
$template_source); $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);
$this->_literal_blocks = $match[1]; $this->_literal_blocks = $match[1];
@@ -94,8 +94,8 @@ class Smarty_Compiler extends Smarty {
preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $match); preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $match);
$this->_php_blocks = $match[1]; $this->_php_blocks = $match[1];
$template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s",
$this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source); $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source);
/* Gather all template tags. */ /* Gather all template tags. */
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $match); preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $match);
$template_tags = $match[1]; $template_tags = $match[1];
@@ -163,10 +163,10 @@ class Smarty_Compiler extends Smarty {
$template_header .= " compiled from ".$tpl_file." */ ?>\n"; $template_header .= " compiled from ".$tpl_file." */ ?>\n";
$template_compiled = $template_header.$template_compiled; $template_compiled = $template_header.$template_compiled;
// remove \n from the end of the file, if any // remove \n from the end of the file, if any
if ( $template_compiled{strlen($template_compiled)-1} == "\n" ) { if ($template_compiled{strlen($template_compiled) - 1} == "\n" ) {
$template_compiled = substr($template_compiled,0,-1); $template_compiled = substr($template_compiled, 0, -1);
} }
// run compiled template through postfilter functions // run compiled template through postfilter functions
if (is_array($this->postfilter_funcs) && count($this->postfilter_funcs) > 0) { if (is_array($this->postfilter_funcs) && count($this->postfilter_funcs) > 0) {
@@ -178,7 +178,7 @@ class Smarty_Compiler extends Smarty {
} }
} }
} }
return true; return true;
} }
@@ -232,10 +232,10 @@ class Smarty_Compiler extends Smarty {
case 'capture': case 'capture':
return $this->_compile_capture_tag(true, $tag_args); return $this->_compile_capture_tag(true, $tag_args);
case '/capture': case '/capture':
return $this->_compile_capture_tag(false); return $this->_compile_capture_tag(false);
case 'ldelim': case 'ldelim':
return $this->left_delimiter; return $this->left_delimiter;
@@ -276,7 +276,7 @@ class Smarty_Compiler extends Smarty {
list (,$php_block) = each($this->_php_blocks); list (,$php_block) = each($this->_php_blocks);
$this->_current_line_no += substr_count($php_block, "\n"); $this->_current_line_no += substr_count($php_block, "\n");
return '<?php '.$php_block.' ?>'; return '<?php '.$php_block.' ?>';
case 'insert': case 'insert':
return $this->_compile_insert_tag($tag_args); return $this->_compile_insert_tag($tag_args);
@@ -355,8 +355,8 @@ class Smarty_Compiler extends Smarty {
} }
return "<?php echo \$this->_run_insert_handler(array(".implode(', ', (array)$arg_list).")); ?>\n"; return "<?php echo \$this->_run_insert_handler(array(".implode(', ', (array)$arg_list).")); ?>\n";
} }
/*======================================================================*\ /*======================================================================*\
Function: _compile_config_load_tag Function: _compile_config_load_tag
@@ -401,7 +401,7 @@ class Smarty_Compiler extends Smarty {
function _compile_include_tag($tag_args) function _compile_include_tag($tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
if (empty($attrs['file'])) { if (empty($attrs['file'])) {
$this->_syntax_error("missing 'file' attribute in include tag"); $this->_syntax_error("missing 'file' attribute in include tag");
} }
@@ -485,7 +485,7 @@ class Smarty_Compiler extends Smarty {
$output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
else else
$output .= "if ({$section_props}['max'] < 0)\n" . $output .= "if ({$section_props}['max'] < 0)\n" .
" {$section_props}['max'] = {$section_props}['loop'];\n"; " {$section_props}['max'] = {$section_props}['loop'];\n";
if (!isset($attrs['step'])) if (!isset($attrs['step']))
$output .= "{$section_props}['step'] = 1;\n"; $output .= "{$section_props}['step'] = 1;\n";
@@ -568,7 +568,7 @@ class Smarty_Compiler extends Smarty {
$is_arg_stack = array(); $is_arg_stack = array();
for ($i = 0; $i < count($tokens); $i++) { for ($i = 0; $i < count($tokens); $i++) {
$token = &$tokens[$i]; $token = &$tokens[$i];
switch ($token) { switch ($token) {
case 'eq': case 'eq':
@@ -644,13 +644,13 @@ class Smarty_Compiler extends Smarty {
current position for the next iteration. */ current position for the next iteration. */
$i = $is_arg_start; $i = $is_arg_start;
break; break;
default: default:
if($this->security && if($this->security &&
$tokens[$i+1] == '(' && $tokens[$i+1] == '(' &&
preg_match('!^[a-zA-Z_]\w+$!', $tokens[$i]) && preg_match('!^[a-zA-Z_]\w+$!', $tokens[$i]) &&
!in_array($tokens[$i], $this->security_settings['IF_FUNCS'])) { !in_array($tokens[$i], $this->security_settings['IF_FUNCS'])) {
$this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement"); $this->_syntax_error("(secure mode) '".$tokens[$i]."' not allowed in if statement");
} }
break; break;
} }
@@ -731,7 +731,7 @@ class Smarty_Compiler extends Smarty {
function _parse_attrs($tag_args, $quote = true) function _parse_attrs($tag_args, $quote = true)
{ {
/* Tokenize tag attributes. */ /* Tokenize tag attributes. */
preg_match_all('/(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | preg_match_all('/(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\'=\s]+) \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | (?>[^"\'=\s]+)
)+ | )+ |
[=] [=]
@@ -797,14 +797,14 @@ class Smarty_Compiler extends Smarty {
return $attrs; return $attrs;
} }
/*======================================================================*\ /*======================================================================*\
Function: _parse_vars_props Function: _parse_vars_props
Purpose: compile variables and section properties tokens into Purpose: compile variables and section properties tokens into
PHP code PHP code
\*======================================================================*/ \*======================================================================*/
function _parse_vars_props(&$tokens) function _parse_vars_props(&$tokens)
{ {
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; $qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
$var_exprs = preg_grep('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens); $var_exprs = preg_grep('!^\$\w+(?>(\[(\d+|\w+(\.\w+)?)\])|((\.|->)\w+))*(?>\|@?\w+(:(?>' . $qstr_regexp . '|[^|]+))*)*$!', $tokens);