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

Side by Side Diff: src/string.js

Issue 11576069: Correctly handle negative codes in String.fromCharCode() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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-166553.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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 if (n == 1) { 817 if (n == 1) {
818 if (!%_IsSmi(code)) code = ToNumber(code); 818 if (!%_IsSmi(code)) code = ToNumber(code);
819 return %_StringCharFromCode(code & 0xffff); 819 return %_StringCharFromCode(code & 0xffff);
820 } 820 }
821 821
822 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); 822 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING);
823 var i; 823 var i;
824 for (i = 0; i < n; i++) { 824 for (i = 0; i < n; i++) {
825 var code = %_Arguments(i); 825 var code = %_Arguments(i);
826 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff; 826 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
827 if (code < 0) code = code & 0xffff;
827 if (code > 0x7f) break; 828 if (code > 0x7f) break;
828 %_OneByteSeqStringSetChar(one_byte, i, code); 829 %_OneByteSeqStringSetChar(one_byte, i, code);
829 } 830 }
830 if (i == n) return one_byte; 831 if (i == n) return one_byte;
831 one_byte = %TruncateString(one_byte, i); 832 one_byte = %TruncateString(one_byte, i);
832 833
833 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); 834 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
834 for (var j = 0; i < n; i++, j++) { 835 for (var j = 0; i < n; i++, j++) {
835 var code = %_Arguments(i); 836 var code = %_Arguments(i);
836 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff; 837 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 "fixed", StringFixed, 1001 "fixed", StringFixed,
1001 "italics", StringItalics, 1002 "italics", StringItalics,
1002 "small", StringSmall, 1003 "small", StringSmall,
1003 "strike", StringStrike, 1004 "strike", StringStrike,
1004 "sub", StringSub, 1005 "sub", StringSub,
1005 "sup", StringSup 1006 "sup", StringSup
1006 )); 1007 ));
1007 } 1008 }
1008 1009
1009 SetUpString(); 1010 SetUpString();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-166553.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698