⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277355 in webkit


Ignore:
Timestamp:
May 11, 2021, 9:23:30 PM (5 years ago)
Author:
Darin Adler
Message:

Remove the String::toInt family of functions
https://bugs.webkit.org/show_bug.cgi?id=225599

Reviewed by Anders Carlsson.

Source/WebCore:

  • platform/graphics/GLContext.cpp:

(WebCore::GLContext::version): Use
parseIntegerAllowingTrailingJunk<unsigned> instead of String::toUInt.

  • platform/graphics/GlyphBuffer.h:

(WebCore::GlyphBuffer::checkedStringOffsetAt const): Fix code that was
assuming GlyphBufferStringOffset was signed to compile without a warning
regardless of whether it's signed or unsigned. This was making GTK
builds have tons and tons of warnings, which was distracting while
working on the other fixes here.

  • platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:

(CachedResourceStreamingClient::responseReceived): Use
parseIntegerAllowingTrailingJunk<uint64_t> instead of String::toUInt64.

Source/WebKit:

  • Shared/win/AuxiliaryProcessMainWin.cpp:

(WebKit::AuxiliaryProcessMainCommon::parseCommandLine): Use
parseIntegerAllowingTrailingJunk<uint64_t> instead of String::toUInt64.

  • UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp:

(WebKit::ScriptMessageClient::didPostMessage): Ditto.

  • UIProcess/win/WebProcessPoolWin.cpp:

(WebKit::initializeRemoteInspectorServer): Use
parseIntegerAllowingTrailingJunk<uint16_t> instead of StringView::toUInt64.
This is a 16-bit port number, so not valuable to parse larger integers.

Source/WTF:

  • wtf/text/AtomString.h: Deleted AtomString::toInt.
  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::toIntStrict): Deleted.
(WTF::StringImpl::toUIntStrict): Deleted.
(WTF::StringImpl::toInt64Strict): Deleted.
(WTF::StringImpl::toUInt64Strict): Deleted.
(WTF::StringImpl::toIntPtrStrict): Deleted.
(WTF::StringImpl::toInt): Deleted.
(WTF::StringImpl::toUInt): Deleted.
(WTF::StringImpl::toInt64): Deleted.
(WTF::StringImpl::toUInt64): Deleted.
(WTF::StringImpl::toIntPtr): Deleted.

  • wtf/text/StringImpl.h: Deleted the above functions.
  • wtf/text/StringToIntegerConversion.h: Removed toIntegralType.
  • wtf/text/StringView.cpp:

(WTF::parseUInt16): Deleted.

  • wtf/text/StringView.h: Deleted StringView::toInt,

StringView::toIntStrict, StringView::toUInt64Strict,
StringView::toInt64Strict, and parseUInt16. Changed the constructor
that takes a const char* to work when passed nullptr. StringView has
a null value, and converting a null const char* should produce that.

  • wtf/text/WTFString.cpp:

(WTF::String::toIntStrict const): Deleted.
(WTF::String::toUIntStrict const): Deleted.
(WTF::String::toInt64Strict const): Deleted.
(WTF::String::toUInt64Strict const): Deleted.
(WTF::String::toIntPtrStrict const): Deleted.
(WTF::String::toInt const): Deleted.
(WTF::String::toUInt const): Deleted.
(WTF::String::toInt64 const): Deleted.
(WTF::String::toUInt64 const): Deleted.
(WTF::String::toIntPtr const): Deleted.
(WTF::lengthOfCharactersAsInteger): Deleted.
(WTF::charactersToIntStrict): Deleted.
(WTF::charactersToUIntStrict): Deleted.
(WTF::charactersToInt64Strict): Deleted.
(WTF::charactersToUInt64Strict): Deleted.
(WTF::charactersToIntPtrStrict): Deleted.
(WTF::charactersToInt): Deleted.
(WTF::charactersToUInt): Deleted.
(WTF::charactersToInt64): Deleted.
(WTF::charactersToUInt64): Deleted.
(WTF::charactersToIntPtr): Deleted.

  • wtf/text/WTFString.h: Deleted the above functions.

Tools:

  • TestWebKitAPI/CMakeLists.txt: Added StringToIntegerConversion.cpp.
  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.
  • TestWebKitAPI/Tests/WTF/StringToIntegerConversion.cpp: Added.

Contains tests moved and adapted from the files below so we don't
lose test coverage. We and and should add many more tests.

  • TestWebKitAPI/Tests/WTF/StringView.cpp: Removed tests for parseUInt16

and StringView::toIntStrict.

  • TestWebKitAPI/Tests/WTF/WTFString.cpp: Removed tests for String::toInt.
  • TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm: Use

parseInteger<uint64_t> instead of StringView::toUInt64Strict.

  • TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm: Ditto.
