$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
// Division vs. regex nastiness
array( "alert( (10+10) / '/'.charCodeAt( 0 ) + '//' );", "alert((10+10)/'/'.charCodeAt(0)+'//');" ),
array( "if(1)/a /g.exec('Pa ss');", "if(1)/a /g.exec('Pa ss');" ),
+
+ // newline insertion after 1000 chars: break after the "++", not before
+ array( str_repeat( ';', 996 ) . "if(x++);", str_repeat( ';', 996 ) . "if(x++\n);" ),
);
}