Skip to content
Permalink
Browse files
Add WTF::findIgnoringASCIICaseWithoutLength to replace strcasestr
https://bugs.webkit.org/show_bug.cgi?id=197291

Reviewed by Konstantin Tokarev.

Source/JavaScriptCore:

Replace uses of strcasestr with WTF::findIgnoringASCIICaseWithoutLength.

* API/tests/testapi.cpp:
* assembler/testmasm.cpp:
* b3/air/testair.cpp:
* b3/testb3.cpp:
* dfg/testdfg.cpp:
* dynbench.cpp:

Source/WTF:

Adds an implementation of strcasestr within WTF.

* wtf/text/StringCommon.h:
(WTF::findIgnoringASCIICaseWithoutLength):


Canonical link: https://commits.webkit.org/211529@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244694 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
donny-dont committed Apr 26, 2019
1 parent f601a06 commit 89b11d0d4f275b0a2714a9d1cf392a1b1c6a02a2
Showing 9 changed files with 48 additions and 14 deletions.
@@ -36,6 +36,7 @@
#include <wtf/Noncopyable.h>
#include <wtf/NumberOfCores.h>
#include <wtf/Vector.h>
#include <wtf/text/StringCommon.h>

extern "C" int testCAPIViaCpp(const char* filter);

@@ -484,13 +485,9 @@ int testCAPIViaCpp(const char* filter)

Deque<RefPtr<SharedTask<void(TestAPI&)>>> tasks;

#if OS(DARWIN)
auto shouldRun = [&] (const char* testName) -> bool {
return !filter || !!strcasestr(testName, filter);
return !filter || WTF::findIgnoringASCIICaseWithoutLength(testName, filter) != WTF::notFound;
};
#else
auto shouldRun = [] (const char*) -> bool { return true; };
#endif

RUN(basicSymbol());
RUN(symbolsTypeof());
@@ -1,3 +1,19 @@
2019-04-26 Don Olmstead <don.olmstead@sony.com>

Add WTF::findIgnoringASCIICaseWithoutLength to replace strcasestr
https://bugs.webkit.org/show_bug.cgi?id=197291

Reviewed by Konstantin Tokarev.

Replace uses of strcasestr with WTF::findIgnoringASCIICaseWithoutLength.

* API/tests/testapi.cpp:
* assembler/testmasm.cpp:
* b3/air/testair.cpp:
* b3/testb3.cpp:
* dfg/testdfg.cpp:
* dynbench.cpp:

2019-04-25 Fujii Hironori <Hironori.Fujii@sony.com>

Unreviewed, rolling out r244669.
@@ -40,6 +40,7 @@
#include <wtf/Lock.h>
#include <wtf/NumberOfCores.h>
#include <wtf/Threading.h>
#include <wtf/text/StringCommon.h>

// We don't have a NO_RETURN_DUE_TO_EXIT, nor should we. That's ridiculous.
static bool hiddenTruthBecauseNoReturnIsStupid() { return true; }
@@ -955,11 +956,7 @@ void run(const char* filter)
Deque<RefPtr<SharedTask<void()>>> tasks;

auto shouldRun = [&] (const char* testName) -> bool {
#if OS(UNIX)
return !filter || !!strcasestr(testName, filter);
#else
return !filter || !!strstr(testName, filter);
#endif
return !filter || WTF::findIgnoringASCIICaseWithoutLength(testName, filter) != WTF::notFound;
};

RUN(testSimple());
@@ -45,6 +45,7 @@
#include <wtf/NumberOfCores.h>
#include <wtf/StdMap.h>
#include <wtf/Threading.h>
#include <wtf/text/StringCommon.h>

// We don't have a NO_RETURN_DUE_TO_EXIT, nor should we. That's ridiculous.
static bool hiddenTruthBecauseNoReturnIsStupid() { return true; }
@@ -2081,7 +2082,7 @@ void run(const char* filter)
Deque<RefPtr<SharedTask<void()>>> tasks;

