mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 14:52:24 +09:00
issue 697: Fixed a bug for wrong compiling switch statement
switch 문이 간혹 잘못 컴파일되던 버그 수정 git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9771 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
22591f44b0
commit
0d56b9038b
2 changed files with 9 additions and 7 deletions
|
|
@ -187,7 +187,7 @@ class TemplateHandler {
|
|||
$buff = $this->_parseInline($buff);
|
||||
|
||||
// include, unload/load, import
|
||||
$buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?))(?(2)\("([^"]+)")(.*?)(?(2)\)--|\/)>|<!--(@[a-z@]+)(.*?)-->/', array($this, '_parseResource'), $buff);
|
||||
$buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?))(?(2)\("([^"]+)")(.*?)(?(2)\)--|\/)>|<!--(@[a-z@]+)(.*?)-->(\s*)/', array($this, '_parseResource'), $buff);
|
||||
|
||||
// remove block which is a virtual tag and remove comments
|
||||
$buff = preg_replace('@</?block\s*>|\s?<!--//(.*?)-->@is','',$buff);
|
||||
|
|
@ -508,14 +508,16 @@ class TemplateHandler {
|
|||
if($mm[1]{0} == 'e') return '<?php } ?>';
|
||||
|
||||
$precheck = '';
|
||||
if($mm[1] == 'foreach') {
|
||||
if($mm[1] == 'switch') {
|
||||
$m[9] = '';
|
||||
} elseif($mm[1] == 'foreach') {
|
||||
$var = preg_replace('/^\s*\(\s*(.+?) .*$/', '$1', $m[8]);
|
||||
$precheck = "if({$var}&&count({$var}))";
|
||||
}
|
||||
return '<?php '.$this->_replaceVar($precheck.$m[7].$m[8]).'{ ?>';
|
||||
return '<?php '.$this->_replaceVar($precheck.$m[7].$m[8]).'{ ?>'.$m[9];
|
||||
}
|
||||
if($mm[2]) return "<?php }{$m[7]}".$this->_replaceVar($m[8])."{ ?>";
|
||||
if($mm[4]) return "<?php ".($mm[3]?'break;':'')."{$m[7]} ".trim($m[8],'()').": ?>";
|
||||
if($mm[2]) return "<?php }{$m[7]}".$this->_replaceVar($m[8])."{ ?>".$m[9];
|
||||
if($mm[4]) return "<?php ".($mm[3]?'break;':'')."{$m[7]} ".trim($m[8],'()').": ?>".$m[9];
|
||||
if($mm[5]) return "<?php break; ?>";
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
|
|||
),
|
||||
// <!--@switch--> ~ <!--@case--> ~ <!--@break--> ~ <!--@default --> ~ <!--@endswitch-->
|
||||
array(
|
||||
'<dummy /><!--@switch($var)--><!--@case("A")-->A<!--@break--><!--@case("B")-->B<!--@break--><!--@default-->C<!--@endswitch--><dummy />',
|
||||
'<dummy /><?php switch($__Context->var){ ?><?php case "A": ?>A<?php break; ?><?php case "B": ?>B<?php break; ?><?php default : ?>C<?php } ?><dummy />'
|
||||
'<dummy /><!--@switch($var)--> <!--@case("A")--> A<!--@break--> <!--@case(\'B\')-->B<!--@break--><!--@default-->C<!--@endswitch--><dummy />',
|
||||
'<dummy /><?php switch($__Context->var){ ?><?php case "A": ?> A<?php break; ?><?php case \'B\': ?>B<?php break; ?><?php default : ?>C<?php } ?><dummy />'
|
||||
),
|
||||
// invalid block statement
|
||||
array(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue