OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 565 |
566 | 566 |
567 // ECMA-262 section 15.5.4.14 | 567 // ECMA-262 section 15.5.4.14 |
568 // Helper function used by split. | 568 // Helper function used by split. |
569 function splitMatch(separator, subject, current_index, start_index) { | 569 function splitMatch(separator, subject, current_index, start_index) { |
570 if (IS_REGEXP(separator)) { | 570 if (IS_REGEXP(separator)) { |
571 var ovector = DoRegExpExec(separator, subject, start_index); | 571 var ovector = DoRegExpExec(separator, subject, start_index); |
572 if (ovector == null) return null; | 572 if (ovector == null) return null; |
573 var nof_results = ovector.length >> 1; | 573 var nof_results = ovector.length >> 1; |
574 var result = new $Array(nof_results + 1); | 574 var result = new $Array(nof_results + 1); |
| 575 // Section 15.5.4.14 paragraph two says that we do not allow zero length |
| 576 // matches at the end of the string. |
| 577 if (ovector[0] === subject.length) return null; |
575 result[0] = ovector[1]; | 578 result[0] = ovector[1]; |
576 result[1] = subject.slice(current_index, ovector[0]); | 579 result[1] = subject.slice(current_index, ovector[0]); |
577 for (var i = 1; i < nof_results; i++) { | 580 for (var i = 1; i < nof_results; i++) { |
578 var matching_start = ovector[2*i]; | 581 var matching_start = ovector[2*i]; |
579 var matching_end = ovector[2*i + 1]; | 582 var matching_end = ovector[2*i + 1]; |
580 if (matching_start != -1 && matching_end != -1) { | 583 if (matching_start != -1 && matching_end != -1) { |
581 result[i + 1] = subject.slice(matching_start, matching_end); | 584 result[i + 1] = subject.slice(matching_start, matching_end); |
582 } | 585 } |
583 } | 586 } |
584 return result; | 587 return result; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 "italics", StringItalics, | 860 "italics", StringItalics, |
858 "small", StringSmall, | 861 "small", StringSmall, |
859 "strike", StringStrike, | 862 "strike", StringStrike, |
860 "sub", StringSub, | 863 "sub", StringSub, |
861 "sup", StringSup | 864 "sup", StringSup |
862 )); | 865 )); |
863 } | 866 } |
864 | 867 |
865 | 868 |
866 SetupString(); | 869 SetupString(); |
OLD | NEW |