WebKit Bugzilla
Attachment 368260 Details for
Bug 197291
: Add WTF::findIgnoringASCIICaseWithoutLength to replace strcasestr
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197291.diff (text/plain), 7.41 KB, created by
Don Olmstead
on 2019-04-25 13:37:26 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Don Olmstead
Created:
2019-04-25 13:37:26 PDT
Size:
7.41 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/API/tests/testapi.cpp b/Source/JavaScriptCore/API/tests/testapi.cpp >index 99352c25b96..bca06071c39 100644 >--- a/Source/JavaScriptCore/API/tests/testapi.cpp >+++ b/Source/JavaScriptCore/API/tests/testapi.cpp >@@ -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()); >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 24db2f4364a..35998197827 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-04-25 Don Olmstead <don.olmstead@sony.com> >+ >+ Add WTF::findIgnoringASCIICaseWithoutLength to replace strcasestr >+ https://bugs.webkit.org/show_bug.cgi?id=197291 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Alex Christensen <achristensen@webkit.org> > > Fix more builds after r244653 >diff --git a/Source/JavaScriptCore/assembler/testmasm.cpp b/Source/JavaScriptCore/assembler/testmasm.cpp >index 99e70a16ede..ac5c63291b3 100644 >--- a/Source/JavaScriptCore/assembler/testmasm.cpp >+++ b/Source/JavaScriptCore/assembler/testmasm.cpp >@@ -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()); >diff --git a/Source/JavaScriptCore/b3/air/testair.cpp b/Source/JavaScriptCore/b3/air/testair.cpp >index a564bc73c8e..9dc9966a944 100644 >--- a/Source/JavaScriptCore/b3/air/testair.cpp >+++ b/Source/JavaScriptCore/b3/air/testair.cpp >@@ -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()); >diff --git a/Source/JavaScriptCore/b3/testb3.cpp b/Source/JavaScriptCore/b3/testb3.cpp >index 4d694f78b9e..ff3b3b53831 100644 >--- a/Source/JavaScriptCore/b3/testb3.cpp >+++ b/Source/JavaScriptCore/b3/testb3.cpp >@@ -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()); >diff --git a/Source/JavaScriptCore/dfg/testdfg.cpp b/Source/JavaScriptCore/dfg/testdfg.cpp >index b604fd1041e..5335e64661b 100644 >--- a/Source/JavaScriptCore/dfg/testdfg.cpp >+++ b/Source/JavaScriptCore/dfg/testdfg.cpp >@@ -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()); >diff --git a/Source/JavaScriptCore/dynbench.cpp b/Source/JavaScriptCore/dynbench.cpp >index bb9d3b590c0..0c7e4c7930e 100644 >--- a/Source/JavaScriptCore/dynbench.cpp >+++ b/Source/JavaScriptCore/dynbench.cpp >@@ -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(testName, filter) == WTF::notFound) > return; > > if (requestedIterationCount) >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 70bf0c5fc50..bc02c9b9adc 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,15 @@ >+2019-04-25 Don Olmstead <don.olmstead@sony.com> >+ >+ Add WTF::findIgnoringASCIICaseWithoutLength to replace strcasestr >+ https://bugs.webkit.org/show_bug.cgi?id=197291 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds an implementation of strcasestr within WTF. >+ >+ * wtf/text/StringCommon.h: >+ (WTF::findIgnoringASCIICaseWithoutLength): >+ > 2019-04-25 Alex Christensen <achristensen@webkit.org> > > Fix High Sierra build after r244653 >diff --git a/Source/WTF/wtf/text/StringCommon.h b/Source/WTF/wtf/text/StringCommon.h >index f756a1495a1..6a7df966d88 100644 >--- a/Source/WTF/wtf/text/StringCommon.h >+++ b/Source/WTF/wtf/text/StringCommon.h >@@ -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) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197291
:
368260
|
368265