OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 end_i = TO_INTEGER(end); | 547 end_i = TO_INTEGER(end); |
548 } | 548 } |
549 | 549 |
550 if (start_i < 0) { | 550 if (start_i < 0) { |
551 start_i += s_len; | 551 start_i += s_len; |
552 if (start_i < 0) { | 552 if (start_i < 0) { |
553 start_i = 0; | 553 start_i = 0; |
554 } | 554 } |
555 } else { | 555 } else { |
556 if (start_i > s_len) { | 556 if (start_i > s_len) { |
557 start_i = s_len; | 557 return ''; |
558 } | 558 } |
559 } | 559 } |
560 | 560 |
561 if (end_i < 0) { | 561 if (end_i < 0) { |
562 end_i += s_len; | 562 end_i += s_len; |
563 if (end_i < 0) { | 563 if (end_i < 0) { |
564 end_i = 0; | 564 return ''; |
565 } | 565 } |
566 } else { | 566 } else { |
567 if (end_i > s_len) { | 567 if (end_i > s_len) { |
568 end_i = s_len; | 568 end_i = s_len; |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 var num_c = end_i - start_i; | 572 if (end_i <= start_i) { |
573 if (num_c < 0) { | 573 return ''; |
574 num_c = 0; | |
575 } | 574 } |
576 | 575 |
577 return SubString(s, start_i, start_i + num_c); | 576 return SubString(s, start_i, end_i); |
578 } | 577 } |
579 | 578 |
580 | 579 |
581 // ECMA-262 section 15.5.4.14 | 580 // ECMA-262 section 15.5.4.14 |
582 function StringSplit(separator, limit) { | 581 function StringSplit(separator, limit) { |
583 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 582 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
584 throw MakeTypeError("called_on_null_or_undefined", | 583 throw MakeTypeError("called_on_null_or_undefined", |
585 ["String.prototype.split"]); | 584 ["String.prototype.split"]); |
586 } | 585 } |
587 var subject = TO_STRING_INLINE(this); | 586 var subject = TO_STRING_INLINE(this); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 "fixed", StringFixed, | 1004 "fixed", StringFixed, |
1006 "italics", StringItalics, | 1005 "italics", StringItalics, |
1007 "small", StringSmall, | 1006 "small", StringSmall, |
1008 "strike", StringStrike, | 1007 "strike", StringStrike, |
1009 "sub", StringSub, | 1008 "sub", StringSub, |
1010 "sup", StringSup | 1009 "sup", StringSup |
1011 )); | 1010 )); |
1012 } | 1011 } |
1013 | 1012 |
1014 SetUpString(); | 1013 SetUpString(); |
OLD | NEW |