This commit is contained in:
uwetews
2016-11-07 03:08:11 +01:00
parent 2d2be8f57f
commit c4746e9080
9 changed files with 159 additions and 159 deletions

View File

@@ -1,4 +1,7 @@
===== 3.1.31-dev ===== (xx.xx.xx)
07.11.2016
- optimization of lexer speed https://github.com/smarty-php/smarty/issues/311
27.10.2016
- bugfix template function definitions array has not been cached between Smarty::fetch() and Smarty::display() calls
https://github.com/smarty-php/smarty/issues/301

View File

@@ -25,7 +25,13 @@ class Smarty_Internal_Configfilelexer
* @var string
*/
public $data;
/**
/**
* Source length
*
* @var int
*/
public $dataLenght = null;
/**
* byte counter
*
* @var int
@@ -120,9 +126,8 @@ class Smarty_Internal_Configfilelexer
*/
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
{
// set instance object
self::instance($this);
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->dataLenght = strlen($data);
$this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
$this->counter += strlen($match[0]);
@@ -133,15 +138,6 @@ class Smarty_Internal_Configfilelexer
$this->configBooleanize = $this->smarty->config_booleanize;
}
public static function &instance($new_instance = null)
{
static $instance = null;
if (isset($new_instance) && is_object($new_instance)) {
$instance = $new_instance;
}
return $instance;
}
public function PrintTrace()
{
$this->yyTraceFILE = fopen('php://output', 'w');

View File

@@ -91,8 +91,6 @@ class Smarty_Internal_Configfileparser
*/
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
{
// set instance object
self::instance($this);
$this->lex = $lex;
$this->smarty = $compiler->smarty;
$this->compiler = $compiler;
@@ -100,20 +98,6 @@ class Smarty_Internal_Configfileparser
$this->configReadHidden = $this->smarty->config_read_hidden;
}
/**
* @param null $new_instance
*
* @return null
*/
public static function &instance($new_instance = null)
{
static $instance = null;
if (isset($new_instance) && is_object($new_instance)) {
$instance = $new_instance;
}
return $instance;
}
/**
* parse optional boolean keywords
*

View File

@@ -25,6 +25,13 @@ class Smarty_Internal_Templatelexer
*/
public $data;
/**
* Source length
*
* @var int
*/
public $dataLenght = null;
/**
* byte counter
*
@@ -225,6 +232,7 @@ class Smarty_Internal_Templatelexer
function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->data = $data;
$this->dataLenght = strlen($data);
$this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
$this->counter += strlen($match[0]);
@@ -366,7 +374,7 @@ class Smarty_Internal_Templatelexer
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
text {
$to = strlen($this->data);
$to = $this->dataLenght;
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
@@ -606,7 +614,7 @@ class Smarty_Internal_Templatelexer
}
}
text {
$to = strlen($this->data);
$to = $this->dataLenght;
preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
@@ -670,7 +678,7 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
text {
$to = strlen($this->data);
$to = $this->dataLenght;
$this->value = substr($this->data,$this->counter,$to-$this->counter);
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}

View File

@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.31-dev/40';
const SMARTY_VERSION = '3.1.31-dev/41';
/**
* define variable scopes

View File

@@ -111,11 +111,11 @@ class Smarty_Internal_Config_File_Compiler
$this->smarty->_debug->start_compile($this->template);
}
// init the lexer/parser to compile the config file
/* @var Smarty_Internal_ConfigFileLexer $lex */
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
/* @var Smarty_Internal_ConfigFileLexer $this->lex */
$this->lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
$this);
/* @var Smarty_Internal_ConfigFileParser $parser */
$parser = new $this->parser_class($lex, $this);
/* @var Smarty_Internal_ConfigFileParser $this->parser */
$this->parser = new $this->parser_class($this->lex, $this);
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
@@ -125,17 +125,17 @@ class Smarty_Internal_Config_File_Compiler
}
if ($this->smarty->_parserdebug) {
$parser->PrintTrace();
$this->parser->PrintTrace();
}
// get tokens from lexer and parse them
while ($lex->yylex()) {
while ($this->lex->yylex()) {
if ($this->smarty->_parserdebug) {
echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
echo "<br>Parsing {$this->parser->yyTokenName[$this->lex->token]} Token {$this->lex->value} Line {$this->lex->line} \n";
}
$parser->doParse($lex->token, $lex->value);
$this->parser->doParse($this->lex->token, $this->lex->value);
}
// finish parsing process
$parser->doParse(0, 0);
$this->parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
@@ -166,8 +166,6 @@ class Smarty_Internal_Config_File_Compiler
*/
public function trigger_config_file_error($args = null)
{
$this->lex = Smarty_Internal_Configfilelexer::instance();
$this->parser = Smarty_Internal_Configfileparser::instance();
// get config source line which has error
$line = $this->lex->line;
if (isset($args)) {

View File

@@ -28,6 +28,13 @@ class Smarty_Internal_Configfilelexer
*/
public $data;
/**
* Source length
*
* @var int
*/
public $dataLenght = null;
/**
* byte counter
*
@@ -109,7 +116,7 @@ class Smarty_Internal_Configfilelexer
/**
* storage for assembled token patterns
*
* @var sring
* @var string
*/
private $yy_global_pattern1 = null;
@@ -139,9 +146,8 @@ class Smarty_Internal_Configfilelexer
*/
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
{
// set instance object
self::instance($this);
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->dataLenght = strlen($data);
$this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
$this->counter += strlen($match[ 0 ]);
@@ -152,15 +158,6 @@ class Smarty_Internal_Configfilelexer
$this->configBooleanize = $this->smarty->config_booleanize;
}
public static function &instance($new_instance = null)
{
static $instance = null;
if (isset($new_instance) && is_object($new_instance)) {
$instance = $new_instance;
}
return $instance;
}
public function PrintTrace()
{
$this->yyTraceFILE = fopen('php://output', 'w');
@@ -223,17 +220,19 @@ class Smarty_Internal_Configfilelexer
$this->yy_global_pattern1 =
"/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -255,7 +254,7 @@ class Smarty_Internal_Configfilelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -328,17 +327,19 @@ class Smarty_Internal_Configfilelexer
$this->yy_global_pattern2 =
"/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -360,7 +361,7 @@ class Smarty_Internal_Configfilelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -452,17 +453,19 @@ class Smarty_Internal_Configfilelexer
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -484,7 +487,7 @@ class Smarty_Internal_Configfilelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -512,17 +515,19 @@ class Smarty_Internal_Configfilelexer
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -544,7 +549,7 @@ class Smarty_Internal_Configfilelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -584,17 +589,19 @@ class Smarty_Internal_Configfilelexer
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -616,7 +623,7 @@ class Smarty_Internal_Configfilelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -650,17 +657,19 @@ class Smarty_Internal_Configfilelexer
if (!isset($this->yy_global_pattern6)) {
$this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -682,7 +691,7 @@ class Smarty_Internal_Configfilelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token

View File

@@ -168,8 +168,6 @@ class Smarty_Internal_Configfileparser
*/
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
{
// set instance object
self::instance($this);
$this->lex = $lex;
$this->smarty = $compiler->smarty;
$this->compiler = $compiler;
@@ -177,20 +175,6 @@ class Smarty_Internal_Configfileparser
$this->configReadHidden = $this->smarty->config_read_hidden;
}
/**
* @param null $new_instance
*
* @return null
*/
public static function &instance($new_instance = null)
{
static $instance = null;
if (isset($new_instance) && is_object($new_instance)) {
$instance = $new_instance;
}
return $instance;
}
/**
* parse optional boolean keywords
*
@@ -736,7 +720,7 @@ class Smarty_Internal_Configfileparser
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
#line 255 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 239 "../smarty/lexer/smarty_internal_configfileparser.y"
$this->internalError = true;
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
@@ -771,27 +755,27 @@ class Smarty_Internal_Configfileparser
6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14,
15 => 15, 16 => 16, 17 => 17, 18 => 17,);
#line 261 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r0()
{
$this->_retvalue = null;
}
#line 266 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r1()
{
$this->add_global_vars($this->yystack[ $this->yyidx + 0 ]->minor);
$this->_retvalue = null;
}
#line 280 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 264 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r4()
{
$this->add_section_vars($this->yystack[ $this->yyidx + - 3 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor);
$this->_retvalue = null;
}
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r5()
{
if ($this->configReadHidden) {
@@ -801,75 +785,75 @@ class Smarty_Internal_Configfileparser
$this->_retvalue = null;
}
#line 293 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r6()
{
$this->_retvalue = $this->yystack[ $this->yyidx + - 1 ]->minor;
}
#line 297 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r7()
{
$this->_retvalue =
array_merge($this->yystack[ $this->yyidx + - 1 ]->minor, Array($this->yystack[ $this->yyidx + 0 ]->minor));
}
#line 301 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r8()
{
$this->_retvalue = Array();
}
#line 307 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r9()
{
$this->_retvalue = Array("key" => $this->yystack[ $this->yyidx + - 2 ]->minor,
"value" => $this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r10()
{
$this->_retvalue = (float) $this->yystack[ $this->yyidx + 0 ]->minor;
}
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r11()
{
$this->_retvalue = (int) $this->yystack[ $this->yyidx + 0 ]->minor;
}
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r12()
{
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r13()
{
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 328 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r14()
{
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
}
#line 332 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r15()
{
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + - 1 ]->minor);
}
#line 336 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r16()
{
$this->_retvalue = '';
}
#line 340 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
function yy_r17()
{
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
@@ -927,7 +911,7 @@ class Smarty_Internal_Configfileparser
public function yy_syntax_error($yymajor, $TOKEN)
{
#line 248 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 232 "../smarty/lexer/smarty_internal_configfileparser.y"
$this->internalError = true;
$this->yymajor = $yymajor;
@@ -942,7 +926,7 @@ class Smarty_Internal_Configfileparser
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
#line 241 "../smarty/lexer/smarty_internal_configfileparser.y"
#line 225 "../smarty/lexer/smarty_internal_configfileparser.y"
$this->successful = !$this->internalError;
$this->internalError = false;

View File

@@ -25,6 +25,13 @@ class Smarty_Internal_Templatelexer
*/
public $data;
/**
* Source length
*
* @var int
*/
public $dataLenght = null;
/**
* byte counter
*
@@ -202,6 +209,7 @@ class Smarty_Internal_Templatelexer
function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->data = $data;
$this->dataLenght = strlen($data);
$this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
$this->counter += strlen($match[ 0 ]);
@@ -291,17 +299,19 @@ class Smarty_Internal_Templatelexer
")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -323,7 +333,7 @@ class Smarty_Internal_Templatelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -405,7 +415,7 @@ class Smarty_Internal_Templatelexer
function yy_r1_19()
{
$to = strlen($this->data);
$to = $this->dataLenght;
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i",
$this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[ 0 ][ 1 ])) {
@@ -426,17 +436,19 @@ class Smarty_Internal_Templatelexer
$this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
"\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -458,7 +470,7 @@ class Smarty_Internal_Templatelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -567,17 +579,19 @@ class Smarty_Internal_Templatelexer
$this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel .
"\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+(is\\s+(not\\s+)?(odd|even|div)\\s+by)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -599,7 +613,7 @@ class Smarty_Internal_Templatelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -912,17 +926,19 @@ class Smarty_Internal_Templatelexer
"/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
$this->rdel . ")|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -944,7 +960,7 @@ class Smarty_Internal_Templatelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -982,7 +998,7 @@ class Smarty_Internal_Templatelexer
function yy_r4_3()
{
$to = strlen($this->data);
$to = $this->dataLenght;
preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE,
$this->counter);
if (isset($match[ 0 ][ 1 ])) {
@@ -1004,17 +1020,19 @@ class Smarty_Internal_Templatelexer
"\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
$this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
if (!isset($this->dataLenght)) {
$this->dataLenght = strlen($this->data);
}
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
@@ -1036,7 +1054,7 @@ class Smarty_Internal_Templatelexer
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= strlen($this->data)) {
if ($this->counter >= $this->dataLenght) {
return false; // end of input
}
// skip this token
@@ -1141,7 +1159,7 @@ class Smarty_Internal_Templatelexer
function yy_r5_14()
{
$to = strlen($this->data);
$to = $this->dataLenght;
$this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}