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) - add javascript parameter to escape modifier (Monte)
- added correct line numbers to syntax error messages - added correct line numbers to syntax error messages
in compiler (Monte) in compiler (Monte)

View File

@@ -1605,7 +1605,7 @@ function _run_insert_handler($args)
if($handle = @opendir($dirname)) { if($handle = @opendir($dirname)) {
while ($entry = readdir($handle)) { while (null != ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..') { if ($entry != '.' && $entry != '..') {
if (@is_dir($dirname . DIR_SEP . $entry)) { if (@is_dir($dirname . DIR_SEP . $entry)) {
$this->_rmdir($dirname . DIR_SEP . $entry, $level + 1, $exp_time); $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+\%'; $this->_svar_regexp = '\%\w+\.\w+\%';
// matches all valid variables (no quotes, no modifiers) // 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: // matches valid modifier syntax:
// |foo // |foo
@@ -116,7 +117,8 @@ class Smarty_Compiler extends Smarty {
// |foo:"bar":$foobar // |foo:"bar":$foobar
// |foo|bar // |foo|bar
// |foo // |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: // matches valid variable syntax:
// $foo // $foo
@@ -164,7 +166,8 @@ class Smarty_Compiler extends Smarty {
// "text" // "text"
// "text"|bar // "text"|bar
// $foo->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: // matches valid parenthesised function parameters:
// //
@@ -180,7 +183,8 @@ class Smarty_Compiler extends Smarty {
// foo_bar($foo) // foo_bar($foo)
// _foo_bar($foo,"bar") // _foo_bar($foo,"bar")
// foo123($foo,$foo->bar(),"foo") // 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('/(?> preg_match_all('/(?>
' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call
' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string ' . $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 \b\w+\b | # valid word token
\S+ # anything else \S+ # anything else
)/x', $tag_args, $match); )/x', $tag_args, $match);
@@ -989,57 +993,65 @@ class Smarty_Compiler extends Smarty {
$token = &$tokens[$i]; $token = &$tokens[$i];
switch ($token) { switch ($token) {
case 'eq': case '!':
case '%':
case '!==':
case '==': case '==':
case '>':
case '<':
case '!=':
case '<=':
case '>=':
case '&&':
case '||':
case '|':
case '^':
case '&':
case '~':
case ')':
case ',':
break;
case 'eq':
$token = '=='; $token = '==';
break; break;
case 'ne': case 'ne':
case 'neq': case 'neq':
case '!=':
case '!==':
$token = '!='; $token = '!=';
break; break;
case 'lt': case 'lt':
case '<':
$token = '<'; $token = '<';
break; break;
case 'le': case 'le':
case 'lte': case 'lte':
case '<=':
$token = '<='; $token = '<=';
break; break;
case 'gt': case 'gt':
case '>':
$token = '>'; $token = '>';
break; break;
case 'ge': case 'ge':
case 'gte': case 'gte':
case '>=':
$token = '>='; $token = '>=';
break; break;
case 'and': case 'and':
case '&&':
$token = '&&'; $token = '&&';
break; break;
case 'or': case 'or':
case '||':
$token = '||'; $token = '||';
break; break;
case 'not': case 'not':
case '!':
$token = '!'; $token = '!';
break; break;
case 'mod': case 'mod':
case '%':
$token = '%'; $token = '%';
break; break;
@@ -1074,10 +1086,6 @@ class Smarty_Compiler extends Smarty {
$i = $is_arg_start; $i = $is_arg_start;
break; break;
case ')':
case ',':
break;
default: default:
if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) { if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) {
// function call // function call

View File

@@ -1605,7 +1605,7 @@ function _run_insert_handler($args)
if($handle = @opendir($dirname)) { if($handle = @opendir($dirname)) {
while ($entry = readdir($handle)) { while (null != ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..') { if ($entry != '.' && $entry != '..') {
if (@is_dir($dirname . DIR_SEP . $entry)) { if (@is_dir($dirname . DIR_SEP . $entry)) {
$this->_rmdir($dirname . DIR_SEP . $entry, $level + 1, $exp_time); $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+\%'; $this->_svar_regexp = '\%\w+\.\w+\%';
// matches all valid variables (no quotes, no modifiers) // 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: // matches valid modifier syntax:
// |foo // |foo
@@ -116,7 +117,8 @@ class Smarty_Compiler extends Smarty {
// |foo:"bar":$foobar // |foo:"bar":$foobar
// |foo|bar // |foo|bar
// |foo // |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: // matches valid variable syntax:
// $foo // $foo
@@ -164,7 +166,8 @@ class Smarty_Compiler extends Smarty {
// "text" // "text"
// "text"|bar // "text"|bar
// $foo->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: // matches valid parenthesised function parameters:
// //
@@ -180,7 +183,8 @@ class Smarty_Compiler extends Smarty {
// foo_bar($foo) // foo_bar($foo)
// _foo_bar($foo,"bar") // _foo_bar($foo,"bar")
// foo123($foo,$foo->bar(),"foo") // 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('/(?> preg_match_all('/(?>
' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*) | # valid object call
' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*) | # var or quoted string ' . $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 \b\w+\b | # valid word token
\S+ # anything else \S+ # anything else
)/x', $tag_args, $match); )/x', $tag_args, $match);
@@ -989,57 +993,65 @@ class Smarty_Compiler extends Smarty {
$token = &$tokens[$i]; $token = &$tokens[$i];
switch ($token) { switch ($token) {
case 'eq': case '!':
case '%':
case '!==':
case '==': case '==':
case '>':
case '<':
case '!=':
case '<=':
case '>=':
case '&&':
case '||':
case '|':
case '^':
case '&':
case '~':
case ')':
case ',':
break;
case 'eq':
$token = '=='; $token = '==';
break; break;
case 'ne': case 'ne':
case 'neq': case 'neq':
case '!=':
case '!==':
$token = '!='; $token = '!=';
break; break;
case 'lt': case 'lt':
case '<':
$token = '<'; $token = '<';
break; break;
case 'le': case 'le':
case 'lte': case 'lte':
case '<=':
$token = '<='; $token = '<=';
break; break;
case 'gt': case 'gt':
case '>':
$token = '>'; $token = '>';
break; break;
case 'ge': case 'ge':
case 'gte': case 'gte':
case '>=':
$token = '>='; $token = '>=';
break; break;
case 'and': case 'and':
case '&&':
$token = '&&'; $token = '&&';
break; break;
case 'or': case 'or':
case '||':
$token = '||'; $token = '||';
break; break;
case 'not': case 'not':
case '!':
$token = '!'; $token = '!';
break; break;
case 'mod': case 'mod':
case '%':
$token = '%'; $token = '%';
break; break;
@@ -1074,10 +1086,6 @@ class Smarty_Compiler extends Smarty {
$i = $is_arg_start; $i = $is_arg_start;
break; break;
case ')':
case ',':
break;
default: default:
if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) { if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) {
// function call // function call