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 ) === '/*' ) {
} 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
$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