cvs: smarty /libs Smarty_Compiler.class.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1082104480@cvsserver>
messju		Fri Apr 16 04:34:40 2004 EDT

  Modified files:              
    /smarty/libs	Smarty_Compiler.class.php 
  Log:
  enabled numerical constants be parsed as statements.
  (like {10} or {10|@range:12} )
  
  
  
http://cvs.php.net/diff.php/smarty/libs/Smarty_Compiler.class.php?r1=1.317&r2=1.318&ty=u
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.317 smarty/libs/Smarty_Compiler.class.php:1.318
--- smarty/libs/Smarty_Compiler.class.php:1.317	Fri Apr 16 04:30:10 2004
+++ smarty/libs/Smarty_Compiler.class.php	Fri Apr 16 04:34:39 2004
@@ -26,7 +26,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.317 2004/04/16 08:30:10 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.318 2004/04/16 08:34:39 messju Exp $ */
 
 /**
  * Template compiling class
@@ -105,6 +105,8 @@
         // $foo[$bar]
         // $foo[5][blah]
         // $foo[5].bar[$foobar][4]
+        $this->_num_const_regexp = '\-?\d+(?:\.\d+)?';
+
         $this->_dvar_math_regexp = '[\+\-\*\/\%]';
         $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]';
         $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
@@ -131,7 +133,7 @@
         // #foo#
         // "text"
         // "text"
-        $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')';
+        $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_num_const_regexp . '|' . $this->_qstr_regexp . ')';
 
         // matches valid object call (no objects allowed in parameters):
         // $foo->bar
@@ -1589,6 +1591,14 @@
                 }
                 return $return;
             }
+        elseif(preg_match('!^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
+                // numerical constant
+                preg_match('!^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);
+                if($match[2] != '') {
+                    $this->_parse_modifiers($match[1], $match[2]);
+                    return $match[1];
+                }
+            }
         elseif(preg_match('!^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) {
                 // single quoted text
                 preg_match('!^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match);

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.