diff options
author | anaqreon <tamanning@zoho.com> | 2014-12-30 16:06:35 -0600 |
---|---|---|
committer | anaqreon <tamanning@zoho.com> | 2014-12-30 16:06:35 -0600 |
commit | b78a545a1056e6db9f4b6b4f262182b0a5c56e67 (patch) | |
tree | 515c2f742a5a39e18b00debf1849ee9703fa4a42 /library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php | |
parent | d67c5a6ffd134602084a6dcb37b316bf768bf715 (diff) | |
parent | 43671a0a323afa758df56c06822ce3c46da026df (diff) | |
download | volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.tar.gz volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.tar.bz2 volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.zip |
Merge pull request #1 from friendica/master
Pull from upstream
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php b/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php index b16a6940d..117310439 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php @@ -1,23 +1,22 @@ <?php /** * Smarty Internal Plugin Config File Compiler - * * This is the config file compiler class. It calls the lexer and parser to * perform the compiling. * - * @package Smarty + * @package Smarty * @subpackage Config - * @author Uwe Tews + * @author Uwe Tews */ /** * Main config file compiler class * - * @package Smarty + * @package Smarty * @subpackage Config */ -class Smarty_Internal_Config_File_Compiler { - +class Smarty_Internal_Config_File_Compiler +{ /** * Lexer object * @@ -69,7 +68,8 @@ class Smarty_Internal_Config_File_Compiler { * Method to compile a Smarty template. * * @param Smarty_Internal_Config $config config object - * @return bool true if compiling succeeded, false if it failed + * + * @return bool true if compiling succeeded, false if it failed */ public function compileSource(Smarty_Internal_Config $config) { @@ -84,28 +84,46 @@ class Smarty_Internal_Config_File_Compiler { return true; } // init the lexer/parser to compile the config file - $lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty); + $lex = new Smarty_Internal_Configfilelexer($_content, $this); $parser = new Smarty_Internal_Configfileparser($lex, $this); - if ($this->smarty->_parserdebug) $parser->PrintTrace(); + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } else { + $mbEncoding = null; + } + + + if ($this->smarty->_parserdebug) { + $parser->PrintTrace(); + } // get tokens from lexer and parse them while ($lex->yylex()) { - if ($this->smarty->_parserdebug) echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; + if ($this->smarty->_parserdebug) { + echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; + } $parser->doParse($lex->token, $lex->value); } // finish parsing process $parser->doParse(0, 0); + + if ($mbEncoding) { + mb_internal_encoding($mbEncoding); + } + $config->compiled_config = '<?php $_config_vars = ' . var_export($this->config_data, true) . '; ?>'; } /** * display compiler error messages without dying - * * If parameter $args is empty it is a parser detected syntax error. - * In this case the parser is called to obtain information about exspected tokens. - * + * In this case the parser is called to obtain information about expected tokens. * If parameter $args contains a string this is used as error message * * @param string $args individual error message or null + * + * @throws SmartyCompilerException */ public function trigger_config_file_error($args = null) { @@ -117,12 +135,12 @@ class Smarty_Internal_Config_File_Compiler { // $line--; } $match = preg_split("/\n/", $this->lex->data); - $error_text = "Syntax error in config file '{$this->config->source->filepath}' on line {$line} '{$match[$line-1]}' "; + $error_text = "Syntax error in config file '{$this->config->source->filepath}' on line {$line} '{$match[$line - 1]}' "; if (isset($args)) { // individual error message $error_text .= $args; } else { - // exspected token from parser + // expected token from parser foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { $exp_token = $this->parser->yyTokenName[$token]; if (isset($this->lex->smarty_token_names[$exp_token])) { @@ -138,7 +156,4 @@ class Smarty_Internal_Config_File_Compiler { } throw new SmartyCompilerException($error_text); } - } - -?>
\ No newline at end of file |