0 ? array_fill(0, $line, '#') : array()) +
preg_split("~\r?\n~", file_get_contents($file)));
switch($mode) {
case 'php':
if($file == $f)
$text = preg_replace('~\b(function)[ \t]+([a-zA-Z])~',
'$1 _DISABLE_$2', $text);
break;
case 'text':
$text = preg_replace('~^\S.*~m', '//', $text);
break;
case 'doc':
$text = explode("\n",
str_replace(array('@code', '@endcode'),
array('', ''), $text));
$text = preg_replace('~^[ \t]*\*(?!/)~m', '', $text);
$t = array_fill(0, count($text), '//');
$c = 0;
foreach($text as $n => $s)
if(!$c && strpos($s, "") !== false) $c = 1;
else if($c && strpos($s, "") !== false) $c = 0;
else if($c) $t[$n] = $s;
$text = implode("\n", $t);
break;
}
$text = preg_replace('~^[ \t]*echo (.+);[ \t]*#~m', 'strval($1); #', $text);
$text = preg_replace('~^(.+);[ \t]*#[ \t]*(.+)$~m',
__FUNCTION__ . "($1,$2,'$file',__LINE__);", $text);
if(preg_match("~^\s*<\?~", $text)) $text = "?>$text";
#foreach(explode("\n", $text) as $k=>$v) printf("
%04d: %s\n", $k+1, $v); eval($text); if($file == $f) exit; } else if($args[0] != $args[1]) { ob_start(); echo "test failed in $args[2] on line $args[3]\n"; echo "expect: "; var_dump($args[1]); echo "actual: "; var_dump($args[0]); $s = ob_get_clean(); (php_sapi_name() == 'cli') ? fwrite(STDERR, $s) : print("
" . htmlspecialchars($s) . ""); } } ?>