Location:
trunk
Files:
1 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r277354 r277355  
     12021-05-11  Darin Adler  <darin@apple.com>
     2
     3        Remove the String::toInt family of functions
     4        https://bugs.webkit.org/show_bug.cgi?id=225599
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * wtf/text/AtomString.h: Deleted AtomString::toInt.
     9
     10        * wtf/text/StringImpl.cpp:
     11        (WTF::StringImpl::toIntStrict): Deleted.
     12        (WTF::StringImpl::toUIntStrict): Deleted.
     13        (WTF::StringImpl::toInt64Strict): Deleted.
     14        (WTF::StringImpl::toUInt64Strict): Deleted.
     15        (WTF::StringImpl::toIntPtrStrict): Deleted.
     16        (WTF::StringImpl::toInt): Deleted.
     17        (WTF::StringImpl::toUInt): Deleted.
     18        (WTF::StringImpl::toInt64): Deleted.
     19        (WTF::StringImpl::toUInt64): Deleted.
     20        (WTF::StringImpl::toIntPtr): Deleted.
     21        * wtf/text/StringImpl.h: Deleted the above functions.
     22
     23        * wtf/text/StringToIntegerConversion.h: Removed toIntegralType.
     24
     25        * wtf/text/StringView.cpp:
     26        (WTF::parseUInt16): Deleted.
     27
     28        * wtf/text/StringView.h: Deleted StringView::toInt,
     29        StringView::toIntStrict, StringView::toUInt64Strict,
     30        StringView::toInt64Strict, and parseUInt16. Changed the constructor
     31        that takes a const char* to work when passed nullptr. StringView has
     32        a null value, and converting a null const char* should produce that.
     33
     34        * wtf/text/WTFString.cpp:
     35        (WTF::String::toIntStrict const): Deleted.
     36        (WTF::String::toUIntStrict const): Deleted.
     37        (WTF::String::toInt64Strict const): Deleted.
     38        (WTF::String::toUInt64Strict const): Deleted.
     39        (WTF::String::toIntPtrStrict const): Deleted.
     40        (WTF::String::toInt const): Deleted.
     41        (WTF::String::toUInt const): Deleted.
     42        (WTF::String::toInt64 const): Deleted.
     43        (WTF::String::toUInt64 const): Deleted.
     44        (WTF::String::toIntPtr const): Deleted.
     45        (WTF::lengthOfCharactersAsInteger): Deleted.
     46        (WTF::charactersToIntStrict): Deleted.
     47        (WTF::charactersToUIntStrict): Deleted.
     48        (WTF::charactersToInt64Strict): Deleted.
     49        (WTF::charactersToUInt64Strict): Deleted.
     50        (WTF::charactersToIntPtrStrict): Deleted.
     51        (WTF::charactersToInt): Deleted.
     52        (WTF::charactersToUInt): Deleted.
     53        (WTF::charactersToInt64): Deleted.
     54        (WTF::charactersToUInt64): Deleted.
     55        (WTF::charactersToIntPtr): Deleted.
     56        * wtf/text/WTFString.h: Deleted the above functions.
     57
    1582021-05-11  Devin Rousso  <drousso@apple.com>
    259
  • trunk/Source/WTF/wtf/text/AtomString.h

    r275457 r277355  
    138138    WTF_EXPORT_PRIVATE AtomString convertToASCIIUppercase() const;
    139139
    140     int toInt(bool* ok = nullptr) const { return m_string.toInt(ok); }
    141140    double toDouble(bool* ok = nullptr) const { return m_string.toDouble(ok); }
    142141    float toFloat(bool* ok = nullptr) const { return m_string.toFloat(ok); }
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r272084 r277355  
    810810        return StringImpl::simplifyMatchedCharactersToSpace<LChar>(isWhiteSpace);
    811811    return StringImpl::simplifyMatchedCharactersToSpace<UChar>(isWhiteSpace);
    812 }
    813 
    814 int StringImpl::toIntStrict(bool* ok, int base)
    815 {
    816     if (is8Bit())
    817         return charactersToIntStrict(characters8(), m_length, ok, base);
    818     return charactersToIntStrict(characters16(), m_length, ok, base);
    819 }
    820 
    821 unsigned StringImpl::toUIntStrict(bool* ok, int base)
    822 {
    823     if (is8Bit())
    824         return charactersToUIntStrict(characters8(), m_length, ok, base);
    825     return charactersToUIntStrict(characters16(), m_length, ok, base);
    826 }
    827 
    828 int64_t StringImpl::toInt64Strict(bool* ok, int base)
    829 {
    830     if (is8Bit())
    831         return charactersToInt64Strict(characters8(), m_length, ok, base);
    832     return charactersToInt64Strict(characters16(), m_length, ok, base);
    833 }
    834 
    835 uint64_t StringImpl::toUInt64Strict(bool* ok, int base)
    836 {
    837     if (is8Bit())
    838         return charactersToUInt64Strict(characters8(), m_length, ok, base);
    839     return charactersToUInt64Strict(characters16(), m_length, ok, base);
    840 }
    841 
    842 intptr_t StringImpl::toIntPtrStrict(bool* ok, int base)
    843 {
    844     if (is8Bit())
    845         return charactersToIntPtrStrict(characters8(), m_length, ok, base);
    846     return charactersToIntPtrStrict(characters16(), m_length, ok, base);
    847 }
    848 
    849 int StringImpl::toInt(bool* ok)
    850 {
    851     if (is8Bit())
    852         return charactersToInt(characters8(), m_length, ok);
    853     return charactersToInt(characters16(), m_length, ok);
    854 }
    855 
    856 unsigned StringImpl::toUInt(bool* ok)
    857 {
    858     if (is8Bit())
    859         return charactersToUInt(characters8(), m_length, ok);
    860     return charactersToUInt(characters16(), m_length, ok);
    861 }
    862 
    863 int64_t StringImpl::toInt64(bool* ok)
    864 {
    865     if (is8Bit())
    866         return charactersToInt64(characters8(), m_length, ok);
    867     return charactersToInt64(characters16(), m_length, ok);
    868 }
    869 
    870 uint64_t StringImpl::toUInt64(bool* ok)
    871 {
    872     if (is8Bit())
    873         return charactersToUInt64(characters8(), m_length, ok);
    874     return charactersToUInt64(characters16(), m_length, ok);
    875 }
    876 
    877 intptr_t StringImpl::toIntPtr(bool* ok)
    878 {
    879     if (is8Bit())
    880         return charactersToIntPtr(characters8(), m_length, ok);
    881     return charactersToIntPtr(characters16(), m_length, ok);
    882812}
    883813
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r274997 r277355  
    393393    WTF_EXPORT_PRIVATE UChar32 characterStartingAt(unsigned);
    394394
    395     int toIntStrict(bool* ok = nullptr, int base = 10);
    396     unsigned toUIntStrict(bool* ok = nullptr, int base = 10);
    397     int64_t toInt64Strict(bool* ok = nullptr, int base = 10);
    398     uint64_t toUInt64Strict(bool* ok = nullptr, int base = 10);
    399     intptr_t toIntPtrStrict(bool* ok = nullptr, int base = 10);
    400 
    401     WTF_EXPORT_PRIVATE int toInt(bool* ok = nullptr); // ignores trailing garbage
    402     unsigned toUInt(bool* ok = nullptr); // ignores trailing garbage
    403     int64_t toInt64(bool* ok = nullptr); // ignores trailing garbage
    404     uint64_t toUInt64(bool* ok = nullptr); // ignores trailing garbage
    405     intptr_t toIntPtr(bool* ok = nullptr); // ignores trailing garbage
    406 
    407395    // FIXME: Like the strict functions above, these give false for "ok" when there is trailing garbage.
    408396    // Like the non-strict functions above, these return the value when there is trailing garbage.
  • trunk/Source/WTF/wtf/text/StringToIntegerConversion.h

    r277234 r277355  
    111111}
    112112
    113 // FIXME: Deprecated. Remove toIntegralType entirely once we get move all callers to parseInteger.
    114 template<typename IntegralType, typename StringOrStringView> IntegralType toIntegralType(const StringOrStringView& stringView, bool* ok, int base = 10)
    115 {
    116     auto result = parseInteger<IntegralType>(stringView, base);
    117     if (ok)
    118         *ok = result.hasValue();
    119     return result.valueOr(0);
    120 }
    121 
    122 // FIXME: Deprecated. Remove toIntegralType entirely once we get move all callers to parseInteger.
    123 template<typename IntegralType, typename CharacterType> IntegralType toIntegralType(const CharacterType* data, unsigned length, bool* ok, int base = 10)
    124 {
    125     return toIntegralType<IntegralType>(StringView { data, length }, ok, base);
    126 }
    127 
    128 // FIXME: Deprecated. Remove toIntegralType entirely once we get move all callers to parseInteger.
    129 template<typename IntegralType, typename StringOrStringView> Optional<IntegralType> toIntegralType(const StringOrStringView& stringView, int base = 10)
    130 {
    131     return parseInteger<IntegralType>(stringView, base);
    132 }
    133 
    134 // FIXME: Deprecated. Remove toIntegralType entirely once we get move all callers to parseInteger.
    135 template<typename IntegralType, typename CharacterType> Optional<IntegralType> toIntegralType(const CharacterType* data, unsigned length, int base = 10)
    136 {
    137     return parseInteger<IntegralType>(StringView { data, length }, base);
    138 }
    139 
    140113}
    141114
    142115using WTF::parseInteger;
    143116using WTF::parseIntegerAllowingTrailingJunk;
    144 using WTF::toIntegralType;
  • trunk/Source/WTF/wtf/text/StringView.cpp

    r265735 r277355  
    310310        return string;
    311311    return result.underlyingString;
    312 }
    313 
    314 // FIXME: Should this be named parseNumber<uint16_t> instead?
    315 // FIXME: Should we replace the toInt family of functions with this style?
    316 Optional<uint16_t> parseUInt16(StringView string)
    317 {
    318     bool ok = false;
    319     auto number = toIntegralType<uint16_t>(string, &ok);
    320     if (!ok)
    321         return WTF::nullopt;
    322     return number;
    323312}
    324313
  • trunk/Source/WTF/wtf/text/StringView.h

    r274872 r277355  
    169169    WTF_EXPORT_PRIVATE bool endsWithIgnoringASCIICase(const StringView&) const;
    170170
    171     int toInt() const;
    172     int toInt(bool& isValid) const;
    173     int toIntStrict(bool& isValid) const;
    174     Optional<uint64_t> toUInt64Strict() const;
    175     Optional<int64_t> toInt64Strict() const;
    176171    float toFloat(bool& isValid) const;
    177172
     
    247242WTF_EXPORT_PRIVATE String normalizedNFC(const String&);
    248243
    249 WTF_EXPORT_PRIVATE Optional<uint16_t> parseUInt16(StringView);
    250 
    251244}
    252245
     
    353346inline StringView::StringView(const char* characters)
    354347{
    355     initialize(reinterpret_cast<const LChar*>(characters), strlen(characters));
     348    initialize(reinterpret_cast<const LChar*>(characters), characters ? strlen(characters) : 0);
    356349}
    357350
     
    587580        return charactersToFloat(characters8(), m_length, &isValid);
    588581    return charactersToFloat(characters16(), m_length, &isValid);
    589 }
    590 
    591 inline int StringView::toInt() const
    592 {
    593     bool isValid;
    594     return toInt(isValid);
    595 }
    596 
    597 inline int StringView::toInt(bool& isValid) const
    598 {
    599     if (is8Bit())
    600         return charactersToInt(characters8(), m_length, &isValid);
    601     return charactersToInt(characters16(), m_length, &isValid);
    602 }
    603 
    604 inline int StringView::toIntStrict(bool& isValid) const
    605 {
    606     if (is8Bit())
    607         return charactersToIntStrict(characters8(), m_length, &isValid);
    608     return charactersToIntStrict(characters16(), m_length, &isValid);
    609 }
    610 
    611 inline Optional<uint64_t> StringView::toUInt64Strict() const
    612 {
    613     bool isValid;
    614     uint64_t result = is8Bit() ? charactersToUInt64Strict(characters8(), m_length, &isValid) : charactersToUInt64Strict(characters16(), m_length, &isValid);
    615     return isValid ? makeOptional(result) : WTF::nullopt;
    616 }
    617 
    618 inline Optional<int64_t> StringView::toInt64Strict() const
    619 {
    620     bool isValid;
    621     int64_t result = is8Bit() ? charactersToInt64Strict(characters8(), m_length, &isValid) : charactersToInt64Strict(characters16(), m_length, &isValid);
    622     return isValid ? makeOptional(result) : WTF::nullopt;
    623582}
    624583
  • trunk/Source/WTF/wtf/text/WTFString.cpp

    r277234 r277355  
    493493}
    494494
    495 int String::toIntStrict(bool* ok, int base) const
    496 {
    497     if (!m_impl) {
    498         if (ok)
    499             *ok = false;
    500         return 0;
    501     }
    502     return m_impl->toIntStrict(ok, base);
    503 }
    504 
    505 unsigned String::toUIntStrict(bool* ok, int base) const
    506 {
    507     if (!m_impl) {
    508         if (ok)
    509             *ok = false;
    510         return 0;
    511     }
    512     return m_impl->toUIntStrict(ok, base);
    513 }
    514 
    515 int64_t String::toInt64Strict(bool* ok, int base) const
    516 {
    517     if (!m_impl) {
    518         if (ok)
    519             *ok = false;
    520         return 0;
    521     }
    522     return m_impl->toInt64Strict(ok, base);
    523 }
    524 
    525 uint64_t String::toUInt64Strict(bool* ok, int base) const
    526 {
    527     if (!m_impl) {
    528         if (ok)
    529             *ok = false;
    530         return 0;
    531     }
    532     return m_impl->toUInt64Strict(ok, base);
    533 }
    534 
    535 intptr_t String::toIntPtrStrict(bool* ok, int base) const
    536 {
    537     if (!m_impl) {
    538         if (ok)
    539             *ok = false;
    540         return 0;
    541     }
    542     return m_impl->toIntPtrStrict(ok, base);
    543 }
    544 
    545 int String::toInt(bool* ok) const
    546 {
    547     if (!m_impl) {
    548         if (ok)
    549             *ok = false;
    550         return 0;
    551     }
    552     return m_impl->toInt(ok);
    553 }
    554 
    555 unsigned String::toUInt(bool* ok) const
    556 {
    557     if (!m_impl) {
    558         if (ok)
    559             *ok = false;
    560         return 0;
    561     }
    562     return m_impl->toUInt(ok);
    563 }
    564 
    565 int64_t String::toInt64(bool* ok) const
    566 {
    567     if (!m_impl) {
    568         if (ok)
    569             *ok = false;
    570         return 0;
    571     }
    572     return m_impl->toInt64(ok);
    573 }
    574 
    575 uint64_t String::toUInt64(bool* ok) const
    576 {
    577     if (!m_impl) {
    578         if (ok)
    579             *ok = false;
    580         return 0;
    581     }
    582     return m_impl->toUInt64(ok);
    583 }
    584 
    585 intptr_t String::toIntPtr(bool* ok) const
    586 {
    587     if (!m_impl) {
    588         if (ok)
    589             *ok = false;
    590         return 0;
    591     }
    592     return m_impl->toIntPtr(ok);
    593 }
    594 
    595495double String::toDouble(bool* ok) const
    596496{
     
    893793
    894794// String Operations
    895 template<typename CharacterType>
    896 static unsigned lengthOfCharactersAsInteger(const CharacterType* data, size_t length)
    897 {
    898     size_t i = 0;
    899 
    900     // Allow leading spaces.
    901     for (; i != length; ++i) {
    902         if (!isSpaceOrNewline(data[i]))
    903             break;
    904     }
    905    
    906     // Allow sign.
    907     if (i != length && (data[i] == '+' || data[i] == '-'))
    908         ++i;
    909    
    910     // Allow digits.
    911     for (; i != length; ++i) {
    912         if (!isASCIIDigit(data[i]))
    913             break;
    914     }
    915 
    916     return i;
    917 }
    918 
    919 int charactersToIntStrict(const LChar* data, size_t length, bool* ok, int base)
    920 {
    921     return toIntegralType<int>(data, length, ok, base);
    922 }
    923 
    924 int charactersToIntStrict(const UChar* data, size_t length, bool* ok, int base)
    925 {
    926     return toIntegralType<int>(data, length, ok, base);
    927 }
    928 
    929 unsigned charactersToUIntStrict(const LChar* data, size_t length, bool* ok, int base)
    930 {
    931     return toIntegralType<unsigned>(data, length, ok, base);
    932 }
    933 
    934 unsigned charactersToUIntStrict(const UChar* data, size_t length, bool* ok, int base)
    935 {
    936     return toIntegralType<unsigned>(data, length, ok, base);
    937 }
    938 
    939 int64_t charactersToInt64Strict(const LChar* data, size_t length, bool* ok, int base)
    940 {
    941     return toIntegralType<int64_t>(data, length, ok, base);
    942 }
    943 
    944 int64_t charactersToInt64Strict(const UChar* data, size_t length, bool* ok, int base)
    945 {
    946     return toIntegralType<int64_t>(data, length, ok, base);
    947 }
    948 
    949 uint64_t charactersToUInt64Strict(const LChar* data, size_t length, bool* ok, int base)
    950 {
    951     return toIntegralType<uint64_t>(data, length, ok, base);
    952 }
    953 
    954 uint64_t charactersToUInt64Strict(const UChar* data, size_t length, bool* ok, int base)
    955 {
    956     return toIntegralType<uint64_t>(data, length, ok, base);
    957 }
    958 
    959 intptr_t charactersToIntPtrStrict(const LChar* data, size_t length, bool* ok, int base)
    960 {
    961     return toIntegralType<intptr_t>(data, length, ok, base);
    962 }
    963 
    964 intptr_t charactersToIntPtrStrict(const UChar* data, size_t length, bool* ok, int base)
    965 {
    966     return toIntegralType<intptr_t>(data, length, ok, base);
    967 }
    968 
    969 int charactersToInt(const LChar* data, size_t length, bool* ok)
    970 {
    971     return toIntegralType<int>(data, lengthOfCharactersAsInteger<LChar>(data, length), ok, 10);
    972 }
    973 
    974 int charactersToInt(const UChar* data, size_t length, bool* ok)
    975 {
    976     return toIntegralType<int>(data, lengthOfCharactersAsInteger(data, length), ok, 10);
    977 }
    978 
    979 unsigned charactersToUInt(const LChar* data, size_t length, bool* ok)
    980 {
    981     return toIntegralType<unsigned>(data, lengthOfCharactersAsInteger<LChar>(data, length), ok, 10);
    982 }
    983 
    984 unsigned charactersToUInt(const UChar* data, size_t length, bool* ok)
    985 {
    986     return toIntegralType<unsigned>(data, lengthOfCharactersAsInteger<UChar>(data, length), ok, 10);
    987 }
    988 
    989 int64_t charactersToInt64(const LChar* data, size_t length, bool* ok)
    990 {
    991     return toIntegralType<int64_t>(data, lengthOfCharactersAsInteger<LChar>(data, length), ok, 10);
    992 }
    993 
    994 int64_t charactersToInt64(const UChar* data, size_t length, bool* ok)
    995 {
    996     return toIntegralType<int64_t>(data, lengthOfCharactersAsInteger<UChar>(data, length), ok, 10);
    997 }
    998 
    999 uint64_t charactersToUInt64(const LChar* data, size_t length, bool* ok)
    1000 {
    1001     return toIntegralType<uint64_t>(data, lengthOfCharactersAsInteger<LChar>(data, length), ok, 10);
    1002 }
    1003 
    1004 uint64_t charactersToUInt64(const UChar* data, size_t length, bool* ok)
    1005 {
    1006     return toIntegralType<uint64_t>(data, lengthOfCharactersAsInteger<UChar>(data, length), ok, 10);
    1007 }
    1008 
    1009 intptr_t charactersToIntPtr(const LChar* data, size_t length, bool* ok)
    1010 {
    1011     return toIntegralType<intptr_t>(data, lengthOfCharactersAsInteger<LChar>(data, length), ok, 10);
    1012 }
    1013 
    1014 intptr_t charactersToIntPtr(const UChar* data, size_t length, bool* ok)
    1015 {
    1016     return toIntegralType<intptr_t>(data, lengthOfCharactersAsInteger<UChar>(data, length), ok, 10);
    1017 }
    1018795
    1019796template<typename CharacterType, TrailingJunkPolicy policy>
  • trunk/Source/WTF/wtf/text/WTFString.h

    r274896 r277355  
    4343// Declarations of string operations
    4444
    45 WTF_EXPORT_PRIVATE int charactersToIntStrict(const LChar*, size_t, bool* ok = nullptr, int base = 10);
    46 WTF_EXPORT_PRIVATE int charactersToIntStrict(const UChar*, size_t, bool* ok = nullptr, int base = 10);
    47 WTF_EXPORT_PRIVATE unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = nullptr, int base = 10);
    48 WTF_EXPORT_PRIVATE unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = nullptr, int base = 10);
    49 WTF_EXPORT_PRIVATE int64_t charactersToInt64Strict(const LChar*, size_t, bool* ok = nullptr, int base = 10);
    50 WTF_EXPORT_PRIVATE int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = nullptr, int base = 10);
    51 WTF_EXPORT_PRIVATE uint64_t charactersToUInt64Strict(const LChar*, size_t, bool* ok = nullptr, int base = 10);
    52 WTF_EXPORT_PRIVATE uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = nullptr, int base = 10);
    53 intptr_t charactersToIntPtrStrict(const LChar*, size_t, bool* ok = nullptr, int base = 10);
    54 intptr_t charactersToIntPtrStrict(const UChar*, size_t, bool* ok = nullptr, int base = 10);
    55 
    56 WTF_EXPORT_PRIVATE int charactersToInt(const LChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    57 WTF_EXPORT_PRIVATE int charactersToInt(const UChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    58 unsigned charactersToUInt(const LChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    59 unsigned charactersToUInt(const UChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    60 int64_t charactersToInt64(const LChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    61 int64_t charactersToInt64(const UChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    62 uint64_t charactersToUInt64(const LChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    63 WTF_EXPORT_PRIVATE uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    64 intptr_t charactersToIntPtr(const LChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    65 intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = nullptr); // ignores trailing garbage
    66 
    67 // FIXME: Like the strict functions above, these give false for "ok" when there is trailing garbage.
    68 // Like the non-strict functions above, these return the value when there is trailing garbage.
    69 // It would be better if these were more consistent with the above functions instead.
    7045WTF_EXPORT_PRIVATE double charactersToDouble(const LChar*, size_t, bool* ok = nullptr);
    7146WTF_EXPORT_PRIVATE double charactersToDouble(const UChar*, size_t, bool* ok = nullptr);
     
    282257    WTF_EXPORT_PRIVATE Vector<String> splitAllowingEmptyEntries(const String& separator) const;
    283258
    284     WTF_EXPORT_PRIVATE int toIntStrict(bool* ok = nullptr, int base = 10) const;
    285     WTF_EXPORT_PRIVATE unsigned toUIntStrict(bool* ok = nullptr, int base = 10) const;
    286     WTF_EXPORT_PRIVATE int64_t toInt64Strict(bool* ok = nullptr, int base = 10) const;
    287     WTF_EXPORT_PRIVATE uint64_t toUInt64Strict(bool* ok = nullptr, int base = 10) const;
    288     WTF_EXPORT_PRIVATE intptr_t toIntPtrStrict(bool* ok = nullptr, int base = 10) const;
    289 
    290     WTF_EXPORT_PRIVATE int toInt(bool* ok = nullptr) const;
    291     WTF_EXPORT_PRIVATE unsigned toUInt(bool* ok = nullptr) const;
    292     WTF_EXPORT_PRIVATE int64_t toInt64(bool* ok = nullptr) const;
    293     WTF_EXPORT_PRIVATE uint64_t toUInt64(bool* ok = nullptr) const;
    294     WTF_EXPORT_PRIVATE intptr_t toIntPtr(bool* ok = nullptr) const;
    295 
    296     // FIXME: Like the strict functions above, these give false for "ok" when there is trailing garbage.
    297     // Like the non-strict functions above, these return the value when there is trailing garbage.
    298     // It would be better if these were more consistent with the above functions instead.
    299259    WTF_EXPORT_PRIVATE double toDouble(bool* ok = nullptr) const;
    300260    WTF_EXPORT_PRIVATE float toFloat(bool* ok = nullptr) const;
     
    681641using WTF::charactersToDouble;
    682642using WTF::charactersToFloat;
    683 using WTF::charactersToInt64;
    684 using WTF::charactersToInt64Strict;
    685 using WTF::charactersToInt;
    686 using WTF::charactersToIntPtr;
    687 using WTF::charactersToIntPtrStrict;
    688 using WTF::charactersToIntStrict;
    689 using WTF::charactersToUInt64;
    690 using WTF::charactersToUInt64Strict;
    691 using WTF::charactersToUInt;
    692 using WTF::charactersToUIntStrict;
    693643using WTF::emptyString;
    694644using WTF::nullString;
  • trunk/Source/WebCore/ChangeLog

    r277353 r277355  
     12021-05-11  Darin Adler  <darin@apple.com>
     2
     3        Remove the String::toInt family of functions
     4        https://bugs.webkit.org/show_bug.cgi?id=225599
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * platform/graphics/GLContext.cpp:
     9        (WebCore::GLContext::version): Use
     10        parseIntegerAllowingTrailingJunk<unsigned> instead of String::toUInt.
     11
     12        * platform/graphics/GlyphBuffer.h:
     13        (WebCore::GlyphBuffer::checkedStringOffsetAt const): Fix code that was
     14        assuming GlyphBufferStringOffset was signed to compile without a warning
     15        regardless of whether it's signed or unsigned. This was making GTK
     16        builds have tons and tons of warnings, which was distracting while
     17        working on the other fixes here.
     18
     19        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
     20        (CachedResourceStreamingClient::responseReceived): Use
     21        parseIntegerAllowingTrailingJunk<uint64_t> instead of String::toUInt64.
     22
    1232021-05-11  Commit Queue  <commit-queue@webkit.org>
    224
  • trunk/Source/WebCore/platform/graphics/GLContext.cpp

    r276528 r277355  
    2020
    2121#if USE(OPENGL) || USE(OPENGL_ES)
     22
    2223#include "GLContext.h"
     24
    2325#include <wtf/ThreadSpecific.h>
     26#include <wtf/text/StringToIntegerConversion.h>
    2427
    2528#if USE(EGL)
     
    184187        }
    185188
    186         m_version = versionDigits[0].toUInt() * 100 + versionDigits[1].toUInt() * 10;
     189        m_version = parseIntegerAllowingTrailingJunk<unsigned>(versionDigits[0]).valueOr(0) * 100
     190            + parseIntegerAllowingTrailingJunk<unsigned>(versionDigits[1]).valueOr(0) * 10;
    187191    }
    188192    return m_version;
  • trunk/Source/WebCore/platform/graphics/GlyphBuffer.h

    r277232 r277355  
    7979    {
    8080        auto result = uncheckedStringOffsetAt(index);
    81         if (result < 0 || static_cast<unsigned>(result) >= stringLength)
     81        if (static_cast<std::make_unsigned_t<GlyphBufferStringOffset>>(result) >= stringLength)
    8282            return WTF::nullopt;
    8383        return result;
  • trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp

    r277269 r277355  
    10261026    headers.reset(gst_structure_new_empty("response-headers"));
    10271027    for (const auto& header : response.httpHeaderFields()) {
    1028         bool ok = false;
    1029         uint64_t convertedValue = header.value.toUInt64(&ok);
    1030         if (ok)
    1031             gst_structure_set(headers.get(), header.key.utf8().data(), G_TYPE_UINT64, convertedValue, nullptr);
     1028        if (auto convertedValue = parseIntegerAllowingTrailingJunk<uint64_t>(header.value))
     1029            gst_structure_set(headers.get(), header.key.utf8().data(), G_TYPE_UINT64, *convertedValue, nullptr);
    10321030        else
    10331031            gst_structure_set(headers.get(), header.key.utf8().data(), G_TYPE_STRING, header.value.utf8().data(), nullptr);
  • trunk/Source/WebKit/ChangeLog

    r277354 r277355  
     12021-05-11  Darin Adler  <darin@apple.com>
     2
     3        Remove the String::toInt family of functions
     4        https://bugs.webkit.org/show_bug.cgi?id=225599
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/win/AuxiliaryProcessMainWin.cpp:
     9        (WebKit::AuxiliaryProcessMainCommon::parseCommandLine): Use
     10        parseIntegerAllowingTrailingJunk<uint64_t> instead of String::toUInt64.
     11        * UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp:
     12        (WebKit::ScriptMessageClient::didPostMessage): Ditto.
     13        * UIProcess/win/WebProcessPoolWin.cpp:
     14        (WebKit::initializeRemoteInspectorServer): Use
     15        parseIntegerAllowingTrailingJunk<uint16_t> instead of StringView::toUInt64.
     16        This is a 16-bit port number, so not valuable to parse larger integers.
     17
    1182021-05-11  Devin Rousso  <drousso@apple.com>
    219
  • trunk/Source/WebKit/Shared/win/AuxiliaryProcessMainWin.cpp

    r271563 r277355  
    2929#include <JavaScriptCore/ExecutableAllocator.h>
    3030#include <cstring>
    31 #include <wtf/text/WTFString.h>
     31#include <wtf/text/StringToIntegerConversion.h>
    3232
    3333namespace WebKit {
     
    3636{
    3737    for (int i = 0; i < argc; i++) {
    38         if (!strcmp(argv[i], "-clientIdentifier") && i + 1 < argc) {
    39             String str(argv[++i]);
    40             m_parameters.connectionIdentifier = reinterpret_cast<HANDLE>(str.toUInt64());
    41         } else if (!strcmp(argv[i], "-processIdentifier") && i + 1 < argc) {
    42             String str(argv[++i]);
    43             m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(str.toUInt64());
    44         } else if (!strcmp(argv[i], "-configure-jsc-for-testing"))
     38        if (!strcmp(argv[i], "-clientIdentifier") && i + 1 < argc)
     39            m_parameters.connectionIdentifier = reinterpret_cast<HANDLE>(parseIntegerAllowingTrailingJunk<uint64_t>(argv[++i]).valueOr(0));
     40        else if (!strcmp(argv[i], "-processIdentifier") && i + 1 < argc)
     41            m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(parseIntegerAllowingTrailingJunk<uint64_t>(argv[++i]).valueOr(0));
     42        else if (!strcmp(argv[i], "-configure-jsc-for-testing"))
    4543            JSC::Config::configureForTesting();
    4644        else if (!strcmp(argv[i], "-disable-jit"))
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp

    r260350 r277355  
    3131#include "WebScriptMessageHandler.h"
    3232#include <wtf/URL.h>
     33#include <wtf/text/StringToIntegerConversion.h>
    3334
    3435namespace WebKit {
     
    5152
    5253        URL requestURL = URL({ }, page.pageLoadState().url());
    53         m_inspectorProtocolHandler.inspect(requestURL.hostAndPort(), tokens[0].toUInt64(), tokens[1].toUInt64(), tokens[2]);
     54        m_inspectorProtocolHandler.inspect(requestURL.hostAndPort(), parseIntegerAllowingTrailingJunk<uint64_t>(tokens[0]).valueOr(0), parseIntegerAllowingTrailingJunk<uint64_t>(tokens[1]).valueOr(0), tokens[2]);
    5455    }
    5556
  • trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp

    r268074 r277355  
    4040#include <wtf/URL.h>
    4141#include <wtf/text/StringBuilder.h>
     42#include <wtf/text/StringToIntegerConversion.h>
    4243
    4344namespace WebKit {
     
    6061
    6162        URL requestURL { { }, page.pageLoadState().url() };
    62         m_inspectorProtocolHandler.inspect(requestURL.hostAndPort(), tokens[0].toUIntStrict(), tokens[1].toUIntStrict(), tokens[2]);
     63        m_inspectorProtocolHandler.inspect(requestURL.hostAndPort(), parseInteger<int>(tokens[0]).valueOr(0), parseInteger<int>(tokens[1]).valueOr(0), tokens[2]);
    6364    }
    6465   
  • trunk/Source/WebKit/UIProcess/win/WebProcessPoolWin.cpp

    r250988 r277355  
    3434#include <JavaScriptCore/RemoteInspectorServer.h>
    3535#include <WebCore/WebCoreBundleWin.h>
     36#include <wtf/text/StringToIntegerConversion.h>
    3637#endif
    3738
     
    6263
    6364    auto host = address.substring(0, pos);
    64     auto port = address.substring(pos + 1).toUInt64Strict();
     65    auto port = parseInteger<uint16_t>(address.substring(pos + 1));
    6566    if (!port)
    6667        return;
  • trunk/Tools/ChangeLog

    r277354 r277355  
     12021-05-11  Darin Adler  <darin@apple.com>
     2
     3        Remove the String::toInt family of functions
     4        https://bugs.webkit.org/show_bug.cgi?id=225599
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * TestWebKitAPI/CMakeLists.txt: Added StringToIntegerConversion.cpp.
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.
     10
     11        * TestWebKitAPI/Tests/WTF/StringToIntegerConversion.cpp: Added.
     12        Contains tests moved and adapted from the files below so we don't
     13        lose test coverage. We and and should add many more tests.
     14
     15        * TestWebKitAPI/Tests/WTF/StringView.cpp: Removed tests for parseUInt16
     16        and StringView::toIntStrict.
     17
     18        * TestWebKitAPI/Tests/WTF/WTFString.cpp: Removed tests for String::toInt.
     19
     20        * TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm: Use
     21        parseInteger<uint64_t> instead of StringView::toUInt64Strict.
     22        * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm: Ditto.
     23
    1242021-05-11  Devin Rousso  <drousso@apple.com>
    225
  • trunk/Tools/TestWebKitAPI/CMakeLists.txt

    r276247 r277355  
    9494    Tests/WTF/StringOperators.cpp
    9595    Tests/WTF/StringParsingBuffer.cpp
     96    Tests/WTF/StringToIntegerConversion.cpp
    9697    Tests/WTF/StringView.cpp
    9798    Tests/WTF/SynchronizedFixedQueue.cpp
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r277353 r277355  
    832832                9329AA291DE3F81E003ABD07 /* TextBreakIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */; };
    833833                932AE53D1D371047005DFFAF /* focus-inputs.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93575C551D30366E000D604D /* focus-inputs.html */; };
     834                9332EF942649BB68009F5D6D /* StringToIntegerConversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9332EF932649BB68009F5D6D /* StringToIntegerConversion.cpp */; };
    834835                933D631D1FCB76200032ECD6 /* Hasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933D631B1FCB76180032ECD6 /* Hasher.cpp */; };
    835836                9342589C255B609B0059EEDD /* SpeechRecognition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9342589B255B609A0059EEDD /* SpeechRecognition.mm */; };
     
    25132514                9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBreakIterator.cpp; sourceTree = "<group>"; };
    25142515                9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidNotHandleKeyDown.cpp; sourceTree = "<group>"; };
     2516                9332EF932649BB68009F5D6D /* StringToIntegerConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringToIntegerConversion.cpp; sourceTree = "<group>"; };
    25152517                933D631B1FCB76180032ECD6 /* Hasher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Hasher.cpp; sourceTree = "<group>"; };
    25162518                9342589B255B609A0059EEDD /* SpeechRecognition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SpeechRecognition.mm; sourceTree = "<group>"; };
     
    44654467                                C01363C713C3997300EF3964 /* StringOperators.cpp */,
    44664468                                7CD70C4E24A436EE00E61040 /* StringParsingBuffer.cpp */,
     4469                                9332EF932649BB68009F5D6D /* StringToIntegerConversion.cpp */,
    44674470                                7C74D42D188228F300E5ED57 /* StringView.cpp */,
    44684471                                5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */,
     
    52215224                                7C83DF381D0A590C00FEBCF3 /* StringOperators.cpp in Sources */,
    52225225                                7CD70C4F24A436EE00E61040 /* StringParsingBuffer.cpp in Sources */,
     5226                                9332EF942649BB68009F5D6D /* StringToIntegerConversion.cpp in Sources */,
    52235227                                7C83DF3A1D0A590C00FEBCF3 /* StringView.cpp in Sources */,
    52245228                                5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp

    r274959 r277355  
    991991}
    992992
    993 TEST(WTF, StringViewParseUInt16)
    994 {
    995     EXPECT_EQ(0U, *WTF::parseUInt16("0"));
    996     EXPECT_EQ(3U, *WTF::parseUInt16("3"));
    997     EXPECT_EQ(12345U, *WTF::parseUInt16("12345"));
    998     EXPECT_EQ(65535U, *WTF::parseUInt16("65535"));
    999     EXPECT_TRUE(!WTF::parseUInt16("-1"));
    1000     EXPECT_TRUE(!WTF::parseUInt16("-3"));
    1001     EXPECT_TRUE(!WTF::parseUInt16("65536"));
    1002 }
    1003 
    1004 TEST(WTF, StringViewToIntStrict)
    1005 {
    1006     auto test = [](ASCIILiteral string) {
    1007         bool isValid = false;
    1008         int result = StringView(string).toIntStrict(isValid);
    1009         return isValid ? makeOptional(result) : WTF::nullopt;
    1010     };
    1011     EXPECT_EQ(0, *test("0"_s));
    1012     EXPECT_EQ(3, *test("3"_s));
    1013     EXPECT_EQ(-3, *test("-3"_s));
    1014     EXPECT_EQ(12345, *test("12345"_s));
    1015     EXPECT_EQ(-12345, *test("-12345"_s));
    1016     if (std::numeric_limits<int>::max() == 2147483647) {
    1017         EXPECT_EQ(2147483647, *test("2147483647"_s));
    1018         EXPECT_TRUE(!test("2147483648"_s));
    1019     }
    1020     if (std::numeric_limits<int>::min() == -2147483648) {
    1021         EXPECT_EQ(-2147483648, *test("-2147483648"_s));
    1022         EXPECT_TRUE(!test("-2147483649"_s));
    1023     }
    1024 }
    1025 
    1026993} // namespace TestWebKitAPI
  • trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp

    r274878 r277355  
    288288}
    289289
    290 TEST(WTF, StringToInt)
    291 {
    292     bool ok = false;
    293 
    294     EXPECT_EQ(0, String().toInt());
    295     EXPECT_EQ(0, String().toInt(&ok));
    296     EXPECT_FALSE(ok);
    297 
    298     EXPECT_EQ(0, emptyString().toInt());
    299     EXPECT_EQ(0, emptyString().toInt(&ok));
    300     EXPECT_FALSE(ok);
    301 
    302     EXPECT_EQ(0, String("0").toInt());
    303     EXPECT_EQ(0, String("0").toInt(&ok));
    304     EXPECT_TRUE(ok);
    305 
    306     EXPECT_EQ(1, String("1").toInt());
    307     EXPECT_EQ(1, String("1").toInt(&ok));
    308     EXPECT_TRUE(ok);
    309 
    310     EXPECT_EQ(2147483647, String("2147483647").toInt());
    311     EXPECT_EQ(2147483647, String("2147483647").toInt(&ok));
    312     EXPECT_TRUE(ok);
    313 
    314     EXPECT_EQ(0, String("2147483648").toInt());
    315     EXPECT_EQ(0, String("2147483648").toInt(&ok));
    316     EXPECT_FALSE(ok);
    317 
    318     EXPECT_EQ(-2147483648, String("-2147483648").toInt());
    319     EXPECT_EQ(-2147483648, String("-2147483648").toInt(&ok));
    320     EXPECT_TRUE(ok);
    321 
    322     EXPECT_EQ(0, String("-2147483649").toInt());
    323     EXPECT_EQ(0, String("-2147483649").toInt(&ok));
    324     EXPECT_FALSE(ok);
    325 
    326     // fail if we see leading junk
    327     EXPECT_EQ(0, String("x1").toInt());
    328     EXPECT_EQ(0, String("x1").toInt(&ok));
    329     EXPECT_FALSE(ok);
    330 
    331     // succeed if we see leading spaces
    332     EXPECT_EQ(1, String(" 1").toInt());
    333     EXPECT_EQ(1, String(" 1").toInt(&ok));
    334     EXPECT_TRUE(ok);
    335 
    336     // silently ignore trailing junk
    337     EXPECT_EQ(1, String("1x").toInt());
    338     EXPECT_EQ(1, String("1x").toInt(&ok));
    339     EXPECT_TRUE(ok);
    340 }
    341 
    342290TEST(WTF, StringToDouble)
    343291{
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm

    r277336 r277355  
    5151#import <wtf/text/StringConcatenateNumbers.h>
    5252#import <wtf/text/StringHash.h>
     53#import <wtf/text/StringToIntegerConversion.h>
    5354#import <wtf/text/WTFString.h>
    5455
     
    16021603        auto rangeBeginString = requestRangeString.substring(begin + rangeBytes.length(), dash - begin - rangeBytes.length());
    16031604        auto rangeEndString = requestRangeString.substring(dash + 1, end - dash - 1);
    1604         auto rangeBegin = rangeBeginString.toUInt64Strict();
    1605         auto rangeEnd = rangeEndString == "*" ? [videoData length] : rangeEndString.toUInt64Strict();
     1605        auto rangeBegin = parseInteger<uint64_t>(rangeBeginString).valueOr(0);
     1606        auto rangeEnd = rangeEndString == "*" ? [videoData length] : parseInteger<uint64_t>(rangeEndString).valueOr(0);
    16061607
    16071608        auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@"https://webkit.org/"] statusCode:206 HTTPVersion:@"HTTP/1.1" headerFields:@{
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm

    r276862 r277355  
    4848#import <wtf/Deque.h>
    4949#import <wtf/RetainPtr.h>
     50#import <wtf/text/StringToIntegerConversion.h>
    5051#import <wtf/text/WTFString.h>
    5152
     
    771772            ASSERT(end != notFound);
    772773
    773             auto rangeBegin = *request.substring(begin + rangeBytes.length(), dash - begin - rangeBytes.length()).toUInt64Strict();
    774             auto rangeEnd = *request.substring(dash + 1, end - dash - 1).toUInt64Strict();
     774            auto rangeBegin = parseInteger<uint64_t>(request.substring(begin + rangeBytes.length(), dash - begin - rangeBytes.length())).value();
     775            auto rangeEnd = parseInteger<uint64_t>(request.substring(dash + 1, end - dash - 1)).value();
    775776
    776777            NSString *responseHeaderString = [NSString stringWithFormat:
Note: See TracChangeset for help on using the changeset viewer.