Changeset 113454 in webkit for trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
- Timestamp:
- Apr 6, 2012, 10:31:54 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r113363 r113454 2 2 * Copyright (C) 1999-2002 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. 5 5 * Copyright (C) 2007 Cameron Zwarich ([email protected]) 6 6 * Copyright (C) 2007 Maks Orlovich … … 296 296 ++p; 297 297 } 298 if (number >= mantissaOverflowLowerBound) {299 if (radix == 10)300 number = WTF::strtod<WTF::AllowTrailingJunk, WTF::DisallowTrailingSpaces>(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0);301 else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32)302 number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix);303 }304 298 305 299 // 12. If Z is empty, return NaN. 306 300 if (!sawDigit) 307 301 return std::numeric_limits<double>::quiet_NaN(); 302 303 // Alternate code path for certain large numbers. 304 if (number >= mantissaOverflowLowerBound) { 305 if (radix == 10) { 306 size_t parsedLength; 307 number = parseDouble(s.characters() + firstDigitPosition, p - firstDigitPosition, parsedLength); 308 } else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) 309 number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix); 310 } 308 311 309 312 // 15. Return sign x number. … … 357 360 358 361 // See ecma-262 9.3.1 359 template < WTF::AllowTrailingJunkTag allowTrailingJunk,typename CharType>362 template <typename CharType> 360 363 static double jsStrDecimalLiteral(const CharType*& data, const CharType* end) 361 364 { 362 365 ASSERT(data < end); 363 366 364 // Copy the sting into a null-terminated byte buffer, and call strtod. 365 Vector<char, 32> byteBuffer; 366 for (const CharType* characters = data; characters < end; ++characters) { 367 CharType character = *characters; 368 byteBuffer.append(isASCII(character) ? static_cast<char>(character) : 0); 369 } 370 byteBuffer.append(0); 371 char* endOfNumber; 372 double number = WTF::strtod<allowTrailingJunk, WTF::AllowTrailingSpaces>(byteBuffer.data(), &endOfNumber); 373 374 // Check if strtod found a number; if so return it. 375 ptrdiff_t consumed = endOfNumber - byteBuffer.data(); 376 if (consumed) { 377 data += consumed; 367 size_t parsedLength; 368 double number = parseDouble(data, end - data, parsedLength); 369 if (parsedLength) { 370 data += parsedLength; 378 371 return number; 379 372 } … … 426 419 number = jsHexIntegerLiteral(characters, endCharacters); 427 420 else 428 number = jsStrDecimalLiteral <WTF::DisallowTrailingJunk>(characters, endCharacters);421 number = jsStrDecimalLiteral(characters, endCharacters); 429 422 430 423 // Allow trailing white space. … … 483 476 return std::numeric_limits<double>::quiet_NaN(); 484 477 485 return jsStrDecimalLiteral <WTF::AllowTrailingJunk>(data, end);478 return jsStrDecimalLiteral(data, end); 486 479 } 487 480 … … 499 492 return std::numeric_limits<double>::quiet_NaN(); 500 493 501 return jsStrDecimalLiteral <WTF::AllowTrailingJunk>(data, end);494 return jsStrDecimalLiteral(data, end); 502 495 } 503 496
Note:
See TracChangeset
for help on using the changeset viewer.