Trim trailing whitespace
[lhc/web/wiklou.git] / includes / libs / JavaScriptMinifier.php
index 710ebe3..a991d91 100644 (file)
@@ -422,7 +422,7 @@ class JavaScriptMinifier {
                while( $pos < $length ) {
                        // First, skip over any whitespace and multiline comments, recording whether we
                        // found any newline character
-                       $skip = strspn( $s, " \t\n\r\v\f", $pos );
+                       $skip = strspn( $s, " \t\n\r\xb\xc", $pos );
                        if( !$skip ) {
                                $ch = $s[$pos];
                                if( $ch === '/' && substr( $s, $pos, 2 ) === '/*' ) {
@@ -512,7 +512,7 @@ class JavaScriptMinifier {
                        } else {
                                // Identifier or reserved word. Search for the end by excluding whitespace and
                                // punctuation.
-                               $end += strcspn( $s, " \t\n.;,=<>+-{}()[]?:*/%'\"!&|^~\f\v\r", $end );
+                               $end += strcspn( $s, " \t\n.;,=<>+-{}()[]?:*/%'\"!&|^~\xb\xc\r", $end );
                        }
 
                        // Now get the token type from our type array
@@ -526,10 +526,11 @@ class JavaScriptMinifier {
                                $state = self::STATEMENT;
                                $lineLength = 0;
                        } elseif( $maxLineLength > 0 && $lineLength + $end - $pos > $maxLineLength &&
-                                       !isset( $semicolon[$state][$type] ) )
+                                       !isset( $semicolon[$state][$type] ) && $type !== self::TYPE_INCR_OP )
                        {
                                // This line would get too long if we added $token, so add a newline first.
-                               // Only do this if it won't trigger semicolon insertion though.
+                               // Only do this if it won't trigger semicolon insertion and if it won't
+                               // put a postfix increment operator on its own line, which is illegal in js.
                                $out .= "\n";
                                $lineLength = 0;
                        // Check, whether we have to separate the token from the last one with whitespace