Index: trunk/phase3/includes/libs/JavaScriptMinifier.php |
— | — | @@ -484,23 +484,34 @@ |
485 | 485 | $end++; |
486 | 486 | } |
487 | 487 | } elseif( |
| 488 | + $ch === '0' |
| 489 | + && ($pos + 1 < $length) && ($s[$pos + 1] === 'x' || $s[$pos + 1] === 'X' ) |
| 490 | + ) { |
| 491 | + // Hex numeric literal |
| 492 | + $end++; // x or X |
| 493 | + $end += strspn( $s, '0123456789ABCDEF', $end ); |
| 494 | + // @fixme if no hex digits, parse error |
| 495 | + } elseif( |
488 | 496 | ctype_digit( $ch ) |
489 | 497 | || ( $ch === '.' && $pos + 1 < $length && ctype_digit( $s[$pos + 1] ) ) |
490 | 498 | ) { |
491 | | - // Numeric literal. Search for the end of it, but don't care about [+-]exponent |
492 | | - // at the end, as the results of "numeric [+-] numeric" and "numeric" are |
493 | | - // identical to our state machine. |
494 | | - $end += strspn( $s, '0123456789ABCDEFabcdefXx.', $end ); |
495 | | - while( $s[$end - 1] === '.' ) { |
496 | | - // Special case: When a numeric ends with a dot, we have to check the |
497 | | - // literal for proper syntax |
498 | | - $decimal = strspn( $s, '0123456789', $pos, $end - $pos - 1 ); |
499 | | - if( $decimal === $end - $pos - 1 ) { |
500 | | - break; |
501 | | - } else { |
502 | | - $end--; |
503 | | - } |
| 499 | + $end += strspn( $s, '0123456789', $end ); |
| 500 | + $decimal = strspn( $s, '.', $end ); |
| 501 | + if ($decimal) { |
| 502 | + $end += $decimal; |
| 503 | + $end += strspn( $s, '0123456789', $end ); |
| 504 | + // @fixme If no decimal digits after the . we cannot be followed |
| 505 | + // by an identifier, and should throw a parse error |
504 | 506 | } |
| 507 | + $exponent = strspn( $s, 'eE', $end ); |
| 508 | + if( $exponent ) { |
| 509 | + $end += $exponent;; |
| 510 | + // + sign is optional; - sign is required. |
| 511 | + $end += strspn( $s, '-+', $end ); |
| 512 | + $end += strspn( $s, '0123456789', $end ); |
| 513 | + // @fixme if no decimal digits after the e/+/- we should |
| 514 | + // throw a parse error |
| 515 | + } |
505 | 516 | } elseif( isset( $opChars[$ch] ) ) { |
506 | 517 | // Punctuation character. Search for the longest matching operator. |
507 | 518 | while( |