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

Side by Side Diff: src/string.js

Issue 9355005: Fix String.prototype.split for undefined separator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months 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/test262/test262.status » ('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 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // ECMA-262 section 15.5.4.14 581 // ECMA-262 section 15.5.4.14
582 function StringSplit(separator, limit) { 582 function StringSplit(separator, limit) {
583 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 583 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
584 throw MakeTypeError("called_on_null_or_undefined", 584 throw MakeTypeError("called_on_null_or_undefined",
585 ["String.prototype.split"]); 585 ["String.prototype.split"]);
586 } 586 }
587 var subject = TO_STRING_INLINE(this); 587 var subject = TO_STRING_INLINE(this);
588 limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit); 588 limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
589 589
590 // ECMA-262 says that if separator is undefined, the result should 590 // ECMA-262 says that if separator is undefined, the result should
591 // be an array of size 1 containing the entire string. SpiderMonkey 591 // be an array of size 1 containing the entire string.
592 // and KJS have this behavior only when no separator is given. If 592 if (IS_UNDEFINED(separator)) {
593 // undefined is explicitly given, they convert it to a string and
594 // use that. We do as SpiderMonkey and KJS.
595 if (%_ArgumentsLength() === 0) {
596 return [subject]; 593 return [subject];
597 } 594 }
598 595
599 var length = subject.length; 596 var length = subject.length;
600 if (!IS_REGEXP(separator)) { 597 if (!IS_REGEXP(separator)) {
601 separator = TO_STRING_INLINE(separator); 598 separator = TO_STRING_INLINE(separator);
602 599
603 if (limit === 0) return []; 600 if (limit === 0) return [];
604 601
605 var separator_length = separator.length; 602 var separator_length = separator.length;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 "fixed", StringFixed, 1005 "fixed", StringFixed,
1009 "italics", StringItalics, 1006 "italics", StringItalics,
1010 "small", StringSmall, 1007 "small", StringSmall,
1011 "strike", StringStrike, 1008 "strike", StringStrike,
1012 "sub", StringSub, 1009 "sub", StringSub,
1013 "sup", StringSup 1010 "sup", StringSup
1014 )); 1011 ));
1015 } 1012 }
1016 1013
1017 SetUpString(); 1014 SetUpString();
OLDNEW
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698