Ignore:
Timestamp:
Mar 13, 2012, 7:12:25 PM (13 years ago)
Author:
[email protected]
Message:

Type conversion of exponential part failed
https://bugs.webkit.org/show_bug.cgi?id=80673

Reviewed by Geoffrey Garen.

  • parser/Lexer.cpp:

(JSC::::lex):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::parseInt):
(JSC):
(JSC::jsStrDecimalLiteral): Added another template argument that exposes whether or not
we accept trailing junk to clients of jsStrDecimalLiteral. Also added additional template
parameter for strtod to allow trailing spaces.
(JSC::toDouble):
(JSC::parseFloat): Accept trailing junk, as per the ECMA 262 spec (15.1.2.3).

  • runtime/LiteralParser.cpp:

(JSC::::Lexer::lexNumber):

  • tests/mozilla/expected.html: Update the expected page for run-javascriptcore-tests so that

we will run ecma/TypeConversion/9.3.1-3.js as a regression test now.

  • wtf/dtoa.cpp:

(WTF):
(WTF::strtod): We also needed to sometimes accept trailing spaces to pass a few other tests that were
broken by changing the default allowance of trailing junk in jsStrDecimalLiteral.

  • wtf/dtoa.h:
  • wtf/dtoa/double-conversion.cc: When the AdvanceToNonspace function was lifted out of the

Chromium codebase, the person porting it only thought to check for spaces when skipping whitespace.
A few of our JSC tests check for other types of trailing whitespace, so I've added checks for those
here to cover those cases (horizontal tab, vertical tab, carriage return, form feed, and line feed).

  • wtf/text/WTFString.cpp:

(WTF::toDoubleType): Disallow trailing spaces, as this breaks form input verification stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wtf/dtoa.cpp

    r107625 r110657  
    649649#define n_bigtens 5
    650650
    651 template<AllowTrailingJunkTag allowTrailingJunk>
     651template<AllowTrailingJunkTag allowTrailingJunk, AllowTrailingSpacesTag allowTrailingSpaces>
    652652double strtod(const char* s00, char** se)
    653653{
     
    655655    double_conversion::StringToDoubleConverter converter(
    656656        (allowTrailingJunk ? double_conversion::StringToDoubleConverter::ALLOW_TRAILING_JUNK : 0) |
     657        (allowTrailingSpaces ? double_conversion::StringToDoubleConverter::ALLOW_TRAILING_SPACES : 0) |
    657658        double_conversion::StringToDoubleConverter::ALLOW_LEADING_SPACES,
    658659        0.0,
     
    666667}
    667668
    668 template double strtod<AllowTrailingJunk>(const char*, char**);
    669 template double strtod<DisallowTrailingJunk>(const char*, char**);
     669template double strtod<AllowTrailingJunk, AllowTrailingSpaces>(const char*, char**);
     670template double strtod<AllowTrailingJunk, DisallowTrailingSpaces>(const char*, char**);
     671template double strtod<DisallowTrailingJunk, AllowTrailingSpaces>(const char*, char**);
     672template double strtod<DisallowTrailingJunk, DisallowTrailingSpaces>(const char*, char**);
    670673
    671674static ALWAYS_INLINE int quorem(BigInt& b, BigInt& S)
Note: See TracChangeset for help on using the changeset viewer.