From 3f0821ed62ed929469376e8cebbb431c4c2592f8 Mon Sep 17 00:00:00 2001 From: messju Date: Sat, 19 Apr 2003 10:12:18 +0000 Subject: [PATCH] enabled hex-constants (0x...) as function-attributes, inside if-statements and as modifier-parameters --- NEWS | 5 ++++- libs/Smarty_Compiler.class.php | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 672157a3..21d1a949 100644 --- a/NEWS +++ b/NEWS @@ -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, diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 268e14bc..fce49215 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -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 */