WebKit Bugzilla
Attachment 361478 Details for
Bug 192405
: [WTF] Add environment variable helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Checkpoint for EWS
bug-192405-20190207175711.patch (text/plain), 57.24 KB, created by
Ross Kirsling
on 2019-02-07 17:57:12 PST
(
hide
)
Description:
Checkpoint for EWS
Filename:
MIME Type:
Creator:
Ross Kirsling
Created:
2019-02-07 17:57:12 PST
Size:
57.24 KB
patch
obsolete
>Subversion Revision: 241123 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index e8524781d548e68a4dab414db9aaf6f823b2a0c0..045ce93e14f8dd2cd8ddf5c2c51c1aee5b52398d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-07 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/remote/glib/RemoteInspectorGlib.cpp: >+ (Inspector::RemoteInspector::RemoteInspector): >+ (Inspector::RemoteInspector::start): >+ * jsc.cpp: >+ (startTimeoutThreadIfNeeded): >+ * runtime/Options.cpp: >+ (JSC::overrideOptionWithHeuristic): >+ (JSC::Options::overrideAliasedOptionWithHeuristic): >+ (JSC::Options::initialize): >+ * runtime/VM.cpp: >+ (JSC::enableAssembler): >+ (JSC::VM::VM): >+ * tools/CodeProfiling.cpp: >+ (JSC::CodeProfiling::notifyAllocator): >+ > 2019-02-06 Yusuke Suzuki <ysuzuki@apple.com> > > [JSC] Use BufferInternal single character StringImpl for SmallStrings >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 65684330426e758849b51e259223d37e3270e59e..cea6b9da951d749921add5f32c1611298aa929e1 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,29 @@ >+2019-02-07 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WTF.xcodeproj/project.pbxproj: >+ * wtf/CMakeLists.txt: >+ * wtf/Environment.h: Added. >+ * wtf/PlatformGTK.cmake: >+ * wtf/PlatformJSCOnly.cmake: >+ * wtf/PlatformMac.cmake: >+ * wtf/PlatformPlayStation.cmake: >+ * wtf/PlatformWPE.cmake: >+ * wtf/PlatformWin.cmake: >+ * wtf/posix/EnvironmentPOSIX.cpp: Added. >+ * wtf/win/EnvironmentWin.cpp: Added. >+ >+ * wtf/DataLog.cpp: >+ (WTF::initializeLogFileOnce): >+ * wtf/NumberOfCores.cpp: >+ (WTF::numberOfProcessorCores): >+ * wtf/posix/FileSystemPOSIX.cpp: >+ (WTF::FileSystemImpl::openTemporaryFile): >+ > 2019-02-05 Keith Rollin <krollin@apple.com> > > Enable the automatic checking and regenerations of .xcfilelists during builds >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c2a1672b1bf022b6bbcffcdc5ef172431e7de24c..ad2b74dda934e860a7311147013ac6eef8111811 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,52 @@ >+2019-02-07 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * platform/NotImplemented.h: >+ * platform/cocoa/SystemVersion.mm: >+ (WebCore::createSystemMarketingVersion): >+ * platform/graphics/gstreamer/GStreamerCommon.cpp: >+ (WebCore::initializeGStreamer): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: >+ (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): >+ * platform/graphics/nicosia/NicosiaPaintingEngine.cpp: >+ (Nicosia::PaintingEngine::create): >+ * platform/graphics/texmap/TextureMapperFPSCounter.cpp: >+ (WebCore::TextureMapperFPSCounter::TextureMapperFPSCounter): >+ * platform/graphics/x11/PlatformDisplayX11.cpp: >+ (WebCore::PlatformDisplayX11::create): >+ * platform/gtk/RenderThemeWidget.cpp: >+ (WebCore::RenderThemeScrollbar::RenderThemeScrollbar): >+ * platform/gtk/ScrollbarThemeGtk.cpp: >+ (WebCore::ScrollbarThemeGtk::ScrollbarThemeGtk): >+ * platform/network/curl/CurlContext.cpp: >+ (WebCore::CurlContext::CurlContext): >+ (WebCore::EnvironmentVariableReader::read): Deleted. >+ (WebCore::EnvironmentVariableReader::defined): Deleted. >+ (WebCore::EnvironmentVariableReader::readAs): Deleted. >+ (WebCore::EnvironmentVariableReader::sscanTemplate): Deleted. >+ (WebCore::EnvironmentVariableReader::sscanTemplate<signed>): Deleted. >+ (WebCore::EnvironmentVariableReader::sscanTemplate<unsigned>): Deleted. >+ * platform/network/curl/NetworkStorageSessionCurl.cpp: >+ (WebCore::defaultCookieJarPath): >+ * platform/network/playstation/CurlSSLHandlePlayStation.cpp: >+ (WebCore::CurlSSLHandle::platformInitialize): >+ (WebCore::getCACertPathEnv): Deleted. >+ * platform/network/win/CurlSSLHandleWin.cpp: >+ (WebCore::getCACertPathEnv): >+ * platform/text/hyphen/HyphenationLibHyphen.cpp: >+ (WebCore::topLevelPath): >+ (WebCore::webkitBuildDirectory): >+ * platform/unix/LoggingUnix.cpp: >+ (WebCore::logLevelString): >+ * platform/win/LoggingWin.cpp: >+ (WebCore::logLevelString): >+ > 2019-02-07 Zalan Bujtas <zalan@apple.com> > > [LFC][Out-of-flow] Use the containing block's padding width when computing min/max width. >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index 0486533c220e50529b2bf4d0b61511f0a1aa306f..793363d66abb8511024157f479c63b106198e779 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-07 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * pal/unix/LoggingUnix.cpp: >+ (PAL::logLevelString): >+ * pal/win/LoggingWin.cpp: >+ (PAL::logLevelString): >+ > 2019-02-05 Ryan Haddad <ryanhaddad@apple.com> > > Unreviewed, rolling out r240742. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index e2486afb93e7cfeee767490eeafaa921d8278a9b..45826e56d3d06f3068546071cd08a8879466cb85 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-07 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Platform/unix/LoggingUnix.cpp: >+ (WebKit::logLevelString): >+ * Platform/win/LoggingWin.cpp: >+ (WebKit::logLevelString): >+ > 2019-02-07 Miguel Gomez <magomez@igalia.com> > > [WPE] Implement GStreamer based holepunch >diff --git a/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp b/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp >index b73455a40cc15d56353ff694fb65340182924c48..9d9acdbea8f8a59eef7adf483e5853044607c840 100644 >--- a/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp >+++ b/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp >@@ -32,6 +32,7 @@ > #include "RemoteConnectionToTarget.h" > #include "RemoteInspectionTarget.h" > #include <gio/gio.h> >+#include <wtf/Environment.h> > #include <wtf/NeverDestroyed.h> > #include <wtf/RunLoop.h> > #include <wtf/glib/GUniquePtr.h> >@@ -51,8 +52,10 @@ RemoteInspector& RemoteInspector::singleton() > > RemoteInspector::RemoteInspector() > { >- if (g_getenv("WEBKIT_INSPECTOR_SERVER")) >- start(); >+ if (!Environment::get("WEBKIT_INSPECTOR_SERVER")) >+ return; >+ >+ start(); > } > > void RemoteInspector::start() >@@ -65,7 +68,8 @@ void RemoteInspector::start() > m_enabled = true; > m_cancellable = adoptGRef(g_cancellable_new()); > >- GUniquePtr<char> inspectorAddress(g_strdup(g_getenv("WEBKIT_INSPECTOR_SERVER"))); >+ auto inspectorServerString = Environment::get("WEBKIT_INSPECTOR_SERVER").utf8().data(); >+ GUniquePtr<char> inspectorAddress(g_strdup(inspectorServerString)); > char* portPtr = g_strrstr(inspectorAddress.get(), ":"); > ASSERT(portPtr); > *portPtr = '\0'; >@@ -73,13 +77,13 @@ void RemoteInspector::start() > unsigned port = g_ascii_strtoull(portPtr, nullptr, 10); > GUniquePtr<char> dbusAddress(g_strdup_printf("tcp:host=%s,port=%u", inspectorAddress.get(), port)); > g_dbus_connection_new_for_address(dbusAddress.get(), G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, nullptr, m_cancellable.get(), >- [](GObject*, GAsyncResult* result, gpointer userData) { >+ [inspectorServerString](GObject*, GAsyncResult* result, gpointer userData) { > RemoteInspector* inspector = static_cast<RemoteInspector*>(userData); > GUniqueOutPtr<GError> error; > if (GRefPtr<GDBusConnection> connection = adoptGRef(g_dbus_connection_new_for_address_finish(result, &error.outPtr()))) > inspector->setupConnection(WTFMove(connection)); > else if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) >- WTFLogAlways("RemoteInspector failed to connect to inspector server at: %s: %s", g_getenv("WEBKIT_INSPECTOR_SERVER"), error->message); >+ WTFLogAlways("RemoteInspector failed to connect to inspector server at: %s: %s", inspectorServerString, error->message); > }, this); > } > >diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp >index be0180605e6e8abf48ab711b86c9d4fc98c05f1a..8acb369a7b60cdcd441deb1bfd7ac2676b1216e5 100644 >--- a/Source/JavaScriptCore/jsc.cpp >+++ b/Source/JavaScriptCore/jsc.cpp >@@ -83,6 +83,7 @@ > #include <type_traits> > #include <wtf/Box.h> > #include <wtf/CommaPrinter.h> >+#include <wtf/Environment.h> > #include <wtf/MainThread.h> > #include <wtf/MemoryPressureHandler.h> > #include <wtf/MonotonicTime.h> >@@ -2250,19 +2251,23 @@ static double s_timeoutMultiplier = 1.0; > > static void startTimeoutThreadIfNeeded() > { >- if (char* timeoutString = getenv("JSCTEST_timeout")) { >- if (sscanf(timeoutString, "%lf", &s_desiredTimeout) != 1) { >- dataLog("WARNING: timeout string is malformed, got ", timeoutString, >- " but expected a number. Not using a timeout.\n"); >- } else { >- Thread::create("jsc Timeout Thread", [] () { >- Seconds timeoutDuration(s_desiredTimeout * s_timeoutMultiplier); >- sleep(timeoutDuration); >- dataLog("Timed out after ", timeoutDuration, " seconds!\n"); >- CRASH(); >- }); >- } >+ auto timeoutString = Environment::get("JSCTEST_timeout"); >+ if (!timeoutString) >+ return; >+ >+ bool ok; >+ s_desiredTimeout = timeoutString.toDouble(&ok); >+ if (!ok) { >+ dataLog("WARNING: timeout string is malformed, got ", timeoutString, " but expected a number. Not using a timeout.\n"); >+ return; > } >+ >+ Thread::create("jsc Timeout Thread", [] () { >+ Seconds timeoutDuration(s_desiredTimeout * s_timeoutMultiplier); >+ sleep(timeoutDuration); >+ dataLog("Timed out after ", timeoutDuration, " seconds!\n"); >+ CRASH(); >+ }); > } > > int main(int argc, char** argv) >diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp >index 84d7326a24fbe5a5de03c5c38dbf2bdedf2360cb..df114b47e327a11c4b76246ead4ac4e46ce98b69 100644 >--- a/Source/JavaScriptCore/runtime/Options.cpp >+++ b/Source/JavaScriptCore/runtime/Options.cpp >@@ -39,6 +39,7 @@ > #include <wtf/ASCIICType.h> > #include <wtf/Compiler.h> > #include <wtf/DataLog.h> >+#include <wtf/Environment.h> > #include <wtf/NumberOfCores.h> > #include <wtf/PointerPreparations.h> > #include <wtf/StdLibExtras.h> >@@ -176,7 +177,7 @@ bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name, > bool available = (availability == Options::Availability::Normal) > || Options::isAvailable(id, availability); > >- const char* stringValue = getenv(name); >+ auto stringValue = Environment::get(name).utf8().data(); > if (!stringValue) > return false; > >@@ -189,7 +190,7 @@ bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name, > > bool Options::overrideAliasedOptionWithHeuristic(const char* name) > { >- const char* stringValue = getenv(name); >+ auto stringValue = Environment::get(name).utf8().data(); > if (!stringValue) > return false; > >@@ -597,9 +598,8 @@ void Options::initialize() > > #if ASAN_ENABLED && OS(LINUX) && ENABLE(WEBASSEMBLY_FAST_MEMORY) > if (Options::useWebAssemblyFastMemory()) { >- const char* asanOptions = getenv("ASAN_OPTIONS"); >- bool okToUseWebAssemblyFastMemory = asanOptions >- && (strstr(asanOptions, "allow_user_segv_handler=1") || strstr(asanOptions, "handle_segv=0")); >+ auto asanOptions = Environment::get("ASAN_OPTIONS"); >+ bool okToUseWebAssemblyFastMemory = asanOptions.contains("allow_user_segv_handler=1") || asanOptions.contains("handle_segv=0"); > if (!okToUseWebAssemblyFastMemory) { > dataLogLn("WARNING: ASAN interferes with JSC signal handlers; useWebAssemblyFastMemory will be disabled."); > Options::useWebAssemblyFastMemory() = false; >diff --git a/Source/JavaScriptCore/runtime/VM.cpp b/Source/JavaScriptCore/runtime/VM.cpp >index a3091d09693f89c8355e4cde07d87c8cb3d3b9fe..b930eb4c56dd9cf824e8afbbd3a46092bb7ad90d 100644 >--- a/Source/JavaScriptCore/runtime/VM.cpp >+++ b/Source/JavaScriptCore/runtime/VM.cpp >@@ -149,6 +149,7 @@ > #include "WeakGCMapInlines.h" > #include "WebAssemblyFunction.h" > #include "WebAssemblyWrapperFunction.h" >+#include <wtf/Environment.h> > #include <wtf/ProcessID.h> > #include <wtf/ReadWriteLock.h> > #include <wtf/SimpleStats.h> >@@ -197,8 +198,7 @@ static bool enableAssembler(ExecutableAllocator& executableAllocator) > return false; > } > >- char* canUseJITString = getenv("JavaScriptCoreUseJIT"); >- return !canUseJITString || atoi(canUseJITString); >+ return !Environment::hasValue("JavaScriptCoreUseJIT", "0"); > } > #endif // ENABLE(!ASSEMBLER) > >@@ -428,7 +428,7 @@ VM::VM(VMType vmType, HeapType heapType) > m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this); > > StringPrintStream pathOut; >- const char* profilerPath = getenv("JSC_PROFILER_PATH"); >+ auto profilerPath = Environment::get("JSC_PROFILER_PATH").utf8().data(); > if (profilerPath) > pathOut.print(profilerPath, "/"); > pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json"); >diff --git a/Source/JavaScriptCore/tools/CodeProfiling.cpp b/Source/JavaScriptCore/tools/CodeProfiling.cpp >index 94ebe8e2ca7e189f8f6d8d5f64d90f9d061c97df..f8ea799ca6833b5cc1d7ec885cc2f8158a4f2c73 100644 >--- a/Source/JavaScriptCore/tools/CodeProfiling.cpp >+++ b/Source/JavaScriptCore/tools/CodeProfiling.cpp >@@ -28,6 +28,7 @@ > > #include "CodeProfile.h" > #include "MachineContext.h" >+#include <wtf/Environment.h> > #include <wtf/MetaAllocator.h> > > #if HAVE(SIGNAL_H) >@@ -85,21 +86,19 @@ void CodeProfiling::sample(void* pc, void** framePointer) > void CodeProfiling::notifyAllocator(WTF::MetaAllocator* allocator) > { > // Check for JSC_CODE_PROFILING. >- const char* codeProfilingMode = getenv("JSC_CODE_PROFILING"); >+ auto codeProfilingMode = Environment::getUInt("JSC_CODE_PROFILING"); > if (!codeProfilingMode) > return; > >- // Check for a valid mode, currently "1", "2", or "3". >- if (!codeProfilingMode[0] || codeProfilingMode[1]) >- return; >+ // Check for a valid mode, currently 1, 2, or 3. > switch (*codeProfilingMode) { >- case '1': >+ case 1: > s_mode = Enabled; > break; >- case '2': >+ case 2: > s_mode = Verbose; > break; >- case '3': >+ case 3: > s_mode = VeryVerbose; > break; > default: >diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj >index e54641d892cbbba8ec8d580cc6cb807d11a4b598..7e5ae223bd779b4d11a085e4be10b3bc2aa3c9c8 100644 >--- a/Source/WTF/WTF.xcodeproj/project.pbxproj >+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj >@@ -89,6 +89,7 @@ > 93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; }; > 93F1993E19D7958D00C2390B /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1993D19D7958D00C2390B /* StringView.cpp */; }; > 9BC70F05176C379D00101DEC /* AtomicStringTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC70F04176C379D00101DEC /* AtomicStringTable.cpp */; }; >+ A307FD29220CB4350021B62C /* EnvironmentPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */; }; > A32D8FA521FFFAB400780662 /* ThreadingPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */; }; > A331D95B21F24992009F02AA /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95A21F24992009F02AA /* FileSystem.cpp */; }; > A331D95D21F249E4009F02AA /* FileSystemCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95C21F249E4009F02AA /* FileSystemCF.cpp */; }; >@@ -437,6 +438,8 @@ > 9BC70F04176C379D00101DEC /* AtomicStringTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomicStringTable.cpp; sourceTree = "<group>"; }; > 9BD8F40A176C2AD80002D865 /* AtomicStringTable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtomicStringTable.h; sourceTree = "<group>"; }; > 9C67C542589348E285B49699 /* IndexedContainerIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexedContainerIterator.h; sourceTree = "<group>"; }; >+ A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnvironmentPOSIX.cpp; sourceTree = "<group>"; }; >+ A307FD2A220CB4490021B62C /* Environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Environment.h; sourceTree = "<group>"; }; > A30D412C1F0DE0BA00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; }; > A30D412D1F0DE13F00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; }; > A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPOSIX.cpp; sourceTree = "<group>"; }; >@@ -800,6 +803,7 @@ > A331D96321F24A2E009F02AA /* posix */ = { > isa = PBXGroup; > children = ( >+ A307FD28220CB4350021B62C /* EnvironmentPOSIX.cpp */, > A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */, > A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */, > A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */, >@@ -929,6 +933,7 @@ > FE05FAE61FDB214300093230 /* DumbPtrTraits.h */, > AD653DA82006B6C200D820D7 /* DumbValueTraits.h */, > 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */, >+ A307FD2A220CB4490021B62C /* Environment.h */, > AD7C434A1DD2A4A70026888B /* Expected.h */, > A8A4729F151A825A004123FF /* ExportMacros.h */, > 0F7C5FB51D885CF20044F5E2 /* FastBitVector.cpp */, >@@ -1026,8 +1031,6 @@ > A8A472CE151A825B004123FF /* MetaAllocator.h */, > A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */, > FE7497ED209163060003565B /* MetaAllocatorPtr.h */, >- 5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */, >- 5FAD3AE021B9636600BEE178 /* URLHelpers.h */, > 0F66B2821DC97BAB004A1D3F /* MonotonicTime.cpp */, > 0F66B2831DC97BAB004A1D3F /* MonotonicTime.h */, > FE8225301B2A1E5B00BA68FD /* NakedPtr.h */, >@@ -1175,6 +1178,8 @@ > 5CC0EE7121629F1800A1A842 /* URL.h */, > 5C1F0597216439940039302C /* URLHash.h */, > 5CC0EE772162A01000A1A842 /* URLHash.h */, >+ 5FAD3AE121B9636600BEE178 /* URLHelpers.cpp */, >+ 5FAD3AE021B9636600BEE178 /* URLHelpers.h */, > 5CC0EE7321629F1900A1A842 /* URLParser.cpp */, > 5CC0EE7221629F1900A1A842 /* URLParser.h */, > 7AFEC6B01EB22B5900DADE36 /* UUID.cpp */, >@@ -1520,6 +1525,7 @@ > A8A473B0151A825B004123FF /* double-conversion.cc in Sources */, > A8A473BA151A825B004123FF /* dtoa.cpp in Sources */, > 143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */, >+ A307FD29220CB4350021B62C /* EnvironmentPOSIX.cpp in Sources */, > 50DE35F5215BB01500B979C7 /* ExternalStringImpl.cpp in Sources */, > A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */, > 0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */, >@@ -1557,7 +1563,6 @@ > 5CC0EE8A2162BC2200A1A842 /* NSURLExtras.mm in Sources */, > A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */, > 8348BA0E21FBC0D500FD3054 /* ObjectIdentifier.cpp in Sources */, >- 5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */, > A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */, > A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */, > A8A47402151A825B004123FF /* PageBlock.cpp in Sources */, >@@ -1614,6 +1619,7 @@ > 5CC0EE7621629F1900A1A842 /* URL.cpp in Sources */, > 5C1F0595216437B30039302C /* URLCF.cpp in Sources */, > 5CC0EE892162BC2200A1A842 /* URLCocoa.mm in Sources */, >+ 5FAD3AE221B9636600BEE178 /* URLHelpers.cpp in Sources */, > 5CC0EE7521629F1900A1A842 /* URLParser.cpp in Sources */, > 1C181C8F1D307AB800F5FA16 /* UTextProvider.cpp in Sources */, > 1C181C911D307AB800F5FA16 /* UTextProviderLatin1.cpp in Sources */, >diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt >index 1f12b79f86a5a6f59c522973e9500178d3aa1740..8104da3b8d9ca4b0c118f899ef99ebddf28652a0 100644 >--- a/Source/WTF/wtf/CMakeLists.txt >+++ b/Source/WTF/wtf/CMakeLists.txt >@@ -55,6 +55,7 @@ set(WTF_PUBLIC_HEADERS > DumbPtrTraits.h > DumbValueTraits.h > EnumTraits.h >+ Environment.h > Expected.h > ExportMacros.h > FastBitVector.h >diff --git a/Source/WTF/wtf/DataLog.cpp b/Source/WTF/wtf/DataLog.cpp >index 57f9eb20d428852f7d00661dd4c50b9fef326afd..a695ab791ef06331ef7e698fb030585bf9915750 100644 >--- a/Source/WTF/wtf/DataLog.cpp >+++ b/Source/WTF/wtf/DataLog.cpp >@@ -26,14 +26,15 @@ > #include "config.h" > #include <wtf/DataLog.h> > >+#include <mutex> > #include <stdarg.h> > #include <string.h> >+#include <thread> >+#include <wtf/Environment.h> > #include <wtf/FilePrintStream.h> > #include <wtf/LockedPrintStream.h> > #include <wtf/ProcessID.h> > #include <wtf/Threading.h> >-#include <mutex> >-#include <thread> > > #if OS(UNIX) || OS(DARWIN) > #include <unistd.h> >@@ -93,7 +94,7 @@ static void initializeLogFileOnce() > #elif defined(DATA_LOG_FILENAME) > filename = DATA_LOG_FILENAME; > #else >- filename = getenv("WTF_DATA_LOG_FILENAME"); >+ filename = Environment::get("WTF_DATA_LOG_FILENAME").utf8().data(); > #endif > char actualFilename[maxPathLength + 1]; > >diff --git a/Source/WTF/wtf/Environment.h b/Source/WTF/wtf/Environment.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8834ad183fcc005e1cf51cb558716acb047de6ca >--- /dev/null >+++ b/Source/WTF/wtf/Environment.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2019 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/Optional.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WTF { >+namespace EnvironmentImpl { >+ >+WTF_EXPORT_PRIVATE String get(const String&); >+inline bool hasValue(const String& variable, const String& value) { return get(variable) == value; } >+ >+inline Optional<int> getInt(const String& variable) >+{ >+ bool ok; >+ auto value = get(variable).toIntStrict(&ok); >+ return ok ? Optional<int>(value) : WTF::nullopt; >+} >+ >+inline Optional<unsigned> getUInt(const String& variable) >+{ >+ bool ok; >+ auto value = get(variable).toUIntStrict(&ok); >+ return ok ? Optional<unsigned>(value) : WTF::nullopt; >+} >+ >+// set overwrites any existing value; add does not. >+WTF_EXPORT_PRIVATE void set(const String& variable, const String& value); >+WTF_EXPORT_PRIVATE void add(const String& variable, const String& value); >+ >+WTF_EXPORT_PRIVATE void remove(const String&); >+ >+ >+} // namespace EnvironmentImpl >+} // namespace WTF >+ >+namespace Environment = WTF::EnvironmentImpl; >diff --git a/Source/WTF/wtf/NumberOfCores.cpp b/Source/WTF/wtf/NumberOfCores.cpp >index 62fa65a04214eb917365e86747f963c84046c223..4a8cfaee8054f06050dea3d229568921475c66f6 100644 >--- a/Source/WTF/wtf/NumberOfCores.cpp >+++ b/Source/WTF/wtf/NumberOfCores.cpp >@@ -27,6 +27,7 @@ > #include <wtf/NumberOfCores.h> > > #include <cstdio> >+#include <wtf/Environment.h> > > #if OS(DARWIN) > #include <sys/param.h> >@@ -50,13 +51,16 @@ int numberOfProcessorCores() > if (s_numberOfCores > 0) > return s_numberOfCores; > >- if (const char* coresEnv = getenv("WTF_numberOfProcessorCores")) { >- unsigned numberOfCores; >- if (sscanf(coresEnv, "%u", &numberOfCores) == 1) { >+ auto coresEnv = Environment::get("WTF_numberOfProcessorCores"); >+ if (!!coresEnv) { >+ bool ok; >+ auto numberOfCores = coresEnv.toUIntStrict(&ok); >+ if (ok) { > s_numberOfCores = numberOfCores; > return s_numberOfCores; >- } else >- fprintf(stderr, "WARNING: failed to parse WTF_numberOfProcessorCores=%s\n", coresEnv); >+ } >+ >+ fprintf(stderr, "WARNING: failed to parse WTF_numberOfProcessorCores=%s\n", coresEnv.utf8().data()); > } > > #if OS(DARWIN) >diff --git a/Source/WTF/wtf/PlatformGTK.cmake b/Source/WTF/wtf/PlatformGTK.cmake >index 297d0fa2c78f3961b0f4c3e17193fba6e5e4a3f5..b55d0ec5703c0122147a5cbb258ea8d7107d8964 100644 >--- a/Source/WTF/wtf/PlatformGTK.cmake >+++ b/Source/WTF/wtf/PlatformGTK.cmake >@@ -28,6 +28,7 @@ list(APPEND WTF_SOURCES > glib/RunLoopGLib.cpp > glib/URLGLib.cpp > >+ posix/EnvironmentPOSIX.cpp > posix/OSAllocatorPOSIX.cpp > posix/ThreadingPOSIX.cpp > >diff --git a/Source/WTF/wtf/PlatformJSCOnly.cmake b/Source/WTF/wtf/PlatformJSCOnly.cmake >index 3542fef6f90ee0a65891b3a37606545c9ac77c41..1932a7ff6bb8280cb4d58dec475ab9e9bee2f2a9 100644 >--- a/Source/WTF/wtf/PlatformJSCOnly.cmake >+++ b/Source/WTF/wtf/PlatformJSCOnly.cmake >@@ -8,6 +8,7 @@ if (WIN32) > > win/CPUTimeWin.cpp > win/DbgHelperWin.cpp >+ win/EnvironmentWin.cpp > win/FileSystemWin.cpp > win/LanguageWin.cpp > win/MainThreadWin.cpp >@@ -33,6 +34,7 @@ else () > > generic/MainThreadGeneric.cpp > >+ posix/EnvironmentPOSIX.cpp > posix/FileSystemPOSIX.cpp > posix/OSAllocatorPOSIX.cpp > posix/ThreadingPOSIX.cpp >diff --git a/Source/WTF/wtf/PlatformMac.cmake b/Source/WTF/wtf/PlatformMac.cmake >index 9a1f510b409f10e0232f1f1e0e2e2e59df14cb16..339f2bb4b7cbda4538269ce4c2f9574a81bb1f0b 100644 >--- a/Source/WTF/wtf/PlatformMac.cmake >+++ b/Source/WTF/wtf/PlatformMac.cmake >@@ -64,6 +64,7 @@ list(APPEND WTF_SOURCES > mac/FileSystemMac.mm > mac/SchedulePairMac.mm > >+ posix/EnvironmentPOSIX.cpp > posix/FileSystemPOSIX.cpp > posix/OSAllocatorPOSIX.cpp > posix/ThreadingPOSIX.cpp >diff --git a/Source/WTF/wtf/PlatformPlayStation.cmake b/Source/WTF/wtf/PlatformPlayStation.cmake >index 4b6919076f391051b85e39b06f215dc9ab458681..fc4a29ff34a7574be68a5e8cee7c3b2b90e7381c 100644 >--- a/Source/WTF/wtf/PlatformPlayStation.cmake >+++ b/Source/WTF/wtf/PlatformPlayStation.cmake >@@ -5,6 +5,7 @@ list(APPEND WTF_SOURCES > generic/RunLoopGeneric.cpp > generic/WorkQueueGeneric.cpp > >+ posix/EnvironmentPOSIX.cpp > posix/FileSystemPOSIX.cpp > posix/OSAllocatorPOSIX.cpp > posix/ThreadingPOSIX.cpp >diff --git a/Source/WTF/wtf/PlatformWPE.cmake b/Source/WTF/wtf/PlatformWPE.cmake >index 38e632c3ef8b3137aa9711990e71455fbaa032cc..eb5f739b2c3bd84fc85b5f1c165d24461a7a96fd 100644 >--- a/Source/WTF/wtf/PlatformWPE.cmake >+++ b/Source/WTF/wtf/PlatformWPE.cmake >@@ -26,6 +26,7 @@ list(APPEND WTF_SOURCES > linux/MemoryFootprintLinux.cpp > linux/MemoryPressureHandlerLinux.cpp > >+ posix/EnvironmentPOSIX.cpp > posix/OSAllocatorPOSIX.cpp > posix/ThreadingPOSIX.cpp > >diff --git a/Source/WTF/wtf/PlatformWin.cmake b/Source/WTF/wtf/PlatformWin.cmake >index 2c34022549d8840eb9230284a1ddd9d285239aae..f65e12155f0deba956d408bf4ef91ab1d2756541 100644 >--- a/Source/WTF/wtf/PlatformWin.cmake >+++ b/Source/WTF/wtf/PlatformWin.cmake >@@ -12,6 +12,7 @@ list(APPEND WTF_SOURCES > > win/CPUTimeWin.cpp > win/DbgHelperWin.cpp >+ win/EnvironmentWin.cpp > win/FileSystemWin.cpp > win/LanguageWin.cpp > win/MainThreadWin.cpp >diff --git a/Source/WTF/wtf/posix/EnvironmentPOSIX.cpp b/Source/WTF/wtf/posix/EnvironmentPOSIX.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b014632bdef205a9681c2aa2d712306d3f3df902 >--- /dev/null >+++ b/Source/WTF/wtf/posix/EnvironmentPOSIX.cpp >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2019 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/Environment.h> >+ >+#include <stdlib.h> >+ >+namespace WTF { >+namespace EnvironmentImpl { >+ >+String get(const String& variable) >+{ >+ return String::fromUTF8(getenv(variable.utf8().data())); >+} >+ >+void set(const String& variable, const String& value) >+{ >+ setenv(variable.utf8().data(), value.utf8().data(), 1); >+} >+ >+void add(const String& variable, const String& value) >+{ >+ setenv(variable.utf8().data(), value.utf8().data(), 0); >+} >+ >+void remove(const String& variable) >+{ >+ unsetenv(variable.utf8().data()); >+} >+ >+} // namespace EnvironmentImpl >+} // namespace WTF >diff --git a/Source/WTF/wtf/posix/FileSystemPOSIX.cpp b/Source/WTF/wtf/posix/FileSystemPOSIX.cpp >index 70d2f98e4d72c2cd15994e9fa7f7a9bc4bf0af56..717fc9c6c075ca8f6bf7862addbc426d37a06469 100644 >--- a/Source/WTF/wtf/posix/FileSystemPOSIX.cpp >+++ b/Source/WTF/wtf/posix/FileSystemPOSIX.cpp >@@ -40,6 +40,7 @@ > #include <sys/types.h> > #include <unistd.h> > #include <wtf/EnumTraits.h> >+#include <wtf/Environment.h> > #include <wtf/FileMetadata.h> > #include <wtf/text/CString.h> > #include <wtf/text/StringBuilder.h> >@@ -424,7 +425,7 @@ bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace) > String openTemporaryFile(const String& prefix, PlatformFileHandle& handle) > { > char buffer[PATH_MAX]; >- const char* tmpDir = getenv("TMPDIR"); >+ auto tmpDir = Environment::get("TMPDIR").utf8().data(); > > if (!tmpDir) > tmpDir = "/tmp"; >diff --git a/Source/WTF/wtf/win/EnvironmentWin.cpp b/Source/WTF/wtf/win/EnvironmentWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..147621442c0e8177a5ce88ef9b4d616b50c05e11 >--- /dev/null >+++ b/Source/WTF/wtf/win/EnvironmentWin.cpp >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2019 Sony Interactive Entertainment Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/Environment.h> >+ >+#include <windows.h> >+#include <wtf/Vector.h> >+ >+namespace WTF { >+namespace EnvironmentImpl { >+ >+String get(const String& variable) >+{ >+ auto rawVariable = variable.charactersWithNullTermination().data(); >+ auto length = ::GetEnvironmentVariableW(rawVariable, nullptr, 0); >+ if (!length) >+ return { }; >+ >+ Vector<UChar> buffer(length); >+ if (!::GetEnvironmentVariableW(rawVariable, buffer.data(), length)) >+ return { }; >+ >+ return buffer.data(); >+} >+ >+void set(const String& variable, const String& value) >+{ >+ ::SetEnvironmentVariableW(variable.charactersWithNullTermination().data(), value.charactersWithNullTermination().data()); >+} >+ >+void add(const String& variable, const String& value) >+{ >+ if (!!get(variable)) >+ return; >+ >+ set(variable, value); >+} >+ >+void remove(const String& variable) >+{ >+ ::SetEnvironmentVariableW(variable.charactersWithNullTermination().data(), nullptr); >+} >+ >+} // namespace EnvironmentImpl >+} // namespace WTF >diff --git a/Source/WebCore/PAL/pal/unix/LoggingUnix.cpp b/Source/WebCore/PAL/pal/unix/LoggingUnix.cpp >index 24734f902c14ab1e8c922762c32f74de7481942e..ebabcda9e55ab4d25b8a6dac9af8f9f477f8373c 100644 >--- a/Source/WebCore/PAL/pal/unix/LoggingUnix.cpp >+++ b/Source/WebCore/PAL/pal/unix/LoggingUnix.cpp >@@ -26,26 +26,29 @@ > #include "config.h" > #include "Logging.h" > >-#include <wtf/text/WTFString.h> >- > #if !LOG_DISABLED || !RELEASE_LOG_DISABLED > >+#include <wtf/Environment.h> >+#include <wtf/text/WTFString.h> >+ > namespace PAL { > > String logLevelString() > { > #if !LOG_DISABLED >- if (char* logEnv = getenv("WEBKIT_DEBUG")) { >+ auto logEnv = Environment::get("WEBKIT_DEBUG"); >+ if (!logEnv) >+ return emptyString(); > > #if defined(NDEBUG) >- WTFLogAlways("WEBCORE_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build."); >+ WTFLogAlways("WEBKIT_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build."); > #endif > >- // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1. >- return makeString("NotYetImplemented,"_s, logEnv); >- } >-#endif >+ // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1. >+ return makeString("NotYetImplemented,"_s, logEnv); >+#else > return String(); >+#endif > } > > } // namespace PAL >diff --git a/Source/WebCore/PAL/pal/win/LoggingWin.cpp b/Source/WebCore/PAL/pal/win/LoggingWin.cpp >index 6b232c4db4876527c73595caf8d1669a93eae048..7fc2ecd859996b14ac91c664800b9cb21c816cd2 100644 >--- a/Source/WebCore/PAL/pal/win/LoggingWin.cpp >+++ b/Source/WebCore/PAL/pal/win/LoggingWin.cpp >@@ -29,7 +29,7 @@ > #if !LOG_DISABLED || !RELEASE_LOG_DISABLED > > #include <windows.h> >-#include <wtf/StdLibExtras.h> >+#include <wtf/Environment.h> > #include <wtf/text/WTFString.h> > > namespace PAL { >@@ -37,17 +37,7 @@ namespace PAL { > String logLevelString() > { > #if !LOG_DISABLED >- static char* const loggingEnvironmentVariable = "WebCoreLogging"; >- DWORD length = GetEnvironmentVariableA(loggingEnvironmentVariable, 0, 0); >- if (!length) >- return emptyString(); >- >- Vector<char> buffer(length); >- >- if (!GetEnvironmentVariableA(loggingEnvironmentVariable, buffer.data(), length)) >- return emptyString(); >- >- return String(buffer.data()); >+ return Environment::get("WebCoreLogging"); > #else > return String(); > #endif >diff --git a/Source/WebCore/platform/NotImplemented.h b/Source/WebCore/platform/NotImplemented.h >index 72af706d40e1279aea9ece08a6b77add486db151..f9e3acd3da0c289df493c208d82d3d18ee6afc7c 100644 >--- a/Source/WebCore/platform/NotImplemented.h >+++ b/Source/WebCore/platform/NotImplemented.h >@@ -27,15 +27,16 @@ > #define NotImplemented_h > > #include <wtf/Assertions.h> >+#include <wtf/Environment.h> > > #if PLATFORM(GTK) >- #define suppressNotImplementedWarning() getenv("DISABLE_NI_WARNING") >+#define suppressNotImplementedWarning() !!Environment::get("DISABLE_NI_WARNING") > #else >- #define suppressNotImplementedWarning() false >+#define suppressNotImplementedWarning() false > #endif > > #if LOG_DISABLED >- #define notImplemented() ((void)0) >+#define notImplemented() ((void)0) > #else > > namespace WebCore { >diff --git a/Source/WebCore/platform/cocoa/SystemVersion.mm b/Source/WebCore/platform/cocoa/SystemVersion.mm >index d4c4f5a0d072203f8be800451f4a8a3c827fd916..286136d624dc9e2f19b6da5651fcc7946b6f0fcd 100644 >--- a/Source/WebCore/platform/cocoa/SystemVersion.mm >+++ b/Source/WebCore/platform/cocoa/SystemVersion.mm >@@ -25,6 +25,8 @@ > #include "config.h" > #include "SystemVersion.h" > >+#include <wtf/Environment.h> >+ > namespace WebCore { > > static NSString *createSystemMarketingVersion() >@@ -32,7 +34,8 @@ static NSString *createSystemMarketingVersion() > // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want. > NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0]; > #if PLATFORM(IOS_FAMILY_SIMULATOR) >- if (char *simulatorRoot = getenv("SIMULATOR_ROOT")) >+ auto simulatorRoot = Environment::get("SIMULATOR_ROOT").utf8().data(); >+ if (simulatorRoot) > systemLibraryPath = [NSString stringWithFormat:@"%s/%@", simulatorRoot, systemLibraryPath]; > #endif > NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"]; >diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp >index c32539b2df1f31a0dc9c8f4592db8f6a70a1eba5..a3c5b0436559f1304f55f8abd50e5d872a7b251a 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp >@@ -29,6 +29,7 @@ > #include <gst/audio/audio-info.h> > #include <gst/gst.h> > #include <mutex> >+#include <wtf/Environment.h> > #include <wtf/glib/GLibUtilities.h> > #include <wtf/glib/GUniquePtr.h> > #include <wtf/glib/RunLoopSourcePriority.h> >@@ -237,8 +238,7 @@ bool initializeGStreamer(Optional<Vector<String>>&& options) > g_strfreev(argv); > > if (isFastMallocEnabled()) { >- const char* disableFastMalloc = getenv("WEBKIT_GST_DISABLE_FAST_MALLOC"); >- if (!disableFastMalloc || !strcmp(disableFastMalloc, "0")) >+ if (!Environment::hasValue("WEBKIT_GST_DISABLE_FAST_MALLOC", "0")) > gst_allocator_set_default(GST_ALLOCATOR(g_object_new(gst_allocator_fast_malloc_get_type(), nullptr))); > } > >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >index 4140c11b0ea4798e660d649580fecaad3c26d4c7..1372a01c04a551868cce36dfed6cd438bd6710c6 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >@@ -41,6 +41,7 @@ > #include <gst/gst.h> > #include <gst/pbutils/missing-plugins.h> > #include <limits> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/HexNumber.h> > #include <wtf/MediaTime.h> >@@ -2555,7 +2556,7 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin(const gchar* playbinName, con > ASSERT(!m_pipeline); > > #if GST_CHECK_VERSION(1, 10, 0) >- if (g_getenv("USE_PLAYBIN3")) >+ if (!!Environment::get("USE_PLAYBIN3")) > playbinName = "playbin3"; > #else > playbinName = "playbin"; >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngine.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngine.cpp >index 07ae7a263c05e8dd30ed95534676eae857e40c14..31082624d4acd9422e35d96c868e71bf01ca5092 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngine.cpp >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngine.cpp >@@ -31,15 +31,18 @@ > > #include "NicosiaPaintingEngineBasic.h" > #include "NicosiaPaintingEngineThreaded.h" >+#include <wtf/Environment.h> > > namespace Nicosia { > > std::unique_ptr<PaintingEngine> PaintingEngine::create() > { > #if ENABLE(DEVELOPER_MODE) && PLATFORM(WPE) >- if (const char* numThreadsEnv = getenv("WEBKIT_NICOSIA_PAINTING_THREADS")) { >- unsigned numThreads = 0; >- if (sscanf(numThreadsEnv, "%u", &numThreads) == 1) { >+ auto numThreadsEnv = Environment::get("WEBKIT_NICOSIA_PAINTING_THREADS"); >+ if (!!numThreadsEnv) { >+ bool ok; >+ auto numThreads = numThreadsEnv.toIntStrict(&ok); >+ if (ok) { > if (numThreads < 1 || numThreads > 8) { > WTFLogAlways("The number of Nicosia painting threads is not between 1 and 8. Using the default value 4\n"); > numThreads = 4; >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp >index c8cac48c6c05ecb452157fb231eb64b698ca6f27..dc0aac3153d03a3d7550645b73abee8a69194c36 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp >@@ -20,10 +20,10 @@ > */ > > #include "config.h" >- > #include "TextureMapperFPSCounter.h" > > #include "TextureMapper.h" >+#include <wtf/Environment.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -34,7 +34,7 @@ TextureMapperFPSCounter::TextureMapperFPSCounter() > , m_lastFPS(0) > , m_frameCount(0) > { >- String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS"); >+ auto showFPSEnvironment = Environment::get("WEBKIT_SHOW_FPS"); > bool ok = false; > m_fpsInterval = Seconds(showFPSEnvironment.toDouble(&ok)); > if (ok && m_fpsInterval) { >diff --git a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp b/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp >index 8c81119bc50dbee90a861930220126ab1b0f6803..48e579aed045d6785b0062b0d224362cf6884098 100644 >--- a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp >+++ b/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp >@@ -27,6 +27,7 @@ > #include "PlatformDisplayX11.h" > > #include "GLContext.h" >+#include <wtf/Environment.h> > > #if PLATFORM(X11) > #include <X11/Xlib.h> >@@ -44,7 +45,7 @@ namespace WebCore { > > std::unique_ptr<PlatformDisplay> PlatformDisplayX11::create() > { >- Display* display = XOpenDisplay(getenv("DISPLAY")); >+ Display* display = XOpenDisplay(Environment::get("DISPLAY").utf8().data()); > if (!display) > return nullptr; > >diff --git a/Source/WebCore/platform/gtk/RenderThemeWidget.cpp b/Source/WebCore/platform/gtk/RenderThemeWidget.cpp >index b72c107c1c43c5c8c382360887493873e1eb213a..d85dca1853d105b9819315d382c085ec65b47385 100644 >--- a/Source/WebCore/platform/gtk/RenderThemeWidget.cpp >+++ b/Source/WebCore/platform/gtk/RenderThemeWidget.cpp >@@ -28,6 +28,7 @@ > > #if GTK_CHECK_VERSION(3, 20, 0) > >+#include <wtf/Environment.h> > #include <wtf/HashMap.h> > #include <wtf/NeverDestroyed.h> > >@@ -109,7 +110,7 @@ RenderThemeScrollbar::RenderThemeScrollbar(GtkOrientation orientation, Mode mode > info.classList.append("horizontal"); > info.classList.append("bottom"); > } >- static bool usesOverlayScrollbars = g_strcmp0(g_getenv("GTK_OVERLAY_SCROLLING"), "0"); >+ static bool usesOverlayScrollbars = !Environment::hasValue("GTK_OVERLAY_SCROLLING", "0"); > if (usesOverlayScrollbars) > info.classList.append("overlay-indicator"); > if (mode == Mode::Full) >diff --git a/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp b/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp >index 209af7b55dba4b1140964fd5ce1461095d03f20b..c3323b591ed8454575baf8c2a6a5f4c081ed3215 100644 >--- a/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp >+++ b/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp >@@ -35,6 +35,7 @@ > #include "Scrollbar.h" > #include <cstdlib> > #include <gtk/gtk.h> >+#include <wtf/Environment.h> > > namespace WebCore { > >@@ -55,7 +56,7 @@ static void themeChangedCallback() > ScrollbarThemeGtk::ScrollbarThemeGtk() > { > #if GTK_CHECK_VERSION(3, 20, 0) >- m_usesOverlayScrollbars = g_strcmp0(g_getenv("GTK_OVERLAY_SCROLLING"), "0"); >+ m_usesOverlayScrollbars = !Environment::hasValue("GTK_OVERLAY_SCROLLING", "0"); > #endif > static bool themeMonitorInitialized = false; > if (!themeMonitorInitialized) { >diff --git a/Source/WebCore/platform/network/curl/CurlContext.cpp b/Source/WebCore/platform/network/curl/CurlContext.cpp >index 0ce1100c860363dd67642b7b47671999e2e0aa5e..413161caa274cc67312e3a47b5414c1c1b9c8e0e 100644 >--- a/Source/WebCore/platform/network/curl/CurlContext.cpp >+++ b/Source/WebCore/platform/network/curl/CurlContext.cpp >@@ -35,6 +35,7 @@ > #include "HTTPHeaderMap.h" > #include <NetworkLoadMetrics.h> > #include <mutex> >+#include <wtf/Environment.h> > #include <wtf/MainThread.h> > #include <wtf/NeverDestroyed.h> > #include <wtf/text/CString.h> >@@ -47,36 +48,6 @@ > > namespace WebCore { > >-class EnvironmentVariableReader { >-public: >- const char* read(const char* name) { return ::getenv(name); } >- bool defined(const char* name) { return read(name) != nullptr; } >- >- template<typename T> Optional<T> readAs(const char* name) >- { >- if (const char* valueStr = read(name)) { >- T value; >- if (sscanf(valueStr, sscanTemplate<T>(), &value) == 1) >- return value; >- } >- >- return WTF::nullopt; >- } >- >-private: >- template<typename T> const char* sscanTemplate() >- { >- ASSERT_NOT_REACHED(); >- return nullptr; >- } >-}; >- >-template<> >-constexpr const char* EnvironmentVariableReader::sscanTemplate<signed>() { return "%d"; } >- >-template<> >-constexpr const char* EnvironmentVariableReader::sscanTemplate<unsigned>() { return "%u"; } >- > // ALPN Protocol ID (RFC7301) https://tools.ietf.org/html/rfc7301 > static const ASCIILiteral httpVersion10 { "http/1.0"_s }; > static const ASCIILiteral httpVersion11 { "http/1.1"_s }; >@@ -94,33 +65,31 @@ CurlContext::CurlContext() > { > initShareHandle(); > >- EnvironmentVariableReader envVar; >- >- if (auto value = envVar.readAs<unsigned>("WEBKIT_CURL_DNS_CACHE_TIMEOUT")) >+ if (auto value = Environment::getUInt("WEBKIT_CURL_DNS_CACHE_TIMEOUT")) > m_dnsCacheTimeout = Seconds(*value); > >- if (auto value = envVar.readAs<unsigned>("WEBKIT_CURL_CONNECT_TIMEOUT")) >+ if (auto value = Environment::getUInt("WEBKIT_CURL_CONNECT_TIMEOUT")) > m_connectTimeout = Seconds(*value); > > long maxConnects { CurlDefaultMaxConnects }; > long maxTotalConnections { CurlDefaultMaxTotalConnections }; > long maxHostConnections { CurlDefaultMaxHostConnections }; > >- if (auto value = envVar.readAs<signed>("WEBKIT_CURL_MAXCONNECTS")) >+ if (auto value = Environment::getInt("WEBKIT_CURL_MAXCONNECTS")) > maxConnects = *value; > >- if (auto value = envVar.readAs<signed>("WEBKIT_CURL_MAX_TOTAL_CONNECTIONS")) >+ if (auto value = Environment::getInt("WEBKIT_CURL_MAX_TOTAL_CONNECTIONS")) > maxTotalConnections = *value; > >- if (auto value = envVar.readAs<signed>("WEBKIT_CURL_MAX_HOST_CONNECTIONS")) >+ if (auto value = Environment::getInt("WEBKIT_CURL_MAX_HOST_CONNECTIONS")) > maxHostConnections = *value; > > m_scheduler = std::make_unique<CurlRequestScheduler>(maxConnects, maxTotalConnections, maxHostConnections); > > #ifndef NDEBUG >- m_verbose = envVar.defined("DEBUG_CURL"); >+ m_verbose = !!Environment::get("DEBUG_CURL"); > >- auto logFile = envVar.read("CURL_LOG_FILE"); >+ auto logFile = Environment::get("CURL_LOG_FILE").utf8().data(); > if (logFile) > m_logFile = fopen(logFile, "a"); > #endif >diff --git a/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp b/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp >index 1ac4e02b7cb0752df22e6cbb38944f1acf861292..f2a8a2e257621094c78091b7389f44ae91c28a12 100644 >--- a/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp >+++ b/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp >@@ -35,6 +35,7 @@ > #include "CurlContext.h" > #include "NetworkingContext.h" > #include "ResourceHandle.h" >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/MainThread.h> > #include <wtf/NeverDestroyed.h> >@@ -46,8 +47,9 @@ namespace WebCore { > static String defaultCookieJarPath() > { > static const char* defaultFileName = "cookie.jar.db"; >- char* cookieJarPath = getenv("CURL_COOKIE_JAR_PATH"); >- if (cookieJarPath) >+ >+ auto cookieJarPath = Environment::get("CURL_COOKIE_JAR_PATH"); >+ if (!!cookieJarPath) > return cookieJarPath; > > #if PLATFORM(WIN) >diff --git a/Source/WebCore/platform/network/playstation/CurlSSLHandlePlayStation.cpp b/Source/WebCore/platform/network/playstation/CurlSSLHandlePlayStation.cpp >index 3e1e28750c0f875ce4af17cb3c210eace7f4b1c1..4f9997b5794af88ab961e174434c3aea2e1eace1 100644 >--- a/Source/WebCore/platform/network/playstation/CurlSSLHandlePlayStation.cpp >+++ b/Source/WebCore/platform/network/playstation/CurlSSLHandlePlayStation.cpp >@@ -26,20 +26,13 @@ > #include "config.h" > #include "CurlSSLHandle.h" > >-namespace WebCore { >- >-static String getCACertPathEnv() >-{ >- char* envPath = getenv("CURL_CA_BUNDLE_PATH"); >- if (envPath) >- return { envPath }; >+#include <wtf/Environment.h> > >- return emptyString(); >-} >+namespace WebCore { > > void CurlSSLHandle::platformInitialize() > { >- auto caCertPath = getCACertPathEnv(); >+ auto caCertPath = Environment::get("CURL_CA_BUNDLE_PATH"); > if (!caCertPath.isEmpty()) > setCACertPath(WTFMove(caCertPath)); > } >diff --git a/Source/WebCore/platform/network/win/CurlSSLHandleWin.cpp b/Source/WebCore/platform/network/win/CurlSSLHandleWin.cpp >index 47c88bad948792e7c44162aa1650621e5d1f4c02..5808ece7f4912cbb3bb526448c4059d661fe5eed 100644 >--- a/Source/WebCore/platform/network/win/CurlSSLHandleWin.cpp >+++ b/Source/WebCore/platform/network/win/CurlSSLHandleWin.cpp >@@ -26,6 +26,8 @@ > #include "config.h" > #include "CurlSSLHandle.h" > >+#include <wtf/Environment.h> >+ > #if USE(CF) > #if OS(WINDOWS) > #include "WebCoreBundleWin.h" >@@ -38,9 +40,9 @@ namespace WebCore { > > static String getCACertPathEnv() > { >- char* envPath = getenv("CURL_CA_BUNDLE_PATH"); >- if (envPath) >- return String(envPath); >+ auto envPath = Environment::get("CURL_CA_BUNDLE_PATH"); >+ if (!!envPath) >+ return envPath; > > #if USE(CF) > CFBundleRef webKitBundleRef = webKitBundle(); >diff --git a/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp b/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp >index 5eeb9bfa7400f7215c026c552d82aa38a763f942..3ad70ed308d3cf4adb9cb882fe7ebb459e0c3c09 100644 >--- a/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp >+++ b/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp >@@ -32,6 +32,7 @@ > #include <hyphen.h> > #include <limits> > #include <stdlib.h> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/HashMap.h> > #include <wtf/NeverDestroyed.h> >@@ -87,7 +88,8 @@ static void scanDirectoryForDictionaries(const char* directoryPath, HashMap<Atom > #if ENABLE(DEVELOPER_MODE) > static CString topLevelPath() > { >- if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL")) >+ auto topLevelDirectory = Environment::get("WEBKIT_TOP_LEVEL"); >+ if (!!topLevelDirectory) > return topLevelDirectory; > > // If the environment variable wasn't provided then assume we were built into >@@ -101,8 +103,8 @@ static CString topLevelPath() > > static CString webkitBuildDirectory() > { >- const char* webkitOutputDir = g_getenv("WEBKIT_OUTPUTDIR"); >- if (webkitOutputDir) >+ auto webkitOutputDir = Environment::get("WEBKIT_OUTPUTDIR"); >+ if (!!webkitOutputDir) > return webkitOutputDir; > > GUniquePtr<char> outputDir(g_build_filename(topLevelPath().data(), "WebKitBuild", nullptr)); >diff --git a/Source/WebCore/platform/unix/LoggingUnix.cpp b/Source/WebCore/platform/unix/LoggingUnix.cpp >index b72ad238fa21d6f35eabd741dbb501a9431cec76..74ddb21fb7cda48896e54058af060e1a5668ae9d 100644 >--- a/Source/WebCore/platform/unix/LoggingUnix.cpp >+++ b/Source/WebCore/platform/unix/LoggingUnix.cpp >@@ -24,7 +24,7 @@ > > #if !LOG_DISABLED || !RELEASE_LOG_DISABLED > >-#include <string.h> >+#include <wtf/Environment.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -32,7 +32,7 @@ namespace WebCore { > String logLevelString() > { > #if !LOG_DISABLED >- char* logEnv = getenv("WEBKIT_DEBUG"); >+ auto logEnv = Environment::get("WEBKIT_DEBUG"); > if (!logEnv) > return emptyString(); > >@@ -42,7 +42,7 @@ String logLevelString() > #endif > > // To disable logging notImplemented set the DISABLE_NI_WARNING environment variable to 1. >- return String("NotYetImplemented,") + logEnv; >+ return makeString("NotYetImplemented,"_s, logEnv); > #else > return String(); > #endif >diff --git a/Source/WebCore/platform/win/LoggingWin.cpp b/Source/WebCore/platform/win/LoggingWin.cpp >index e6c444ecac7a2f93fe290f332e0903dc4646da6e..1d741d7b2f15a1bd69bead92f93a255410644401 100644 >--- a/Source/WebCore/platform/win/LoggingWin.cpp >+++ b/Source/WebCore/platform/win/LoggingWin.cpp >@@ -29,7 +29,7 @@ > #if !LOG_DISABLED || !RELEASE_LOG_DISABLED > > #include <windows.h> >-#include <wtf/StdLibExtras.h> >+#include <wtf/Environment.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -37,17 +37,7 @@ namespace WebCore { > String logLevelString() > { > #if !LOG_DISABLED >- static char* const loggingEnvironmentVariable = "WebCoreLogging"; >- DWORD length = GetEnvironmentVariableA(loggingEnvironmentVariable, 0, 0); >- if (!length) >- return emptyString(); >- >- Vector<char> buffer(length); >- >- if (!GetEnvironmentVariableA(loggingEnvironmentVariable, buffer.data(), length)) >- return emptyString(); >- >- return String(buffer.data()); >+ return Environment::get("WebCoreLogging"); > #else > return String(); > #endif >diff --git a/Source/WebKit/Platform/unix/LoggingUnix.cpp b/Source/WebKit/Platform/unix/LoggingUnix.cpp >index 5b17b3bd8de3f548bf7690c1893d99fe1eb6d022..a124d8eee113f34813a5c8a4a1e36e36a4cb9b16 100644 >--- a/Source/WebKit/Platform/unix/LoggingUnix.cpp >+++ b/Source/WebKit/Platform/unix/LoggingUnix.cpp >@@ -27,19 +27,22 @@ > #include "config.h" > #include "Logging.h" > >-namespace WebKit { >- > #if !LOG_DISABLED || !RELEASE_LOG_DISABLED > >+#include <wtf/Environment.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebKit { >+ > String logLevelString() > { > #if !LOG_DISABLED >- return getenv("WEBKIT_DEBUG"); >+ return Environment::get("WEBKIT_DEBUG"); > #else > return String(); > #endif > } > >-#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED >+} // namespace WebKit > >-} >+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED >diff --git a/Source/WebKit/Platform/win/LoggingWin.cpp b/Source/WebKit/Platform/win/LoggingWin.cpp >index 69b0a5c910fbdaf3d38ffc2706a0e40f8204fe53..cc91d831037211517301ed703b99d9601bd9ab9a 100644 >--- a/Source/WebKit/Platform/win/LoggingWin.cpp >+++ b/Source/WebKit/Platform/win/LoggingWin.cpp >@@ -30,7 +30,7 @@ > #if !LOG_DISABLED || !RELEASE_LOG_DISABLED > > #include <windows.h> >-#include <wtf/StdLibExtras.h> >+#include <wtf/Environment.h> > #include <wtf/text/WTFString.h> > > namespace WebKit { >@@ -38,18 +38,7 @@ namespace WebKit { > String logLevelString() > { > #if !LOG_DISABLED >- static char* const loggingEnvironmentVariable = "WebKitLogging"; >- >- DWORD length = GetEnvironmentVariableA(loggingEnvironmentVariable, 0, 0); >- if (!length) >- return emptyString(); >- >- Vector<char> buffer(length); >- >- if (!GetEnvironmentVariableA(loggingEnvironmentVariable, buffer.data(), length)) >- return emptyString(); >- >- return String(buffer.data()); >+ return Environment::get("WebKitLogging"); > #else > return String(); > #endif
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 192405
:
361353
|
361357
|
361478
|
361490
|
361574
|
361592
|
361594
|
361595
|
361599
|
361600
|
361604
|
361613
|
361618
|
361619
|
361653
|
361736
|
361757
|
361759
|
361765
|
361774
|
361813
|
361840
|
361933
|
361937
|
361942
|
362038
|
362040
|
362041
|
362153
|
362156
|
362399