auto shouldRun = [&] (const char* testName) -> bool {
return !filter || !!strcasestr(testName, filter);
return !filter || WTF::findIgnoringASCIICaseWithoutLength(testName, filter) != WTF::notFound;
};

RUN(testSimple());
@@ -78,6 +78,7 @@
#include <wtf/NumberOfCores.h>
#include <wtf/StdList.h>
#include <wtf/Threading.h>
#include <wtf/text/StringCommon.h>

// We don't have a NO_RETURN_DUE_TO_EXIT, nor should we. That's ridiculous.
static bool hiddenTruthBecauseNoReturnIsStupid() { return true; }
@@ -17156,7 +17157,7 @@ void run(const char* filter)
Deque<RefPtr<SharedTask<void()>>> tasks;

auto shouldRun = [&] (const char* testName) -> bool {
return !filter || !!strcasestr(testName, filter);
return !filter || WTF::findIgnoringASCIICaseWithoutLength(testName, filter) != WTF::notFound;
};

RUN_NOW(testTerminalPatchpointThatNeedsToBeSpilled2());
@@ -31,6 +31,7 @@
#include "DFGAbstractValue.h"
#include "InitializeThreading.h"
#include <wtf/DataLog.h>
#include <wtf/text/StringCommon.h>

// We don't have a NO_RETURN_DUE_TO_EXIT, nor should we. That's ridiculous.
static bool hiddenTruthBecauseNoReturnIsStupid() { return true; }
@@ -80,7 +81,7 @@ static void testEmptyValueDoesNotValidateWithHeapTop()
void run(const char* filter)
{
auto shouldRun = [&] (const char* testName) -> bool {
return !filter || !!strcasestr(testName, filter);
return !filter || WTF::findIgnoringASCIICaseWithoutLength(testName, filter) != WTF::notFound;
};

RUN_NOW(testEmptyValueDoesNotValidateWithHeapTop());
@@ -34,6 +34,7 @@
#include "JSObject.h"
#include "VM.h"
#include <wtf/MainThread.h>
#include <wtf/text/StringCommon.h>

using namespace JSC;

@@ -54,7 +55,7 @@ unsigned requestedIterationCount;
template<typename Callback>
NEVER_INLINE void benchmarkImpl(const char* name, unsigned iterationCount, const Callback& callback)
{
if (nameFilter && !strcasestr(name, nameFilter))
if (nameFilter && WTF::findIgnoringASCIICaseWithoutLength(name, nameFilter) == WTF::notFound)
return;

if (requestedIterationCount)
@@ -1,3 +1,15 @@
2019-04-26 Don Olmstead <don.olmstead@sony.com>

Add WTF::findIgnoringASCIICaseWithoutLength to replace strcasestr
https://bugs.webkit.org/show_bug.cgi?id=197291

Reviewed by Konstantin Tokarev.

Adds an implementation of strcasestr within WTF.

* wtf/text/StringCommon.h:
(WTF::findIgnoringASCIICaseWithoutLength):

2019-04-26 Sihui Liu <sihui_liu@apple.com>

Stop IDB transactions to release locked database files when network process is ready to suspend
@@ -466,6 +466,14 @@ size_t findIgnoringASCIICase(const SearchCharacterType* source, const MatchChara
return notFound;
}

inline size_t findIgnoringASCIICaseWithoutLength(const char* source, const char* matchCharacters)
{
unsigned searchLength = strlen(source);
unsigned matchLength = strlen(matchCharacters);

return matchLength < searchLength ? findIgnoringASCIICase(source, matchCharacters, 0, searchLength, matchLength) : notFound;
}

template<typename StringClassA, typename StringClassB>
size_t findIgnoringASCIICase(const StringClassA& source, const StringClassB& stringToFind, unsigned startOffset)
{

0 comments on commit 89b11d0

Please sign in to comment.