1
0
Fork 0

Decompiler: remove '' . and . '' for string constant

This commit is contained in:
Xuefer 2015-06-24 11:50:05 +08:00
parent 8a8428b9a8
commit 828ca4e4c5
1 changed files with 7 additions and 11 deletions

View File

@ -222,20 +222,16 @@ class Decompiler_Value extends Decompiler_Object // {{{
{
$code = var_export($this->value, true);
if (gettype($this->value) == 'string') {
switch ($this->value) {
case "\r":
return '"\\r"';
case "\n":
return '"\\n"';
case "\r\n":
return '"\\r\\n"';
}
$code = str_replace("\r\n", '\' . "\\r\\n" . \'', $code);
$code = str_replace("\r", '\' . "\\r" . \'', $code);
$code = str_replace("\n", '\' . "\\n" . \'', $code);
$code = preg_replace_callback("![\r\n]+!", array(&$this, 'convertNewline'), $code);
$code = preg_replace("!^'' \\. \"|\" \\. ''\$!", '"', $code);
}
return $code;
}
function convertNewline($m)
{
return "' . \"". strtr($m[0], array("\r" => "\\r", "\n" => "\\n")) . "\" . '";
}
}
// }}}
class Decompiler_Code extends Decompiler_Object // {{{