enabled hex-constants (0x...) as function-attributes, inside

if-statements and as modifier-parameters
This commit is contained in:
messju
2003-04-19 10:12:18 +00:00
parent aa7d2b3418
commit 3f0821ed62
2 changed files with 7 additions and 4 deletions

5
NEWS
View File

@@ -1,4 +1,7 @@
- fixed bug with passing $smarty as reference in Smarty.compiler.class (messju)
- enabled hex-constants (0x...) as function-attributes, inside if-statements
and as modifier-parameters (messju)
- fixed bug with passing $smarty as reference in Smarty.compiler.class
(messju)
- corrected output with {strip} and PHP tag newlines (Monte)
- added possibility to register function-callbacks as "array(&$obj, 'method)"
this affects register_function(), -block, -compiler_function, -modifier,

View File

@@ -157,7 +157,7 @@ class Smarty_Compiler extends Smarty {
// |foo:"bar":$foobar
// |foo|bar
// |foo:$foo->bar
$this->_mod_regexp = '(?:\|@?\w+(?::(?>\w+|'
$this->_mod_regexp = '(?:\|@?\w+(?::(?>-?\w+|'
. $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
// matches valid function name:
@@ -1103,7 +1103,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+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
\-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
\b\w+\b | # valid word token
\S+ # anything else
)/x', $tag_args, $match);
@@ -1367,7 +1367,7 @@ class Smarty_Compiler extends Smarty {
$token = 'false';
} else if ($token == 'null') {
$token = 'null';
} else if (preg_match('!^-?[0-9]+$!', $token)) {
} else if (preg_match('!^-?([0-9]+|0[xX][0-9a-fA-F]+)$!', $token)) {
/* treat integer literally */
} else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$!', $token)) {
/* treat as a string, double-quote it escaping quotes */