From 40ea5d89daee1a9f7b9ef52e45530fd8a9fb9a65 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 20 Nov 2017 12:26:48 +0100 Subject: [PATCH] - replacement of " by ' --- change_log.txt | 2 +- lexer/smarty_internal_templatelexer.plex | 2 +- lexer/smarty_internal_templateparser.y | 8 ++-- .../smarty_internal_compile_while.php | 6 +-- .../smarty_internal_configfileparser.php | 7 ++-- .../smarty_internal_templatelexer.php | 2 +- .../smarty_internal_templateparser.php | 38 ++++++++++--------- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/change_log.txt b/change_log.txt index c3bfd8cf..4924f59b 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,7 +2,7 @@ 20.11.2017 - bugfix rework of newline spacing between tag code and template text. now again identical with Smarty2 (forum topic 26878) - - bugfix variable filter might not have been loaded in cache file for use in nocache sections. + - replacement of " by ' 05.11.2017 - lexer/parser optimization diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex index 5908eaa6..95d575ce 100644 --- a/lexer/smarty_internal_templatelexer.plex +++ b/lexer/smarty_internal_templatelexer.plex @@ -530,7 +530,7 @@ class Smarty_Internal_Templatelexer attr { // resolve conflicts with shorttag and right_delimiter starting with '=' if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) { - preg_match("/\s+/",$this->value,$match); + preg_match('/\s+/',$this->value,$match); $this->value = $match[0]; $this->token = Smarty_Internal_Templateparser::TP_SPACE; } else { diff --git a/lexer/smarty_internal_templateparser.y b/lexer/smarty_internal_templateparser.y index 6d6c04b5..45d7b194 100644 --- a/lexer/smarty_internal_templateparser.y +++ b/lexer/smarty_internal_templateparser.y @@ -220,7 +220,7 @@ class Smarty_Internal_Templateparser %stack_overflow { $this->internalError = true; - $this->compiler->trigger_template_error("Stack overflow in template parser"); + $this->compiler->trigger_template_error('Stack overflow in template parser'); } @@ -317,7 +317,7 @@ smartytag(A)::= SIMPLETAG(B). { A = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$tag)); } else { if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) { - A = $this->compiler->compileTag($match[1],array("'nocache'")); + A = $this->compiler->compileTag($match[1],array('\'nocache\'')); } else { A = $this->compiler->compileTag($tag,array()); } @@ -785,7 +785,7 @@ value(res) ::= ns1(c)DOUBLECOLON static_class_access(s). { res = c.'::'.s[0].s[1]; } } else { - $this->compiler->trigger_template_error ("static class '".c."' is undefined or not allowed by security setting"); + $this->compiler->trigger_template_error ('static class \''.c.'\' is undefined or not allowed by security setting'); } } // @@ -1235,7 +1235,7 @@ doublequotedcontent(res) ::= BACKTICK variable(v) BACKTICK. { } doublequotedcontent(res) ::= BACKTICK expr(e) BACKTICK. { - res = new Smarty_Internal_ParseTree_Code('(string)'.e); + res = new Smarty_Internal_ParseTree_Code('(string)('.e.')'); } doublequotedcontent(res) ::= DOLLARID(i). { diff --git a/libs/sysplugins/smarty_internal_compile_while.php b/libs/sysplugins/smarty_internal_compile_while.php index 4689ef9d..328d6551 100644 --- a/libs/sysplugins/smarty_internal_compile_while.php +++ b/libs/sysplugins/smarty_internal_compile_while.php @@ -33,8 +33,8 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase $_attr = $this->getAttributes($compiler, $args); $this->openTag($compiler, 'while', $compiler->nocache); - if (!array_key_exists("if condition", $parameter)) { - $compiler->trigger_template_error("missing while condition", null, true); + if (!array_key_exists('if condition', $parameter)) { + $compiler->trigger_template_error('missing while condition', null, true); } // maybe nocache because of nocache variables @@ -52,7 +52,7 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase $prefixVar = $compiler->getNewPrefixVariable(); $assignCompiler = new Smarty_Internal_Compile_Assign(); $assignAttr = array(); - $assignAttr[][ 'value' ] = "{$prefixVar}"; + $assignAttr[][ 'value' ] = $prefixVar; if (is_array($parameter[ 'if condition' ][ 'var' ])) { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; $_output = ""; diff --git a/libs/sysplugins/smarty_internal_configfileparser.php b/libs/sysplugins/smarty_internal_configfileparser.php index 2be0ec2e..1c76f7bc 100644 --- a/libs/sysplugins/smarty_internal_configfileparser.php +++ b/libs/sysplugins/smarty_internal_configfileparser.php @@ -9,7 +9,6 @@ class TPC_yyStackEntry ** is the value of the token */ } -; #line 12 "../smarty/lexer/smarty_internal_configfileparser.y" /** @@ -365,7 +364,7 @@ class Smarty_Internal_Configfileparser if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { return $this->yyTokenName[ $tokenType ]; } else { - return "Unknown"; + return 'Unknown'; } } @@ -591,8 +590,8 @@ class Smarty_Internal_Configfileparser && ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0) { if ($this->yyTraceFILE) { fwrite($this->yyTraceFILE, - $this->yyTracePrompt . "FALLBACK " . - $this->yyTokenName[ $iLookAhead ] . " => " . + $this->yyTracePrompt . 'FALLBACK ' . + $this->yyTokenName[ $iLookAhead ] . ' => ' . $this->yyTokenName[ $iFallback ] . "\n"); } return $this->yy_find_shift_action($iFallback); diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index c097f44b..63a76d63 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -761,7 +761,7 @@ class Smarty_Internal_Templatelexer // resolve conflicts with shorttag and right_delimiter starting with '=' if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) { - preg_match("/\s+/", $this->value, $match); + preg_match('/\s+/', $this->value, $match); $this->value = $match[ 0 ]; $this->token = Smarty_Internal_Templateparser::TP_SPACE; } else { diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/libs/sysplugins/smarty_internal_templateparser.php index 4a10f56b..d58499fb 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/libs/sysplugins/smarty_internal_templateparser.php @@ -9,6 +9,8 @@ class TP_yyStackEntry ** is the value of the token */ } +#line 11 "../smarty/lexer/smarty_internal_templateparser.y" + /** * Smarty Template Parser Class * @@ -1451,10 +1453,10 @@ class Smarty_Internal_Templateparser 176 => 176, 177 => 177, 178 => 178, - 179 => 178, 181 => 178, + 179 => 179, + 182 => 179, 180 => 180, - 182 => 182, 183 => 183, 184 => 184, ); @@ -1683,7 +1685,7 @@ class Smarty_Internal_Templateparser if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { return $this->yyTokenName[ $tokenType ]; } else { - return "Unknown"; + return 'Unknown'; } } @@ -1909,8 +1911,8 @@ class Smarty_Internal_Templateparser && ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0) { if ($this->yyTraceFILE) { fwrite($this->yyTraceFILE, - $this->yyTracePrompt . "FALLBACK " . - $this->yyTokenName[ $iLookAhead ] . " => " . + $this->yyTracePrompt . 'FALLBACK ' . + $this->yyTokenName[ $iLookAhead ] . ' => ' . $this->yyTokenName[ $iFallback ] . "\n"); } return $this->yy_find_shift_action($iFallback); @@ -1957,7 +1959,7 @@ class Smarty_Internal_Templateparser } #line 221 "../smarty/lexer/smarty_internal_templateparser.y" $this->internalError = true; - $this->compiler->trigger_template_error("Stack overflow in template parser"); + $this->compiler->trigger_template_error('Stack overflow in template parser'); return; } $yytos = new TP_yyStackEntry; @@ -2111,7 +2113,7 @@ class Smarty_Internal_Templateparser $this->compiler->compileTag('private_print_expression', array(), array('value' => $tag)); } else { if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) { - $this->_retvalue = $this->compiler->compileTag($match[ 1 ], array("'nocache'")); + $this->_retvalue = $this->compiler->compileTag($match[ 1 ], array('\'nocache\'')); } else { $this->_retvalue = $this->compiler->compileTag($tag, array()); } @@ -2711,8 +2713,8 @@ class Smarty_Internal_Templateparser $this->yystack[ $this->yyidx + 0 ]->minor[ 1 ]; } } else { - $this->compiler->trigger_template_error("static class '" . $this->yystack[ $this->yyidx + -2 ]->minor . - "' is undefined or not allowed by security setting"); + $this->compiler->trigger_template_error('static class \'' . $this->yystack[ $this->yyidx + -2 ]->minor . + '\' is undefined or not allowed by security setting'); } } @@ -3197,13 +3199,20 @@ class Smarty_Internal_Templateparser $this->_retvalue = new Smarty_Internal_ParseTree_Dq($this, $this->yystack[ $this->yyidx + 0 ]->minor); } - #line 1241 "../smarty/lexer/smarty_internal_templateparser.y" + #line 1237 "../smarty/lexer/smarty_internal_templateparser.y" function yy_r178() { $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)' . $this->yystack[ $this->yyidx + -1 ]->minor); } - #line 1249 "../smarty/lexer/smarty_internal_templateparser.y" + #line 1241 "../smarty/lexer/smarty_internal_templateparser.y" + function yy_r179() + { + $this->_retvalue = + new Smarty_Internal_ParseTree_Code('(string)(' . $this->yystack[ $this->yyidx + -1 ]->minor . ')'); + } + + #line 1253 "../smarty/lexer/smarty_internal_templateparser.y" function yy_r180() { $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)$_smarty_tpl->tpl_vars[\'' . @@ -3211,13 +3220,6 @@ class Smarty_Internal_Templateparser '\']->value'); } - #line 1253 "../smarty/lexer/smarty_internal_templateparser.y" - function yy_r182() - { - $this->_retvalue = - new Smarty_Internal_ParseTree_Code('(string)(' . $this->yystack[ $this->yyidx + -1 ]->minor . ')'); - } - #line 1257 "../smarty/lexer/smarty_internal_templateparser.y" function yy_r183() {