Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: src/string.js

Issue 119093002: Fix small spec violation in String.prototype.split. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-3026.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 609
610 // ECMA-262 section 15.5.4.14 610 // ECMA-262 section 15.5.4.14
611 function StringSplit(separator, limit) { 611 function StringSplit(separator, limit) {
612 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 612 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
613 throw MakeTypeError("called_on_null_or_undefined", 613 throw MakeTypeError("called_on_null_or_undefined",
614 ["String.prototype.split"]); 614 ["String.prototype.split"]);
615 } 615 }
616 var subject = TO_STRING_INLINE(this); 616 var subject = TO_STRING_INLINE(this);
617 limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit); 617 limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
618 618
619 // ECMA-262 says that if separator is undefined, the result should
620 // be an array of size 1 containing the entire string.
621 if (IS_UNDEFINED(separator)) {
622 return [subject];
623 }
624
625 var length = subject.length; 619 var length = subject.length;
626 if (!IS_REGEXP(separator)) { 620 if (!IS_REGEXP(separator)) {
627 separator = TO_STRING_INLINE(separator); 621 var separator_string = TO_STRING_INLINE(separator);
628 622
629 if (limit === 0) return []; 623 if (limit === 0) return [];
630 624
631 var separator_length = separator.length; 625 // ECMA-262 says that if separator is undefined, the result should
626 // be an array of size 1 containing the entire string.
627 if (IS_UNDEFINED(separator)) return [subject];
628
629 var separator_length = separator_string.length;
632 630
633 // If the separator string is empty then return the elements in the subject. 631 // If the separator string is empty then return the elements in the subject.
634 if (separator_length === 0) return %StringToArray(subject, limit); 632 if (separator_length === 0) return %StringToArray(subject, limit);
635 633
636 var result = %StringSplit(subject, separator, limit); 634 var result = %StringSplit(subject, separator_string, limit);
637 635
638 return result; 636 return result;
639 } 637 }
640 638
641 if (limit === 0) return []; 639 if (limit === 0) return [];
642 640
643 // Separator is a regular expression. 641 // Separator is a regular expression.
644 return StringSplitOnRegExp(subject, separator, limit, length); 642 return StringSplitOnRegExp(subject, separator, limit, length);
645 } 643 }
646 644
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 "fixed", StringFixed, 1005 "fixed", StringFixed,
1008 "italics", StringItalics, 1006 "italics", StringItalics,
1009 "small", StringSmall, 1007 "small", StringSmall,
1010 "strike", StringStrike, 1008 "strike", StringStrike,
1011 "sub", StringSub, 1009 "sub", StringSub,
1012 "sup", StringSup 1010 "sup", StringSup
1013 )); 1011 ));
1014 } 1012 }
1015 1013
1016 SetUpString(); 1014 SetUpString();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-3026.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698