diff --git a/_compile.php b/_compile.php index 31891a4a..df32f5c0 100644 --- a/_compile.php +++ b/_compile.php @@ -41,6 +41,28 @@ function put_file($match) { return $return; } +// Dgx's PHP shrinker +function php_shrink($input) { + $set = array_flip(preg_split('//', '!"#$&\'()*+,-./:;<=>?@[\]^`{|}')); + $space = ''; + $output = ''; + foreach (token_get_all($input) as $token) { + if (!is_array($token)) { + $token = array(0, $token); + } + if ($token[0] == T_COMMENT || $token[0] == T_WHITESPACE) { + $space = "\n"; + } else { + if (isset($set[substr($output, -1)]) || isset($set[$token[1]{0}])) { + $space = ''; + } + $output .= $space . $token[1]; + $space = ''; + } + } + return $output; +} + error_reporting(E_ALL & ~E_NOTICE); if ($_SERVER["argc"] > 1) { $_COOKIE["lang"] = $_SERVER["argv"][1]; @@ -64,5 +86,6 @@ $file = str_replace("favicon.ico", '', "", $file); +$file = php_shrink($file); fwrite(fopen($filename, "w"), $file); echo "$filename created.\n";