fix if statement syntax for negative integers, fix issue with directories

named '0'
This commit is contained in:
mohrt
2003-01-15 15:23:13 +00:00
parent 11a81370c7
commit 450e15dd8e
5 changed files with 67 additions and 50 deletions

1
NEWS
View File

@@ -1,3 +1,4 @@
- fixed bug with directories named '0' (Frank Bauer, Monte)
- add javascript parameter to escape modifier (Monte)
- added correct line numbers to syntax error messages
in compiler (Monte)

View File

@@ -1605,7 +1605,7 @@ function _run_insert_handler($args)
if($handle = @opendir($dirname)) {
while ($entry = readdir($handle)) {
while (null != ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..') {
if (@is_dir($dirname . DIR_SEP . $entry)) {
$this->_rmdir($dirname . DIR_SEP . $entry, $level + 1, $exp_time);

View File

@@ -106,7 +106,8 @@ class Smarty_Compiler extends Smarty {
$this->_svar_regexp = '\%\w+\.\w+\%';
// matches all valid variables (no quotes, no modifiers)
$this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|' . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
$this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
. $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
// matches valid modifier syntax:
// |foo
@@ -116,7 +117,8 @@ class Smarty_Compiler extends Smarty {
// |foo:"bar":$foobar
// |foo|bar
// |foo
$this->_mod_regexp = '(?:\|@?\w+(?::(?>\w+|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
$this->_mod_regexp = '(?:\|@?\w+(?::(?>\w+|'
. $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
// matches valid variable syntax:
// $foo
@@ -164,7 +166,8 @@ class Smarty_Compiler extends Smarty {
// "text"
// "text"|bar
// $foo->bar()
$this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
$this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
. $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
// matches valid parenthesised function parameters:
//
@@ -180,7 +183,8 @@ class Smarty_Compiler extends Smarty {
// foo_bar($foo)
// _foo_bar($foo,"bar")
// foo123($foo,$foo->bar(),"foo")
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' . $this->_parenth_param_regexp . '))';
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
. $this->_parenth_param_regexp . '))';
}
@@ -969,7 +973,7 @@ class Smarty_Compiler extends Smarty {
preg_match_all('/(?>
' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call
' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string
\d+|!==|<=>|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
\-?\d+|!==|<=>|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
\b\w+\b | # valid word token
\S+ # anything else
)/x', $tag_args, $match);
@@ -989,57 +993,65 @@ class Smarty_Compiler extends Smarty {
$token = &$tokens[$i];
switch ($token) {
case 'eq':
case '!':
case '%':
case '!==':
case '==':
case '>':
case '<':
case '!=':
case '<=':
case '>=':
case '&&':
case '||':
case '|':
case '^':
case '&':
case '~':
case ')':
case ',':
break;
case 'eq':
$token = '==';
break;
case 'ne':
case 'neq':
case '!=':
case '!==':
$token = '!=';
break;
case 'lt':
case '<':
$token = '<';
break;
case 'le':
case 'lte':
case '<=':
$token = '<=';
break;
case 'gt':
case '>':
$token = '>';
break;
case 'ge':
case 'gte':
case '>=':
$token = '>=';
break;
case 'and':
case '&&':
$token = '&&';
break;
case 'or':
case '||':
$token = '||';
break;
case 'not':
case '!':
$token = '!';
break;
case 'mod':
case '%':
$token = '%';
break;
@@ -1074,10 +1086,6 @@ class Smarty_Compiler extends Smarty {
$i = $is_arg_start;
break;
case ')':
case ',':
break;
default:
if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) {
// function call

View File

@@ -1605,7 +1605,7 @@ function _run_insert_handler($args)
if($handle = @opendir($dirname)) {
while ($entry = readdir($handle)) {
while (null != ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..') {
if (@is_dir($dirname . DIR_SEP . $entry)) {
$this->_rmdir($dirname . DIR_SEP . $entry, $level + 1, $exp_time);

View File

@@ -106,7 +106,8 @@ class Smarty_Compiler extends Smarty {
$this->_svar_regexp = '\%\w+\.\w+\%';
// matches all valid variables (no quotes, no modifiers)
$this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|' . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
$this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
. $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
// matches valid modifier syntax:
// |foo
@@ -116,7 +117,8 @@ class Smarty_Compiler extends Smarty {
// |foo:"bar":$foobar
// |foo|bar
// |foo
$this->_mod_regexp = '(?:\|@?\w+(?::(?>\w+|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
$this->_mod_regexp = '(?:\|@?\w+(?::(?>\w+|'
. $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
// matches valid variable syntax:
// $foo
@@ -164,7 +166,8 @@ class Smarty_Compiler extends Smarty {
// "text"
// "text"|bar
// $foo->bar()
$this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
$this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
. $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
// matches valid parenthesised function parameters:
//
@@ -180,7 +183,8 @@ class Smarty_Compiler extends Smarty {
// foo_bar($foo)
// _foo_bar($foo,"bar")
// foo123($foo,$foo->bar(),"foo")
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' . $this->_parenth_param_regexp . '))';
$this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
. $this->_parenth_param_regexp . '))';
}
@@ -969,7 +973,7 @@ class Smarty_Compiler extends Smarty {
preg_match_all('/(?>
' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call
' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string
\d+|!==|<=>|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
\-?\d+|!==|<=>|==|!=|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|<|>|\||\% | # valid non-word token
\b\w+\b | # valid word token
\S+ # anything else
)/x', $tag_args, $match);
@@ -989,57 +993,65 @@ class Smarty_Compiler extends Smarty {
$token = &$tokens[$i];
switch ($token) {
case 'eq':
case '!':
case '%':
case '!==':
case '==':
case '>':
case '<':
case '!=':
case '<=':
case '>=':
case '&&':
case '||':
case '|':
case '^':
case '&':
case '~':
case ')':
case ',':
break;
case 'eq':
$token = '==';
break;
case 'ne':
case 'neq':
case '!=':
case '!==':
$token = '!=';
break;
case 'lt':
case '<':
$token = '<';
break;
case 'le':
case 'lte':
case '<=':
$token = '<=';
break;
case 'gt':
case '>':
$token = '>';
break;
case 'ge':
case 'gte':
case '>=':
$token = '>=';
break;
case 'and':
case '&&':
$token = '&&';
break;
case 'or':
case '||':
$token = '||';
break;
case 'not':
case '!':
$token = '!';
break;
case 'mod':
case '%':
$token = '%';
break;
@@ -1074,10 +1086,6 @@ class Smarty_Compiler extends Smarty {
$i = $is_arg_start;
break;
case ')':
case ',':
break;
default:
if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) {
// function call