Changeset 108001 in webkit for trunk/Source/JavaScriptCore/wtf


Ignore:
Timestamp:
Feb 16, 2012, 4:54:37 PM (13 years ago)
Author:
[email protected]
Message:

Fix the broken viewport tests
https://bugs.webkit.org/show_bug.cgi?id=78774

Reviewed by Kenneth Rohde Christiansen.

Source/JavaScriptCore:

  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • wtf/text/WTFString.cpp:

(WTF):
(WTF::toDoubleType): Template-ized to allow other functions to specify whether they
want to allow trailing junk or not when calling strtod.
(WTF::charactersToDouble):
(WTF::charactersToFloat):
(WTF::charactersToFloatIgnoringJunk): Created new version of charactersToFloat that allows
trailing junk.

  • wtf/text/WTFString.h:

(WTF):

Source/WebCore:

No new tests.

  • dom/ViewportArguments.cpp:

(WebCore::numericPrefix): Changed to use the new charactersToFloatWithJunk function(s).

LayoutTests:

  • platform/gtk/Skipped: Undoing tests skipped due to earlier breakage.
  • platform/qt/Skipped: Ditto.
Location:
trunk/Source/JavaScriptCore/wtf/text
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wtf/text/WTFString.cpp

    r107625 r108001  
    10371037}
    10381038
    1039 template <typename CharType>
     1039template <typename CharType, WTF::AllowTrailingJunkTag allowTrailingJunk>
    10401040static inline double toDoubleType(const CharType* data, size_t length, bool* ok, bool* didReadNumber)
    10411041{
     
    10541054    char* start = bytes.data();
    10551055    char* end;
    1056     double val = WTF::strtod<WTF::DisallowTrailingJunk>(start, &end);
     1056    double val = WTF::strtod<allowTrailingJunk>(start, &end);
    10571057    if (ok)
    10581058        *ok = (end == 0 || *end == '\0') && !isnan(val);
     
    10641064double charactersToDouble(const LChar* data, size_t length, bool* ok, bool* didReadNumber)
    10651065{
    1066     return toDoubleType<LChar>(data, length, ok, didReadNumber);
     1066    return toDoubleType<LChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber);
    10671067}
    10681068
    10691069double charactersToDouble(const UChar* data, size_t length, bool* ok, bool* didReadNumber)
    10701070{
    1071     return toDoubleType<UChar>(data, length, ok, didReadNumber);
     1071    return toDoubleType<UChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber);
    10721072}
    10731073
     
    10751075{
    10761076    // FIXME: This will return ok even when the string fits into a double but not a float.
    1077     return static_cast<float>(toDoubleType<LChar>(data, length, ok, didReadNumber));
     1077    return static_cast<float>(toDoubleType<LChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber));
    10781078}
    10791079
     
    10811081{
    10821082    // FIXME: This will return ok even when the string fits into a double but not a float.
    1083     return static_cast<float>(toDoubleType<UChar>(data, length, ok, didReadNumber));
     1083    return static_cast<float>(toDoubleType<UChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber));
     1084}
     1085
     1086float charactersToFloatIgnoringJunk(const LChar* data, size_t length, bool* ok, bool* didReadNumber)
     1087{
     1088    // FIXME: This will return ok even when the string fits into a double but not a float.
     1089    return static_cast<float>(toDoubleType<LChar, WTF::AllowTrailingJunk>(data, length, ok, didReadNumber));
     1090}
     1091
     1092float charactersToFloatIgnoringJunk(const UChar* data, size_t length, bool* ok, bool* didReadNumber)
     1093{
     1094    // FIXME: This will return ok even when the string fits into a double but not a float.
     1095    return static_cast<float>(toDoubleType<UChar, WTF::AllowTrailingJunk>(data, length, ok, didReadNumber));
    10841096}
    10851097
  • trunk/Source/JavaScriptCore/wtf/text/WTFString.h

    r106433 r108001  
    8888WTF_EXPORT_PRIVATE double charactersToDouble(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
    8989float charactersToFloat(const LChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
     90WTF_EXPORT_PRIVATE float charactersToFloatIgnoringJunk(const LChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
    9091WTF_EXPORT_PRIVATE float charactersToFloat(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
     92WTF_EXPORT_PRIVATE float charactersToFloatIgnoringJunk(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0);
    9193
    9294enum FloatConversionFlags {
Note: See TracChangeset for help on using the changeset viewer.