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:
taggon 2011-10-27 06:43:54 +00:00
parent 22591f44b0
commit 0d56b9038b
2 changed files with 9 additions and 7 deletions

View file

@ -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 '';
}