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

Side by Side Diff: src/conversions.cc

Issue 5338005: Fix number parsing to not allow space between sign and digits. (Closed)
Patch Set: Address review comment. Created 10 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
« no previous file with comments | « no previous file | test/cctest/test-conversions.cc » ('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-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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // or insignificant leading zeros of the fractional part are dropped. 441 // or insignificant leading zeros of the fractional part are dropped.
442 int exponent = 0; 442 int exponent = 0;
443 int significant_digits = 0; 443 int significant_digits = 0;
444 int insignificant_digits = 0; 444 int insignificant_digits = 0;
445 bool nonzero_digit_dropped = false; 445 bool nonzero_digit_dropped = false;
446 bool fractional_part = false; 446 bool fractional_part = false;
447 447
448 bool sign = false; 448 bool sign = false;
449 449
450 if (*current == '+') { 450 if (*current == '+') {
451 // Ignore leading sign; skip following spaces. 451 // Ignore leading sign.
452 ++current; 452 ++current;
453 if (!AdvanceToNonspace(&current, end)) return JUNK_STRING_VALUE; 453 if (current == end) return JUNK_STRING_VALUE;
454 } else if (*current == '-') { 454 } else if (*current == '-') {
455 ++current; 455 ++current;
456 if (!AdvanceToNonspace(&current, end)) return JUNK_STRING_VALUE; 456 if (current == end) return JUNK_STRING_VALUE;
457 sign = true; 457 sign = true;
458 } 458 }
459 459
460 static const char kInfinitySymbol[] = "Infinity"; 460 static const char kInfinitySymbol[] = "Infinity";
461 if (*current == kInfinitySymbol[0]) { 461 if (*current == kInfinitySymbol[0]) {
462 if (!SubStringEquals(&current, end, kInfinitySymbol)) { 462 if (!SubStringEquals(&current, end, kInfinitySymbol)) {
463 return JUNK_STRING_VALUE; 463 return JUNK_STRING_VALUE;
464 } 464 }
465 465
466 if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) { 466 if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 // Allocate result and fill in the parts. 1074 // Allocate result and fill in the parts.
1075 StringBuilder builder(result_size + 1); 1075 StringBuilder builder(result_size + 1);
1076 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); 1076 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size);
1077 if (decimal_pos > 0) builder.AddCharacter('.'); 1077 if (decimal_pos > 0) builder.AddCharacter('.');
1078 builder.AddSubstring(decimal_buffer, decimal_pos); 1078 builder.AddSubstring(decimal_buffer, decimal_pos);
1079 return builder.Finalize(); 1079 return builder.Finalize();
1080 } 1080 }
1081 1081
1082 1082
1083 } } // namespace v8::internal 1083 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698