WebKit Bugzilla
Attachment 361595 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-20190208221230.patch (text/plain), 120.56 KB, created by
Ross Kirsling
on 2019-02-08 22:12:31 PST
(
hide
)
Description:
Checkpoint for EWS
Filename:
MIME Type:
Creator:
Ross Kirsling
Created:
2019-02-08 22:12:31 PST
Size:
120.56 KB
patch
obsolete
>Subversion Revision: 241229 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 3f61fe33d5fcfeb2f9e33db18ea2dcf28f2ea3bc..022b4176d4d6735e61bb1d373398b91f1a22b024 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-08 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-08 Saam barati <sbarati@apple.com> > > Nodes that rely on being dominated by CheckInBounds should have a child edge to it >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index e45ad93c1e472acbf5066018dd2a237aeafd04dd..64bca763ef2cc80a53bc512d9117d176ca853d6c 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,29 @@ >+2019-02-08 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-08 Alex Christensen <achristensen@webkit.org> > > Add SPI to use networking daemon instead of XPC service >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 380c4900be76d0dae8a50d48245167874c7b4b83..45307ea344046580bd325d9b44e118dcff2d7582 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,52 @@ >+2019-02-08 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm: >+ (WebCore::DatabaseManager::platformInitialize): >+ * 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-08 Myles C. Maxfield <mmaxfield@apple.com> > > [Cocoa] Ask platform for generic font family mappings >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index 3c0ef8449b208e0f6a8a9b6b708f9b71ba7cb4d1..aed4c46e1e18549ed98f87040c884b3790f1be8e 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-08 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-08 Myles C. Maxfield <mmaxfield@apple.com> > > [Cocoa] Ask platform for generic font family mappings >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 3f86bead7753f270efb9fcdf650549206192d288..444582667e986969f76c917f5e519bb180e71909 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,70 @@ >+2019-02-08 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp: >+ (main): >+ * Platform/unix/EnvironmentUtilities.cpp: >+ (WebKit::EnvironmentUtilities::stripValuesEndingWithString): >+ * Platform/unix/LoggingUnix.cpp: >+ (WebKit::logLevelString): >+ * Platform/win/LoggingWin.cpp: >+ (WebKit::logLevelString): >+ * PluginProcess/mac/PluginProcessMac.mm: >+ (WebKit::shouldCallRealDebugger): >+ (WebKit::PluginProcess::platformInitializeProcess): >+ * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm: >+ (WebKit::XPCInitializationHandler): >+ * Shared/Plugins/unix/PluginSearchPath.cpp: >+ (WebKit::pluginsDirectories): >+ * Shared/glib/ProcessExecutablePathGLib.cpp: >+ (WebKit::findWebKitProcess): >+ * Shared/mac/AuxiliaryProcessMac.mm: >+ (WebKit::initializeSandboxParameters): >+ * UIProcess/API/glib/WebKitSettings.cpp: >+ (webKitSettingsConstructed): >+ (webKitSettingsSetProperty): >+ * UIProcess/API/glib/WebKitWebContext.cpp: >+ (injectedBundleDirectory): >+ (webkitWebContextConstructed): >+ * UIProcess/API/gtk/WebKitWebViewGtk.cpp: >+ (webkitWebViewMaximizeWindow): >+ (webkitWebViewRestoreWindow): >+ * UIProcess/API/wpe/WPEView.cpp: >+ (WKWPE::m_backend): >+ * UIProcess/AuxiliaryProcessProxy.cpp: >+ (WebKit::AuxiliaryProcessProxy::getLaunchOptions): >+ * UIProcess/Launcher/glib/BubblewrapLauncher.cpp: >+ (WebKit::XDGDBusProxyLauncher::launch): >+ (WebKit::bindDBusSession): >+ (WebKit::bindX11): >+ (WebKit::bindWayland): >+ (WebKit::bindPulse): >+ (WebKit::bindPathVar): >+ (WebKit::bindGStreamerData): >+ (WebKit::bubblewrapSpawn): >+ * UIProcess/Launcher/glib/ProcessLauncherGLib.cpp: >+ (WebKit::ProcessLauncher::launchProcess): >+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm: >+ (WebKit::systemDirectoryPath): >+ (WebKit::ProcessLauncher::launchProcess): >+ * UIProcess/gtk/HardwareAccelerationManager.cpp: >+ (WebKit::HardwareAccelerationManager::HardwareAccelerationManager): >+ * UIProcess/gtk/WebProcessPoolGtk.cpp: >+ (WebKit::memoryPressureMonitorDisabled): >+ (WebKit::WebProcessPool::platformInitialize): >+ (WebKit::WebProcessPool::platformInitializeWebProcess): >+ * UIProcess/wpe/WebProcessPoolWPE.cpp: >+ (WebKit::WebProcessPool::platformInitialize): >+ (WebKit::WebProcessPool::platformInitializeWebProcess): >+ * WebProcess/EntryPoint/unix/WebProcessMain.cpp: >+ (main): >+ * WebProcess/gtk/WebProcessMainGtk.cpp: >+ * WebProcess/wpe/WebProcessMainWPE.cpp: >+ > 2019-02-08 Alexander Mikhaylenko <exalm7659@gmail.com> > > [GTK] Implement back/forward touchpad gesture >diff --git a/Source/WebKitLegacy/ios/ChangeLog b/Source/WebKitLegacy/ios/ChangeLog >index d5c40d7ff4e7d3c93768bb7b0d1ec3ca4f586203..75b7807795e55261473a41d2fcdfcb82cdd79913 100644 >--- a/Source/WebKitLegacy/ios/ChangeLog >+++ b/Source/WebKitLegacy/ios/ChangeLog >@@ -1,3 +1,13 @@ >+2019-02-08 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Misc/WebUIKitSupport.mm: >+ (WebKitPlatformSystemRootDirectory): >+ > 2019-01-22 Conrad Shultz <conrad_shultz@apple.com> > > Clean up USE(WEB_THREAD) >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 9a36586501c2dd39f6780b66302a81163da64397..4b9054d636fb1171ddab78b3475486bfe391e04d 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,13 @@ >+2019-02-08 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebView/WebView.mm: >+ (-[WebView _initWithFrame:frameName:groupName:]): >+ > 2019-02-06 Andy Estes <aestes@apple.com> > > [Payment Request] It should be possible to require a phonetic name for shipping contacts >diff --git a/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp b/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp >index b73455a40cc15d56353ff694fb65340182924c48..ee5970cebfa70302712b3f79a0b10e73cd6f6813 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,7 @@ void RemoteInspector::start() > m_enabled = true; > m_cancellable = adoptGRef(g_cancellable_new()); > >- GUniquePtr<char> inspectorAddress(g_strdup(g_getenv("WEBKIT_INSPECTOR_SERVER"))); >+ GUniquePtr<char> inspectorAddress(g_strdup(Environment::get("WEBKIT_INSPECTOR_SERVER").utf8().data())); > char* portPtr = g_strrstr(inspectorAddress.get(), ":"); > ASSERT(portPtr); > *portPtr = '\0'; >@@ -79,7 +82,7 @@ void RemoteInspector::start() > 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", Environment::get("WEBKIT_INSPECTOR_SERVER").utf8().data(), 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..8ac2fbff201c6dfd3b5c26eaa33344ca9752d0df 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,29 +177,28 @@ 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); > if (!stringValue) > return false; > >- if (available && parse(stringValue, variable)) >+ if (available && parse(stringValue.utf8().data(), variable)) > return true; > >- fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue); >+ fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue.utf8().data()); > return false; > } > > bool Options::overrideAliasedOptionWithHeuristic(const char* name) > { >- const char* stringValue = getenv(name); >+ auto stringValue = Environment::get(name); > if (!stringValue) > return false; > >- String aliasedOption; >- aliasedOption = String(&name[4]) + "=" + stringValue; >+ auto aliasedOption = makeString(&name[4], "=", stringValue); > if (Options::setOption(aliasedOption.utf8().data())) > return true; > >- fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue); >+ fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue.utf8().data()); > return false; > } > >@@ -597,9 +597,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..bd070cb3632ef311ee5faeec4a27605fb9a8d4a1 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,9 +428,9 @@ VM::VM(VMType vmType, HeapType heapType) > m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this); > > StringPrintStream pathOut; >- const char* profilerPath = getenv("JSC_PROFILER_PATH"); >- if (profilerPath) >- pathOut.print(profilerPath, "/"); >+ auto profilerPath = Environment::get("JSC_PROFILER_PATH"); >+ if (!!profilerPath) >+ pathOut.print(profilerPath.utf8().data(), "/"); > pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json"); > m_perBytecodeProfiler->registerToSaveAtExit(pathOut.toCString().data()); > } >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..4e314a7bc9301941a960357c7f024b3f0618dba7 >--- /dev/null >+++ b/Source/WTF/wtf/Environment.h >@@ -0,0 +1,69 @@ >+/* >+ * 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 bool doesNotHaveValue(const String& variable, const String& value) >+{ >+ auto var = get(variable); >+ return !var || var == 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..b16c189ab80c78c8adcd478e59f202e3c07395ce 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,12 +425,12 @@ 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"); > if (!tmpDir) > tmpDir = "/tmp"; > >- if (snprintf(buffer, PATH_MAX, "%s/%sXXXXXX", tmpDir, prefix.utf8().data()) >= PATH_MAX) >+ if (snprintf(buffer, PATH_MAX, "%s/%sXXXXXX", tmpDir.utf8().data(), prefix.utf8().data()) >= PATH_MAX) > goto end; > > handle = mkstemp(buffer); >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/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm b/Source/WebCore/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm >index 8d325073b04aca1d328496e1828338dfebcabff3..792a0e259a928cc796bad08fa737ffcc70f1fdd1 100644 >--- a/Source/WebCore/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm >+++ b/Source/WebCore/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm >@@ -29,6 +29,7 @@ > #import "config.h" > #import "DatabaseManager.h" > >+#import <wtf/Environment.h> > #import <wtf/FileSystem.h> > > namespace WebCore { >@@ -40,8 +41,7 @@ void DatabaseManager::platformInitialize(const String& databasePath) > FileSystem::makeAllDirectories(databasePath); > > // Disable vnode-guard related simulated crashes for WebSQL (rdar://problem/40674034). We do not overwrite the value here as it may have already been set by WKTR / DRT. >- int overwrite = 0; >- setenv("SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS", FileSystem::realPath(databasePath).utf8().data(), overwrite); >+ Environment::add("SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS", FileSystem::realPath(databasePath)); > } > > } // namespace WebCore >diff --git a/Source/WebCore/PAL/pal/unix/LoggingUnix.cpp b/Source/WebCore/PAL/pal/unix/LoggingUnix.cpp >index 24734f902c14ab1e8c922762c32f74de7481942e..b8451cb6698e3e6dd9f7b2b78cae9e4ee1b793b4 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,", 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..a7227e31fd2efe3ecac370a0e1c55d778ddbf71f 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,8 +34,9 @@ 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")) >- systemLibraryPath = [NSString stringWithFormat:@"%s/%@", simulatorRoot, systemLibraryPath]; >+ auto simulatorRoot = Environment::get("SIMULATOR_ROOT"); >+ if (!!simulatorRoot) >+ systemLibraryPath = [NSString stringWithFormat:@"%s/%@", simulatorRoot.utf8().data(), systemLibraryPath]; > #endif > NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"]; > NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath]; >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..2882ebd40cee468acbef4d38fcbdc644cb709c62 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,35 +65,33 @@ 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"); >- if (logFile) >- m_logFile = fopen(logFile, "a"); >+ auto logFile = Environment::get("CURL_LOG_FILE"); >+ if (!!logFile) >+ m_logFile = fopen(logFile.utf8().data(), "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..0d84bf3591e4a00630aac7fdbcaa4d96e1bd61ac 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,", 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/NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp b/Source/WebKit/NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp >index 736c01708a46698699a0839a71477e2a4a483da7..1cf6a6b74a29e9a4c8f0c40baf3757ea7403d6bf 100644 >--- a/Source/WebKit/NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp >+++ b/Source/WebKit/NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp >@@ -23,9 +23,10 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >+#include "config.h" > #include "NetworkProcessMainUnix.h" > >-#include <cstdlib> >+#include <wtf/Environment.h> > > #if USE(GCRYPT) > #include <pal/crypto/gcrypt/Initialization.h> >@@ -43,7 +44,7 @@ int main(int argc, char** argv) > // overwrite this priority string if it's already set by the user. > // https://bugzilla.gnome.org/show_bug.cgi?id=738633 > // WARNING: This needs to be KEPT IN SYNC with WebProcessMain.cpp. >- setenv("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128", 0); >+ Environment::add("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128"); > > #if USE(GCRYPT) > PAL::GCrypt::initialize(); >diff --git a/Source/WebKit/Platform/unix/EnvironmentUtilities.cpp b/Source/WebKit/Platform/unix/EnvironmentUtilities.cpp >index bb80120fc22c4b29cfe446f8f4fefb46b6cfca3f..f2c88ff78dba992152b4dda3e341b6797e3b9583 100644 >--- a/Source/WebKit/Platform/unix/EnvironmentUtilities.cpp >+++ b/Source/WebKit/Platform/unix/EnvironmentUtilities.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "EnvironmentUtilities.h" > >+#include <wtf/Environment.h> > #include <wtf/text/CString.h> > > namespace WebKit { >@@ -38,9 +39,8 @@ void stripValuesEndingWithString(const char* environmentVariable, const char* se > ASSERT(searchValue); > > // Grab the current value of the environment variable. >- char* environmentValue = getenv(environmentVariable); >- >- if (!environmentValue || environmentValue[0] == '\0') >+ auto environmentValue = Environment::get(environmentVariable).utf8().mutableData(); >+ if (!environmentValue[0]) > return; > > const size_t environmentValueLength = strlen(environmentValue); >@@ -118,12 +118,12 @@ void stripValuesEndingWithString(const char* environmentVariable, const char* se > return; > > // If we have nothing left, just unset the variable >- if (environmentValue[0] == '\0') { >- unsetenv(environmentVariable); >+ if (!environmentValue[0]) { >+ Environment::remove(environmentVariable); > return; > } > >- setenv(environmentVariable, environmentValue, 1); >+ Environment::set(environmentVariable, environmentValue); > } > > } // namespace EnvironmentUtilities >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 >diff --git a/Source/WebKit/PluginProcess/mac/PluginProcessMac.mm b/Source/WebKit/PluginProcess/mac/PluginProcessMac.mm >index 1054e4303a5ae61bcb45a6f383be14c8592d1742..e5928362bffc996f894fe5640264cfab30a9a41e 100644 >--- a/Source/WebKit/PluginProcess/mac/PluginProcessMac.mm >+++ b/Source/WebKit/PluginProcess/mac/PluginProcessMac.mm >@@ -53,6 +53,7 @@ > #import <pal/spi/mac/NSApplicationSPI.h> > #import <pal/spi/mac/NSWindowSPI.h> > #import <sysexits.h> >+#import <wtf/Environment.h> > #import <wtf/HashSet.h> > #import <wtf/NeverDestroyed.h> > >@@ -168,10 +169,8 @@ static bool shouldCallRealDebugger() > static bool isUserbreakSet = false; > static dispatch_once_t flag; > dispatch_once(&flag, ^{ >- char* var = getenv("USERBREAK"); >- >- if (var) >- isUserbreakSet = atoi(var); >+ if (auto var = Environment::getInt("USERBREAK")) >+ isUserbreakSet = *var; > }); > > return isUserbreakSet; >@@ -619,7 +618,7 @@ void PluginProcess::platformInitializeProcess(const AuxiliaryProcessInitializati > > if (!pluginHasSandboxProfile(m_pluginBundleIdentifier)) { > // Allow Apple Events from Citrix plugin. This can be removed when <rdar://problem/14012823> is fixed. >- setenv("__APPLEEVENTSSERVICENAME", "com.apple.coreservices.appleevents", 1); >+ Environment::set("__APPLEEVENTSSERVICENAME", "com.apple.coreservices.appleevents"); > } > } > >diff --git a/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm b/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm >index 4304c48ac6e38624e8f781092f550a904b4a33c3..608fef61d3723a105a7c6af0036a2044ac78cb25 100644 >--- a/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm >+++ b/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm >@@ -24,10 +24,11 @@ > */ > > #import "config.h" >-#import "WebProcessCocoa.h" > #import "XPCServiceEntryPoint.h" > >+#import "WebProcessCocoa.h" > #import <CoreFoundation/CoreFoundation.h> >+#import <wtf/Environment.h> > #import <wtf/OSObjectPtr.h> > #import <wtf/RetainPtr.h> > #import <wtf/spi/darwin/XPCSPI.h> >@@ -110,7 +111,7 @@ void XPCInitializationHandler(xpc_object_t event) > std::call_once(once, [event] { > #if PLATFORM(MAC) > // Don't allow Apple Events in WebKit processes. This can be removed when <rdar://problem/14012823> is fixed. >- setenv("__APPLEEVENTSSERVICENAME", "", 1); >+ Environment::set("__APPLEEVENTSSERVICENAME", ""); > > #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 > // We don't need to talk to the dock. >@@ -134,7 +135,7 @@ void XPCInitializationHandler(xpc_object_t event) > #if PLATFORM(IOS_FAMILY) > auto containerEnvironmentVariables = xpc_dictionary_get_value(event, "ContainerEnvironmentVariables"); > xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) { >- setenv(key, xpc_string_get_string_ptr(value), 1); >+ Environment::set(key, xpc_string_get_string_ptr(value)); > return true; > }); > #endif >diff --git a/Source/WebKit/Shared/Plugins/unix/PluginSearchPath.cpp b/Source/WebKit/Shared/Plugins/unix/PluginSearchPath.cpp >index 2bd549a95dfa675ce47f56d78a59b4f7315a11ab..c22ca2f909c36f1fba83fe7d7f2b1c15086fc86c 100644 >--- a/Source/WebKit/Shared/Plugins/unix/PluginSearchPath.cpp >+++ b/Source/WebKit/Shared/Plugins/unix/PluginSearchPath.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "PluginSearchPath.h" > >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > > namespace WebKit { >@@ -36,13 +37,13 @@ Vector<String> pluginsDirectories() > Vector<String> result; > > #if ENABLE(NETSCAPE_PLUGIN_API) >- String mozillaPaths(getenv("MOZ_PLUGIN_PATH")); >+ auto mozillaPaths = Environment::get("MOZ_PLUGIN_PATH"); > if (!mozillaPaths.isEmpty()) { > Vector<String> paths = mozillaPaths.split(':'); > result.appendVector(paths); > } > >- String mozillaHome(getenv("MOZILLA_HOME")); >+ auto mozillaHome = Environment::get("MOZILLA_HOME"); > if (!mozillaHome.isEmpty()) > result.append(mozillaHome + "/plugins"); > >diff --git a/Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp b/Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp >index 4ff35d31de1d57231a6f6e1015a855d40f8c8c35..64c0450afd598b6ad11da9629db83bfd2de8ec03 100644 >--- a/Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp >+++ b/Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp >@@ -28,6 +28,7 @@ > #include "ProcessExecutablePath.h" > > #include <glib.h> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/glib/GLibUtilities.h> > >@@ -46,9 +47,9 @@ static String getExecutablePath() > static String findWebKitProcess(const char* processName) > { > #if ENABLE(DEVELOPER_MODE) >- static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH"); >- if (execDirectory) { >- String processPath = FileSystem::pathByAppendingComponent(FileSystem::stringFromFileSystemRepresentation(execDirectory), processName); >+ static auto execDirectory = Environment::get("WEBKIT_EXEC_PATH"); >+ if (!!execDirectory) { >+ String processPath = FileSystem::pathByAppendingComponent(FileSystem::stringFromFileSystemRepresentation(execDirectory.utf8().data()), processName); > if (FileSystem::fileExists(processPath)) > return processPath; > } >diff --git a/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm b/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm >index 386443e782e752a72cc6511937254cc6ce91bb68..5bc5a7f365cbb498a0824dbd63e6bdb3c19fbbeb 100644 >--- a/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm >+++ b/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm >@@ -46,6 +46,7 @@ > #import <sys/sysctl.h> > #import <sysexits.h> > #import <wtf/DataLog.h> >+#import <wtf/Environment.h> > #import <wtf/FileSystem.h> > #import <wtf/RandomNumber.h> > #import <wtf/Scope.h> >@@ -621,13 +622,13 @@ static void initializeSandboxParameters(const AuxiliaryProcessInitializationPara > sandboxParameters.addParameter("_OS_VERSION", osVersion.utf8().data()); > > // Use private temporary and cache directories. >- setenv("DIRHELPER_USER_DIR_SUFFIX", FileSystem::fileSystemRepresentation(sandboxParameters.userDirectorySuffix()).data(), 1); >+ Environment::set("DIRHELPER_USER_DIR_SUFFIX", FileSystem::fileSystemRepresentation(sandboxParameters.userDirectorySuffix()).data()); > char temporaryDirectory[PATH_MAX]; > if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) { > WTFLogAlways("%s: couldn't retrieve private temporary directory path: %d\n", getprogname(), errno); > exit(EX_NOPERM); > } >- setenv("TMPDIR", temporaryDirectory, 1); >+ Environment::set("TMPDIR", temporaryDirectory); > > sandboxParameters.addPathParameter("WEBKIT2_FRAMEWORK_DIR", [[webKit2Bundle() bundlePath] stringByDeletingLastPathComponent]); > sandboxParameters.addConfDirectoryParameter("DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR); >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp b/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp >index a840651c6daa81c1b5fa6bed5e03319020295ec4..fdae5b66d297bf48da211206be331324e0db19cb 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp >@@ -40,6 +40,7 @@ > #include <WebCore/UserAgent.h> > #include <cmath> > #include <glib/gi18n-lib.h> >+#include <wtf/Environment.h> > #include <wtf/glib/WTFGType.h> > #include <wtf/text/CString.h> > >@@ -182,7 +183,7 @@ static void webKitSettingsConstructed(GObject* object) > WebPreferences* prefs = settings->priv->preferences.get(); > prefs->setShouldRespectImageOrientation(true); > >- if (g_getenv("WEBKIT_WEBRTC_DISABLE_UNIFIED_PLAN")) >+ if (!!Environment::get("WEBKIT_WEBRTC_DISABLE_UNIFIED_PLAN")) > prefs->setWebRTCUnifiedPlanEnabled(FALSE); > > bool mediaStreamEnabled = prefs->mediaStreamEnabled(); >@@ -334,8 +335,7 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu > if (g_value_get_boolean(value)) > webkit_settings_set_draw_compositing_indicators(settings, g_value_get_boolean(value)); > else { >- char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS"); >- bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1"); >+ auto showDebugVisuals = Environment::hasValue("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS", "1"); > webkit_settings_set_draw_compositing_indicators(settings, showDebugVisuals); > } > break; >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp >index 724c5fbf5e847ced1f30fb08cfd58d8d1f569f0b..a1c56944cde99546362afdeb8f1bfb16c1e94668 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp >@@ -57,6 +57,7 @@ > #include <glib/gi18n-lib.h> > #include <libintl.h> > #include <memory> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/HashMap.h> > #include <wtf/Language.h> >@@ -261,8 +262,8 @@ WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT) > static const char* injectedBundleDirectory() > { > #if ENABLE(DEVELOPER_MODE) >- const char* bundleDirectory = g_getenv("WEBKIT_INJECTED_BUNDLE_PATH"); >- if (bundleDirectory && g_file_test(bundleDirectory, G_FILE_TEST_IS_DIR)) >+ auto bundleDirectory = Environment::get("WEBKIT_INJECTED_BUNDLE_PATH").utf8().data(); >+ if (bundleDirectory[0] && g_file_test(bundleDirectory, G_FILE_TEST_IS_DIR)) > return bundleDirectory; > #endif > >@@ -359,7 +360,7 @@ static void webkitWebContextConstructed(GObject* object) > priv->processPool->setIgnoreTLSErrors(false); > > #if ENABLE(MEMORY_SAMPLER) >- if (getenv("WEBKIT_SAMPLE_MEMORY")) >+ if (!!Environment::get("WEBKIT_SAMPLE_MEMORY")) > priv->processPool->startMemorySampler(0); > #endif > >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp >index bc82179912826ab47af7c96575e1ba8ba426e881..cbfc68c24499603b5a84a91410bcb330d5df9171 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp >@@ -29,6 +29,7 @@ > #include <WebCore/PlatformScreen.h> > #include <glib/gi18n-lib.h> > #include <gtk/gtk.h> >+#include <wtf/Environment.h> > > gboolean webkitWebViewAuthenticate(WebKitWebView* webView, WebKitAuthenticationRequest* request) > { >@@ -192,8 +193,7 @@ void webkitWebViewMaximizeWindow(WebKitWebView* view, CompletionHandler<void()>& > #if ENABLE(DEVELOPER_MODE) > // Xvfb doesn't support maximize, so we resize the window to the screen size. > if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::X11) { >- const char* underXvfb = g_getenv("UNDER_XVFB"); >- if (!g_strcmp0(underXvfb, "yes")) { >+ if (Environment::hasValue("UNDER_XVFB", "yes")) { > auto screenRect = WebCore::screenAvailableRect(nullptr); > gtk_window_move(window, screenRect.x(), screenRect.y()); > gtk_window_resize(window, screenRect.width(), screenRect.height()); >@@ -245,8 +245,7 @@ void webkitWebViewRestoreWindow(WebKitWebView* view, CompletionHandler<void()>&& > #if ENABLE(DEVELOPER_MODE) > // Xvfb doesn't support maximize, so we resize the window to the default size. > if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::X11) { >- const char* underXvfb = g_getenv("UNDER_XVFB"); >- if (!g_strcmp0(underXvfb, "yes")) { >+ if (Environment::hasValue("UNDER_XVFB", "yes")) { > int x, y; > gtk_window_get_default_size(window, &x, &y); > gtk_window_resize(window, x, y); >diff --git a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >index afdbd07dfb65998bf650892bc8fe2bf42e5cd0bc..97db959cd778d8168be58949ef90a40287bcafc5 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >@@ -36,6 +36,7 @@ > #include "WebPageGroup.h" > #include "WebProcessPool.h" > #include <wpe/wpe.h> >+#include <wtf/Environment.h> > > using namespace WebKit; > >@@ -71,7 +72,7 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC > m_pageProxy = pool->createWebPage(*m_pageClient, WTFMove(configuration)); > > #if ENABLE(MEMORY_SAMPLER) >- if (getenv("WEBKIT_SAMPLE_MEMORY")) >+ if (!!Environment::get("WEBKIT_SAMPLE_MEMORY")) > pool->startMemorySampler(0); > #endif > >diff --git a/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp b/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp >index ca3789dde6ad06212603b807fa9d241dcbba3bbc..8e1c1d6b3b49857dbff32e397780668908121722 100644 >--- a/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp >@@ -27,6 +27,7 @@ > #include "AuxiliaryProcessProxy.h" > > #include "AuxiliaryProcessMessages.h" >+#include <wtf/Environment.h> > #include <wtf/RunLoop.h> > > namespace WebKit { >@@ -51,7 +52,8 @@ void AuxiliaryProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& lau > { > launchOptions.processIdentifier = m_processIdentifier; > >- if (const char* userDirectorySuffix = getenv("DIRHELPER_USER_DIR_SUFFIX")) >+ auto userDirectorySuffix = Environment::get("DIRHELPER_USER_DIR_SUFFIX"); >+ if (!!userDirectorySuffix) > launchOptions.extraInitializationData.add("user-directory-suffix"_s, userDirectorySuffix); > > if (m_alwaysRunsAtBackgroundPriority) >@@ -76,9 +78,9 @@ void AuxiliaryProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& lau > ASSERT_NOT_REACHED(); > break; > } >- const char* processCmdPrefix = getenv(varname); >- if (processCmdPrefix && *processCmdPrefix) >- launchOptions.processCmdPrefix = String::fromUTF8(processCmdPrefix); >+ auto processCmdPrefix = Environment::get(varname); >+ if (!processCmdPrefix.isEmpty()) >+ launchOptions.processCmdPrefix = processCmdPrefix; > #endif // ENABLE(DEVELOPER_MODE) && (PLATFORM(GTK) || PLATFORM(WPE)) > > platformGetLaunchOptions(launchOptions); >diff --git a/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp b/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp >index f8b102a68e971cc34d3d914e84d2a4ac42f28221..ed2fccd7da99b3ac3bb4f44cfd4f766e320649dc 100644 >--- a/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp >+++ b/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp >@@ -25,6 +25,7 @@ > #include <glib.h> > #include <seccomp.h> > #include <sys/ioctl.h> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/glib/GLibUtilities.h> > #include <wtf/glib/GRefPtr.h> >@@ -165,7 +166,7 @@ public: > syncFdStr.get(), > }; > >- if (!g_strcmp0(g_getenv("WEBKIT_ENABLE_DBUS_PROXY_LOGGING"), "1")) >+ if (Environment::hasValue("WEBKIT_ENABLE_DBUS_PROXY_LOGGING", "1")) > proxyArgs.append("--log"); > > proxyArgs.appendVector(m_permissions); >@@ -282,7 +283,7 @@ static void bindIfExists(Vector<CString>& args, const char* path, BindFlags bind > static void bindDBusSession(Vector<CString>& args, XDGDBusProxyLauncher& proxy) > { > if (!proxy.isRunning()) >- proxy.setAddress(g_getenv("DBUS_SESSION_BUS_ADDRESS"), DBusAddressType::Normal); >+ proxy.setAddress(Environment::get("DBUS_SESSION_BUS_ADDRESS").utf8().data(), DBusAddressType::Normal); > > if (proxy.proxyPath().data()) { > args.appendVector(Vector<CString>({ >@@ -293,30 +294,30 @@ static void bindDBusSession(Vector<CString>& args, XDGDBusProxyLauncher& proxy) > > static void bindX11(Vector<CString>& args) > { >- const char* display = g_getenv("DISPLAY"); >- if (!display || display[0] != ':' || !g_ascii_isdigit(const_cast<char*>(display)[1])) >+ auto display = Environment.get("DISPLAY").utf8().data(); >+ if (display[0] != ':' || !g_ascii_isdigit(const_cast<char*>(display)[1])) > display = ":0"; > GUniquePtr<char> x11File(g_strdup_printf("/tmp/.X11-unix/X%s", display + 1)); > bindIfExists(args, x11File.get(), BindFlags::ReadWrite); > >- const char* xauth = g_getenv("XAUTHORITY"); >+ auto xauth = Environment.get("XAUTHORITY"); > if (!xauth) { > const char* homeDir = g_get_home_dir(); > GUniquePtr<char> xauthFile(g_build_filename(homeDir, ".Xauthority", nullptr)); > bindIfExists(args, xauthFile.get()); > } else >- bindIfExists(args, xauth); >+ bindIfExists(args, xauth.utf8().data()); > } > > #if PLATFORM(WAYLAND) && USE(EGL) > static void bindWayland(Vector<CString>& args) > { >- const char* display = g_getenv("WAYLAND_DISPLAY"); >+ auto display = Environment.get("WAYLAND_DISPLAY"); > if (!display) > display = "wayland-0"; > > const char* runtimeDir = g_get_user_runtime_dir(); >- GUniquePtr<char> waylandRuntimeFile(g_build_filename(runtimeDir, display, nullptr)); >+ GUniquePtr<char> waylandRuntimeFile(g_build_filename(runtimeDir, display.utf8().data(), nullptr)); > bindIfExists(args, waylandRuntimeFile.get(), BindFlags::ReadWrite); > } > #endif >@@ -325,8 +326,8 @@ static void bindPulse(Vector<CString>& args) > { > // FIXME: The server can be defined in config files we'd have to parse. > // They can also be set as X11 props but that is getting a bit ridiculous. >- const char* pulseServer = g_getenv("PULSE_SERVER"); >- if (pulseServer) { >+ auto pulseServer = Environment.get("PULSE_SERVER").utf8().data(); >+ if (!pulseServer[0]) { > if (g_str_has_prefix(pulseServer, "unix:")) > bindIfExists(args, pulseServer + 5, BindFlags::ReadWrite); > // else it uses tcp >@@ -336,9 +337,9 @@ static void bindPulse(Vector<CString>& args) > bindIfExists(args, pulseRuntimeDir.get(), BindFlags::ReadWrite); > } > >- const char* pulseConfig = g_getenv("PULSE_CLIENTCONFIG"); >- if (pulseConfig) >- bindIfExists(args, pulseConfig); >+ auto pulseConfig = Environment.get("PULSE_CLIENTCONFIG"); >+ if (!!pulseConfig) >+ bindIfExists(args, pulseConfig.utf8().data()); > > const char* configDir = g_get_user_config_dir(); > GUniquePtr<char> pulseConfigDir(g_build_filename(configDir, "pulse", nullptr)); >@@ -450,11 +451,11 @@ static void bindA11y(Vector<CString>& args) > > static bool bindPathVar(Vector<CString>& args, const char* varname) > { >- const char* pathValue = g_getenv(varname); >+ auto pathValue = Environment::get(varname); > if (!pathValue) > return false; > >- GUniquePtr<char*> splitPaths(g_strsplit(pathValue, ":", -1)); >+ GUniquePtr<char*> splitPaths(g_strsplit(pathValue.utf8().data(), ":", -1)); > for (size_t i = 0; splitPaths.get()[i]; ++i) > bindIfExists(args, splitPaths.get()[i]); > >@@ -477,11 +478,11 @@ static void bindGStreamerData(Vector<CString>& args) > bindIfExists(args, gstCache.get(), BindFlags::ReadWrite); > > // /usr/lib is already added so this is only requried for other dirs >- const char* scannerPath = g_getenv("GST_PLUGIN_SCANNER") ?: "/usr/libexec/gstreamer-1.0/gst-plugin-scanner"; >- const char* helperPath = g_getenv("GST_INSTALL_PLUGINS_HELPER ") ?: "/usr/libexec/gst-install-plugins-helper"; >+ auto scannerPath = Environment::get("GST_PLUGIN_SCANNER") ?: "/usr/libexec/gstreamer-1.0/gst-plugin-scanner"_s; >+ auto helperPath = Environment::get("GST_INSTALL_PLUGINS_HELPER ") ?: "/usr/libexec/gst-install-plugins-helper"_s; > >- bindIfExists(args, scannerPath); >- bindIfExists(args, helperPath); >+ bindIfExists(args, scannerPath.utf8().data()); >+ bindIfExists(args, helperPath.utf8().data()); > } > > static void bindOpenGL(Vector<CString>& args) >@@ -720,12 +721,12 @@ GRefPtr<GSubprocess> bubblewrapSpawn(GSubprocessLauncher* launcher, const Proces > // We would have to parse ld config files for more info. > bindPathVar(sandboxArgs, "LD_LIBRARY_PATH"); > >- const char* libraryPath = g_getenv("LD_LIBRARY_PATH"); >- if (libraryPath && libraryPath[0]) { >+ auto libraryPath = Environment::get("LD_LIBRARY_PATH"); >+ if (!libraryPath.isEmpty()) { > // On distros using a suid bwrap it drops this env var > // so we have to pass it through to the children. > sandboxArgs.appendVector(Vector<CString>({ >- "--setenv", "LD_LIBRARY_PATH", libraryPath, >+ "--setenv", "LD_LIBRARY_PATH", libraryPath.utf8(), > })); > } > >@@ -804,9 +805,9 @@ GRefPtr<GSubprocess> bubblewrapSpawn(GSubprocessLauncher* launcher, const Proces > } > > #if ENABLE(DEVELOPER_MODE) >- const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH"); >- if (execDirectory) { >- String parentDir = FileSystem::directoryName(FileSystem::stringFromFileSystemRepresentation(execDirectory)); >+ auto execDirectory = Environment::get("WEBKIT_EXEC_PATH"); >+ if (!!execDirectory) { >+ String parentDir = FileSystem::directoryName(FileSystem::stringFromFileSystemRepresentation(execDirectory.utf8().data())); > bindIfExists(sandboxArgs, parentDir.utf8().data()); > } > >diff --git a/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp b/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp >index 0c39073fe1de7adaf5312683d816462f64d3ec6f..3de6d2a42a092ff48be44391d76f16dbd19222d3 100644 >--- a/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp >+++ b/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp >@@ -34,6 +34,7 @@ > #include <errno.h> > #include <fcntl.h> > #include <glib.h> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/RunLoop.h> > #include <wtf/UniStdExtras.h> >@@ -165,11 +166,11 @@ void ProcessLauncher::launchProcess() > GUniqueOutPtr<GError> error; > GRefPtr<GSubprocess> process; > #if OS(LINUX) >- const char* sandboxEnv = g_getenv("WEBKIT_FORCE_SANDBOX"); > bool sandboxEnabled = m_launchOptions.extraInitializationData.get("enable-sandbox") == "true"; > >- if (sandboxEnv) >- sandboxEnabled = !strcmp(sandboxEnv, "1"); >+ auto sandboxEnv = Environment::get("WEBKIT_FORCE_SANDBOX"); >+ if (!!sandboxEnv) >+ sandboxEnabled = sandboxEnv == "1"; > > if (sandboxEnabled && isInsideFlatpak()) > process = flatpakSpawn(launcher.get(), m_launchOptions, argv, socketPair.client, &error.outPtr()); >diff --git a/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >index 66896f1eb5fedeada412ed45f6e6e8c4c654e981..966b8da43fc5dcfaa60e2b2694b335154a4dfe1f 100644 >--- a/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >+++ b/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >@@ -34,6 +34,7 @@ > #import <spawn.h> > #import <sys/param.h> > #import <sys/stat.h> >+#import <wtf/Environment.h> > #import <wtf/MachSendRight.h> > #import <wtf/RunLoop.h> > #import <wtf/SoftLinking.h> >@@ -84,8 +85,8 @@ static NSString *systemDirectoryPath() > { > static NSString *path = [^{ > #if PLATFORM(IOS_FAMILY_SIMULATOR) >- char *simulatorRoot = getenv("SIMULATOR_ROOT"); >- return simulatorRoot ? [NSString stringWithFormat:@"%s/System/", simulatorRoot] : @"/System/"; >+ auto simulatorRoot = Environment::get("SIMULATOR_ROOT"); >+ return !!simulatorRoot ? [NSString stringWithFormat:@"%s/System/", simulatorRoot.utf8().data()] : @"/System/"; > #else > return @"/System/"; > #endif >@@ -118,12 +119,19 @@ void ProcessLauncher::launchProcess() > #if PLATFORM(IOS_FAMILY) > // Clients that set these environment variables explicitly do not have the values automatically forwarded by libxpc. > auto containerEnvironmentVariables = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0)); >- if (const char* environmentHOME = getenv("HOME")) >- xpc_dictionary_set_string(containerEnvironmentVariables.get(), "HOME", environmentHOME); >- if (const char* environmentCFFIXED_USER_HOME = getenv("CFFIXED_USER_HOME")) >- xpc_dictionary_set_string(containerEnvironmentVariables.get(), "CFFIXED_USER_HOME", environmentCFFIXED_USER_HOME); >- if (const char* environmentTMPDIR = getenv("TMPDIR")) >- xpc_dictionary_set_string(containerEnvironmentVariables.get(), "TMPDIR", environmentTMPDIR); >+ >+ auto environmentHOME = Environment::get("HOME"); >+ if (!!environmentHOME) >+ xpc_dictionary_set_string(containerEnvironmentVariables.get(), "HOME", environmentHOME.utf8().data()); >+ >+ auto environmentCFFIXED_USER_HOME = Environment::get("CFFIXED_USER_HOME"); >+ if (!!environmentCFFIXED_USER_HOME) >+ xpc_dictionary_set_string(containerEnvironmentVariables.get(), "CFFIXED_USER_HOME", environmentCFFIXED_USER_HOME.utf8().data()); >+ >+ auto environmentTMPDIR = Environment::get("TMPDIR"); >+ if (!!environmentTMPDIR) >+ xpc_dictionary_set_string(containerEnvironmentVariables.get(), "TMPDIR", environmentTMPDIR.utf8().data()); >+ > xpc_dictionary_set_value(initializationMessage.get(), "ContainerEnvironmentVariables", containerEnvironmentVariables.get()); > #endif > >diff --git a/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp b/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp >index 45760eeeed9ff4cce74ccdd7278d7cfd7f5ecea7..0a51bf31d740be643268c3325dd268d69f793a2c 100644 >--- a/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp >+++ b/Source/WebKit/UIProcess/gtk/HardwareAccelerationManager.cpp >@@ -29,6 +29,7 @@ > #include "WaylandCompositor.h" > #include <WebCore/NotImplemented.h> > #include <WebCore/PlatformDisplay.h> >+#include <wtf/Environment.h> > > #if USE(REDIRECTED_XCOMPOSITE_WINDOW) > #include <WebCore/PlatformDisplayX11.h> >@@ -52,8 +53,7 @@ HardwareAccelerationManager::HardwareAccelerationManager() > return; > #endif > >- const char* disableCompositing = getenv("WEBKIT_DISABLE_COMPOSITING_MODE"); >- if (disableCompositing && strcmp(disableCompositing, "0")) { >+ if (Environment::doesNotHaveValue("WEBKIT_DISABLE_COMPOSITING_MODE", "0")) { > m_canUseHardwareAcceleration = false; > return; > } >@@ -78,8 +78,7 @@ HardwareAccelerationManager::HardwareAccelerationManager() > } > #endif > >- const char* forceCompositing = getenv("WEBKIT_FORCE_COMPOSITING_MODE"); >- if (forceCompositing && strcmp(forceCompositing, "0")) >+ if (Environment::doesNotHaveValue("WEBKIT_FORCE_COMPOSITING_MODE", "0")) > m_forceHardwareAcceleration = true; > } > >diff --git a/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp b/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp >index 5127d3af6edd7804e31912d5c6909996c6fc2678..02d581d95dc89c60cdfecd36b6eb33153041e6b3 100644 >--- a/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp >+++ b/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp >@@ -38,6 +38,7 @@ > #include <WebCore/GStreamerCommon.h> > #include <WebCore/NotImplemented.h> > #include <WebCore/SchemeRegistry.h> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/glib/GUniquePtr.h> > #include <wtf/text/CString.h> >@@ -70,17 +71,15 @@ static bool initializeRemoteInspectorServer(const char* address) > > static bool memoryPressureMonitorDisabled() > { >- static const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR"); >- return disableMemoryPressureMonitor && !strcmp(disableMemoryPressureMonitor, "1"); >+ return Environment::hasValue("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1"); > } > > void WebProcessPool::platformInitialize() > { > #if ENABLE(REMOTE_INSPECTOR) >- if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER")) { >- if (!initializeRemoteInspectorServer(address)) >- g_unsetenv("WEBKIT_INSPECTOR_SERVER"); >- } >+ auto address = Environment::get("WEBKIT_INSPECTOR_SERVER"); >+ if (!!address) >+ initializeRemoteInspectorServer(address.utf8().data()); > #endif > > if (!memoryPressureMonitorDisabled()) >@@ -93,8 +92,7 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& > parameters.proxySettings = m_networkProxySettings; > > parameters.shouldAlwaysUseComplexTextCodePath = true; >- const char* forceComplexText = getenv("WEBKIT_FORCE_COMPLEX_TEXT"); >- if (forceComplexText && !strcmp(forceComplexText, "0")) >+ if (Environment::hasValue("WEBKIT_FORCE_COMPLEX_TEXT", "0")) > parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath; > > if (memoryPressureMonitorDisabled()) >diff --git a/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp b/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp >index f51017a8ca29ed07994d7d207c95714112a38bf5..63996d4aa6a103e98051138c974e6d896cad35a8 100644 >--- a/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp >+++ b/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp >@@ -37,6 +37,7 @@ > #include <WebCore/NotImplemented.h> > #include <WebCore/SchemeRegistry.h> > #include <cstdlib> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > > #if ENABLE(REMOTE_INSPECTOR) >@@ -77,10 +78,9 @@ static bool initializeRemoteInspectorServer(const char* address) > void WebProcessPool::platformInitialize() > { > #if ENABLE(REMOTE_INSPECTOR) >- if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER")) { >- if (!initializeRemoteInspectorServer(address)) >- g_unsetenv("WEBKIT_INSPECTOR_SERVER"); >- } >+ auto address = Environment::get("WEBKIT_INSPECTOR_SERVER"); >+ if (!!address) >+ initializeRemoteInspectorServer(address.utf8().data()); > #endif > } > >@@ -88,8 +88,7 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& > { > parameters.memoryCacheDisabled = m_memoryCacheDisabled || cacheModel() == CacheModel::DocumentViewer; > >- const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR"); >- if (disableMemoryPressureMonitor && !strcmp(disableMemoryPressureMonitor, "1")) >+ if (Environment::hasValue("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1")) > parameters.shouldSuppressMemoryPressureHandler = true; > > #if USE(GSTREAMER) >diff --git a/Source/WebKit/WebProcess/EntryPoint/unix/WebProcessMain.cpp b/Source/WebKit/WebProcess/EntryPoint/unix/WebProcessMain.cpp >index eedd4425b7fef68be8769c990d1575fd5fcee667..709c7bc21920869da15aa7b12871813de2a2506e 100644 >--- a/Source/WebKit/WebProcess/EntryPoint/unix/WebProcessMain.cpp >+++ b/Source/WebKit/WebProcess/EntryPoint/unix/WebProcessMain.cpp >@@ -23,9 +23,10 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >+#include "config.h" > #include "WebProcessMainUnix.h" > >-#include <cstdlib> >+#include <wtf/Environment.h> > > #if USE(GCRYPT) > #include <pal/crypto/gcrypt/Initialization.h> >@@ -42,8 +43,8 @@ int main(int argc, char** argv) > // GnuTLS or simply stops parsing this variable. We intentionally do not > // overwrite this priority string if it's already set by the user. > // https://bugzilla.gnome.org/show_bug.cgi?id=738633 >- // WARNING: This needs to be KEPT IN SYNC with WebProcessMain.cpp. >- setenv("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128", 0); >+ // WARNING: This needs to be KEPT IN SYNC with NetworkProcessMain.cpp. >+ Environment::add("G_TLS_GNUTLS_PRIORITY", "NORMAL:%COMPAT:!VERS-SSL3.0:!ARCFOUR-128"); > > #if USE(GCRYPT) > PAL::GCrypt::initialize(); >diff --git a/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp b/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp >index b5f7ac489d28dd08f5bb210f413876d31d07cc57..c3f082c6a32758231b9a3ac3a9e64f97db1a3159 100644 >--- a/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp >+++ b/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp >@@ -33,6 +33,7 @@ > #include <gtk/gtk.h> > #include <libintl.h> > #include <libsoup/soup.h> >+#include <wtf/Environment.h> > > #if PLATFORM(X11) > #include <X11/Xlib.h> >@@ -46,7 +47,7 @@ public: > bool platformInitialize() override > { > #ifndef NDEBUG >- if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) >+ if (!!Environment::get("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) > g_usleep(30 * G_USEC_PER_SEC); > #endif > >diff --git a/Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp b/Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp >index 13192b44d436e22e974d3b6733da54ec7c31e4d3..202563c8d11c9b0839ae53e46068598fd0317b05 100644 >--- a/Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp >+++ b/Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp >@@ -34,6 +34,7 @@ > #include <iostream> > #include <libsoup/soup.h> > #include <wpe/wpe.h> >+#include <wtf/Environment.h> > > namespace WebKit { > using namespace WebCore; >@@ -43,7 +44,7 @@ public: > bool platformInitialize() override > { > #if ENABLE(DEVELOPER_MODE) >- if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) >+ if (!!Environment::get("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) > WTF::sleep(30_s); > #endif > >diff --git a/Source/WebKitLegacy/ios/Misc/WebUIKitSupport.mm b/Source/WebKitLegacy/ios/Misc/WebUIKitSupport.mm >index ad6fe54a1b20e7d6e50fa75b876c0cf7dbaddd81..9d969acf1d7b35c23dcbdb967ee701f36c7df369 100644 >--- a/Source/WebKitLegacy/ios/Misc/WebUIKitSupport.mm >+++ b/Source/WebKitLegacy/ios/Misc/WebUIKitSupport.mm >@@ -38,6 +38,7 @@ > #import <WebCore/Settings.h> > #import <WebCore/WebBackgroundTaskController.h> > #import <WebCore/WebCoreThreadSystemInterface.h> >+#import <wtf/Environment.h> > #import <wtf/spi/darwin/dyldSPI.h> > > using namespace WebCore; >@@ -106,8 +107,8 @@ const char *WebKitPlatformSystemRootDirectory(void) > #if PLATFORM(IOS_FAMILY_SIMULATOR) > static const char *platformSystemRootDirectory = nil; > if (!platformSystemRootDirectory) { >- char *simulatorRoot = getenv("IPHONE_SIMULATOR_ROOT"); >- platformSystemRootDirectory = simulatorRoot ? simulatorRoot : "/"; >+ auto simulatorRoot = Environment::get("IPHONE_SIMULATOR_ROOT"); >+ platformSystemRootDirectory = !!simulatorRoot ? simulatorRoot.utf8().data() : "/"; > } > return platformSystemRootDirectory; > #else >diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm >index 480f88502cb5bd55d7ea6d6702a6c6976520c018..0085522ee5e1d223b4657cbd8050f42c1d800a2f 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm >@@ -232,6 +232,7 @@ > #import <pal/spi/mac/NSSpellCheckerSPI.h> > #import <pal/spi/mac/NSWindowSPI.h> > #import <wtf/Assertions.h> >+#import <wtf/Environment.h> > #import <wtf/FileSystem.h> > #import <wtf/HashTraits.h> > #import <wtf/MainThread.h> >@@ -1606,9 +1607,9 @@ - (id)_initWithFrame:(NSRect)f frameName:(NSString *)frameName groupName:(NSStri > // need for Safari to unset it to prevent it from being passed to applications it launches. > // Unsetting it when a WebView is first created is as good a place as any. > // See <http://bugs.webkit.org/show_bug.cgi?id=4286> for more details. >- if (getenv("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH")) { >- unsetenv("DYLD_FRAMEWORK_PATH"); >- unsetenv("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH"); >+ if (!!Environment::get("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH")) { >+ Environment::remove("DYLD_FRAMEWORK_PATH"); >+ Environment::remove("WEBKIT_UNSET_DYLD_FRAMEWORK_PATH"); > } > #endif > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index eacb7f2221e36e6a896fa78eaa2ec8c79c2da395..047f21f05cdc9981999860abea90afcc31b12231 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,47 @@ >+2019-02-08 Ross Kirsling <ross.kirsling@sony.com> >+ >+ [WTF] Add environment variable helpers >+ https://bugs.webkit.org/show_bug.cgi?id=192405 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DumpRenderTree/mac/DumpRenderTree.mm: >+ (libraryPathForDumpRenderTree): >+ * DumpRenderTree/win/DumpRenderTree.cpp: >+ (libraryPathForDumpRenderTree): >+ * TestRunnerShared/IOSLayoutTestCommunication.cpp: >+ (setUpIOSLayoutTestCommunication): >+ * TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp: >+ (TestWebKitAPI::strip): >+ * TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp: >+ (beforeAll): >+ (afterAll): >+ * TestWebKitAPI/glib/WebKitGLib/TestMain.cpp: >+ (main): >+ * TestWebKitAPI/glib/WebKitGLib/WebKitTestBus.cpp: >+ (WebKitTestBus::run): >+ * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp: >+ (WTR::getOutputDir): >+ (WTR::initializeFontConfigSetting): >+ * WebKitTestRunner/InjectedBundle/gtk/InjectedBundleGtk.cpp: >+ (WTR::InjectedBundle::platformInitialize): >+ * WebKitTestRunner/InjectedBundle/gtk/InjectedBundleUtilities.cpp: >+ (WTR::topLevelPath): >+ * WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm: >+ (WTR::InjectedBundle::platformInitialize): >+ * WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm: >+ (WTR::InjectedBundle::platformInitialize): >+ * WebKitTestRunner/InjectedBundle/wpe/ActivateFontsWPE.cpp: >+ (WTR::topLevelPath): >+ (WTR::getOutputDir): >+ (WTR::activateFonts): >+ * WebKitTestRunner/TestController.cpp: >+ (WTR::TestController::libraryPathForTesting): >+ * WebKitTestRunner/gtk/main.cpp: >+ (main): >+ * WebKitTestRunner/wpe/main.cpp: >+ (main): >+ > 2019-02-08 Myles C. Maxfield <mmaxfield@apple.com> > > [Cocoa] Ask platform for generic font family mappings >diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >index b052412b0fc3d1b9a9df1340f2f56cf8394bcf6a..d51aec53b5347acaeaf7af576d1d5c3f88fe55a6 100644 >--- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm >+++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >@@ -91,6 +91,7 @@ > #import <WebKit/WebViewPrivate.h> > #import <getopt.h> > #import <wtf/Assertions.h> >+#import <wtf/Environment.h> > #import <wtf/FastMalloc.h> > #import <wtf/LoggingAccumulator.h> > #import <wtf/ObjCRuntimeExtras.h> >@@ -843,11 +844,11 @@ static void destroyWebViewAndOffscreenWindow(WebView *webView) > > static NSString *libraryPathForDumpRenderTree() > { >- char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP"); >- if (dumpRenderTreeTemp) >- return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:dumpRenderTreeTemp length:strlen(dumpRenderTreeTemp)]; >- else >+ auto dumpRenderTreeTemp = Environment::get("DUMPRENDERTREE_TEMP"); >+ if (!dumpRenderTreeTemp) > return [@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath]; >+ >+ return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:dumpRenderTreeTemp.utf8().data() length:dumpRenderTreeTemp.length()]; > } > > static void enableExperimentalFeatures(WebPreferences* preferences) >diff --git a/Tools/DumpRenderTree/win/DumpRenderTree.cpp b/Tools/DumpRenderTree/win/DumpRenderTree.cpp >index a0b685c75f9daf0feb7eaae1bb32a2e952d226f4..8ef63e04940e0e82a01742b836bae35a3000721a 100644 >--- a/Tools/DumpRenderTree/win/DumpRenderTree.cpp >+++ b/Tools/DumpRenderTree/win/DumpRenderTree.cpp >@@ -59,6 +59,7 @@ > #include <shlwapi.h> > #include <tchar.h> > #include <windows.h> >+#include <wtf/Environment.h> > #include <wtf/FileSystem.h> > #include <wtf/HashSet.h> > #include <wtf/NeverDestroyed.h> >@@ -213,16 +214,14 @@ static string toUTF8(const wchar_t* wideString, size_t length) > #if USE(CF) > static String libraryPathForDumpRenderTree() > { >- DWORD size = ::GetEnvironmentVariable(dumpRenderTreeTemp, 0, 0); >- Vector<TCHAR> buffer(size); >- if (::GetEnvironmentVariable(dumpRenderTreeTemp, buffer.data(), buffer.size())) { >- wstring path = buffer.data(); >- if (!path.empty() && (path[path.length() - 1] != L'\\')) >- path.append(L"\\"); >- return String (path.data(), path.length()); >- } >+ auto path = Environment::get(dumpRenderTreeTemp); >+ if (path.isEmpty()) >+ return FileSystem::localUserSpecificStorageDirectory(); > >- return FileSystem::localUserSpecificStorageDirectory(); >+ if (!path.endsWith('\\')) >+ path.append('\\'); >+ >+ return path; > } > #endif > >diff --git a/Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp b/Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp >index bc312bf82cd3b6efaa7130015aae8091882f7153..e2e6517220e1466df971934cc66929a1c37468f2 100644 >--- a/Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp >+++ b/Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp >@@ -32,6 +32,7 @@ > #include <sys/types.h> > #include <unistd.h> > #include <wtf/Assertions.h> >+#include <wtf/Environment.h> > > static int stdinSocket; > static int stdoutSocket; >@@ -48,11 +49,10 @@ static int connectToServer(sockaddr_in& serverAddress) > > void setUpIOSLayoutTestCommunication() > { >- char* portFromEnvironment = getenv("PORT"); >- if (!portFromEnvironment) >+ auto port = Environment::getInt("PORT"); >+ if (!port) > return; >- int port = atoi(portFromEnvironment); >- RELEASE_ASSERT(port > 0); >+ RELEASE_ASSERT(*port > 0); > isUsingTCP = true; > > struct hostent* host = gethostbyname("127.0.0.1"); >@@ -63,7 +63,7 @@ void setUpIOSLayoutTestCommunication() > (char*)&serverAddress.sin_addr.s_addr, > (char*)host->h_addr, > host->h_length); >- serverAddress.sin_port = htons(port); >+ serverAddress.sin_port = htons(*port); > > // This order matches the server side listener in Tools/Scripts/webkitpy/port/simulator_process.py SimulatorProcess._start() > stdinSocket = connectToServer(serverAddress); >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp b/Tools/TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp >index e1de83265fbf71dc683e7f3c51b553cb377ca8a4..15762af95c35e4651f2fd6cd9b01ff3051f22b90 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp >@@ -28,6 +28,7 @@ > > #include <WebKit/EnvironmentUtilities.h> > #include <stdlib.h> >+#include <wtf/Environment.h> > > namespace TestWebKitAPI { > >@@ -37,9 +38,9 @@ const char* const stripValue = "/" PROCESS_DYLIB; > > static const char* strip(const char* input) > { >- setenv(environmentVariable, input, 1); >+ Environment::set(environmentVariable, input); > WebKit::EnvironmentUtilities::stripValuesEndingWithString(environmentVariable, stripValue); >- return getenv(environmentVariable); >+ return Environment::get(environmentVariable).utf8().data(); > } > > TEST(WebKit, StripValuesEndingWithString) >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp >index 998ab2f2a29c26f7fa65d2b81e9e1ef27b4e5d3b..0754fe1dcfcfe27b74e358a3d4bfe56320ec926a 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp >@@ -21,6 +21,7 @@ > > #include "TestMain.h" > #include <gio/gio.h> >+#include <wtf/Environment.h> > #include <wtf/UUID.h> > #include <wtf/text/StringBuilder.h> > >@@ -343,7 +344,7 @@ static void testAutomationSessionApplicationInfo(Test* test, gconstpointer) > > void beforeAll() > { >- g_setenv("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2229", TRUE); >+ Environment::set("WEBKIT_INSPECTOR_SERVER", "127.0.0.1:2229"); > > AutomationTest::add("WebKitAutomationSession", "request-session", testAutomationSessionRequestSession); > Test::add("WebKitAutomationSession", "application-info", testAutomationSessionApplicationInfo); >@@ -351,5 +352,5 @@ void beforeAll() > > void afterAll() > { >- g_unsetenv("WEBKIT_INSPECTOR_SERVER"); >+ Environment::remove("WEBKIT_INSPECTOR_SERVER"); > } >diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp b/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp >index a155a5100a6bbaedf0ae1b52769a738718a0f5cf..493c65639b5aec0204e77a17d95e32c25f4ca985 100644 >--- a/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp >+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp >@@ -21,6 +21,7 @@ > #include "TestMain.h" > > #include <glib/gstdio.h> >+#include <wtf/Environment.h> > > #if PLATFORM(GTK) > #include <gtk/gtk.h> >@@ -66,19 +67,19 @@ static void removeNonEmptyDirectory(const char* directoryPath) > > int main(int argc, char** argv) > { >- g_unsetenv("DBUS_SESSION_BUS_ADDRESS"); >+ Environment::remove("DBUS_SESSION_BUS_ADDRESS"); > #if PLATFORM(GTK) > gtk_test_init(&argc, &argv, nullptr); > #else > g_test_init(&argc, &argv, nullptr); > #endif >- g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE); >- g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE); >- g_setenv("LC_ALL", "C", TRUE); >- g_setenv("GIO_USE_VFS", "local", TRUE); >- g_setenv("GSETTINGS_BACKEND", "memory", TRUE); >+ Environment::add("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH); >+ Environment::add("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH); >+ Environment::set("LC_ALL", "C"); >+ Environment::set("GIO_USE_VFS", "local"); >+ Environment::set("GSETTINGS_BACKEND", "memory"); > // Get rid of runtime warnings about deprecated properties and signals, since they break the tests. >- g_setenv("G_ENABLE_DIAGNOSTIC", "0", TRUE); >+ Environment::set("G_ENABLE_DIAGNOSTIC", "0"); > g_test_bug_base("https://bugs.webkit.org/"); > > registerGResource(); >diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestBus.cpp b/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestBus.cpp >index ba6476c8da15bb4b3b846640aa397a567d64525b..33f58c726e1c77d75a4d4b5d74c48a9ae3edb29b 100644 >--- a/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestBus.cpp >+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestBus.cpp >@@ -20,6 +20,8 @@ > #include "config.h" > #include "WebKitTestBus.h" > >+#include <wtf/Environment.h> >+ > WebKitTestBus::WebKitTestBus() > : m_bus(adoptGRef(g_test_dbus_new(G_TEST_DBUS_NONE))) > { >@@ -32,14 +34,14 @@ WebKitTestBus::~WebKitTestBus() > > bool WebKitTestBus::run() > { >- CString display = g_getenv("DISPLAY"); >- CString runtimeDir = g_getenv("XDG_RUNTIME_DIR"); >+ auto display = Environment::get("DISPLAY"); >+ auto runtimeDir = Environment::get("XDG_RUNTIME_DIR"); > g_test_dbus_up(m_bus.get()); > m_address = g_test_dbus_get_bus_address(m_bus.get()); >- if (!display.isNull()) >- g_setenv("DISPLAY", display.data(), FALSE); >- if (!runtimeDir.isNull()) >- g_setenv("XDG_RUNTIME_DIR", runtimeDir.data(), FALSE); >+ if (!!display) >+ Environment::add("DISPLAY", display); >+ if (!!runtimeDir) >+ Environment::add("XDG_RUNTIME_DIR", runtimeDir); > return !m_address.isNull(); > } > >diff --git a/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp b/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp >index 3f8e2440f283e4b4e5427ad644d2b3b4e31965a1..2148fa48391fade60512bd7b783c65fe3f64d55e 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp >@@ -34,6 +34,7 @@ > #include "InjectedBundleUtilities.h" > #include <fontconfig/fontconfig.h> > #include <gtk/gtk.h> >+#include <wtf/Environment.h> > #include <wtf/glib/GLibUtilities.h> > #include <wtf/glib/GUniquePtr.h> > >@@ -54,9 +55,9 @@ void initializeGtkSettings() > > CString getOutputDir() > { >- const char* webkitOutputDir = g_getenv("WEBKIT_OUTPUTDIR"); >- if (webkitOutputDir) >- return webkitOutputDir; >+ auto webkitOutputDir = Environment::get("WEBKIT_OUTPUTDIR"); >+ if (!!webkitOutputDir) >+ return webkitOutputDir.utf8(); > > CString topLevelPath = WTR::topLevelPath(); > GUniquePtr<char> outputDir(g_build_filename(topLevelPath.data(), "WebKitBuild", nullptr)); >@@ -80,7 +81,7 @@ static CString getFontsPath() > > void initializeFontConfigSetting() > { >- if (g_getenv("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION")) >+ if (!!Environment::get("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION")) > return; > > FcInit(); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleGtk.cpp b/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleGtk.cpp >index ba08431c4cd7ba7ce052851407f5bf53d50e4e62..b15ffe668bdc9ec42c79aecb88ace71b75957b69 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleGtk.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleGtk.cpp >@@ -29,6 +29,7 @@ > > #include <cstdio> > #include <glib.h> >+#include <wtf/Environment.h> > > namespace WTR { > >@@ -45,8 +46,7 @@ void InjectedBundle::platformInitialize(WKTypeRef) > // messages sent to the logger. > g_log_set_default_handler(logHandler, 0); > >- if (!g_getenv("WEBKIT_TOP_LEVEL")) >- g_setenv("WEBKIT_TOP_LEVEL", TOP_LEVEL_DIR, FALSE); >+ Environment::add("WEBKIT_TOP_LEVEL", TOP_LEVEL_DIR); > } > > } // namespace WTR >diff --git a/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleUtilities.cpp b/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleUtilities.cpp >index afbd3f74a1d60d7318d4b798d094320d9ca692ef..97ff792b2e8796fdb12c908903ff637ca8f03bd7 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleUtilities.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/gtk/InjectedBundleUtilities.cpp >@@ -30,6 +30,7 @@ > #include "InjectedBundleUtilities.h" > > #include <gtk/gtk.h> >+#include <wtf/Environment.h> > #include <wtf/glib/GLibUtilities.h> > #include <wtf/glib/GUniquePtr.h> > >@@ -37,8 +38,9 @@ namespace WTR { > > CString topLevelPath() > { >- if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL")) >- return topLevelDirectory; >+ auto topLevelDirectory = Environment::get("WEBKIT_TOP_LEVEL"); >+ if (!!topLevelDirectory) >+ return topLevelDirectory.utf8(); > > // If the environment variable wasn't provided then assume we were built into > // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build >diff --git a/Tools/WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm b/Tools/WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm >index 42908befef7a58f7ae04f05805314e5a45e4e3ed..0e9b8b4395b16169ac25f011e35c672ca12356e9 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/ios/InjectedBundleIOS.mm >@@ -26,13 +26,14 @@ > #import "InjectedBundle.h" > > #import <Foundation/Foundation.h> >+#import <wtf/Environment.h> > > namespace WTR { > > void InjectedBundle::platformInitialize(WKTypeRef) > { > // Work around missing /etc/catalog <rdar://problem/4292995>. >- setenv("XML_CATALOG_FILES", "", 0); >+ Environment::add("XML_CATALOG_FILES", ""); > > // Language was set up earlier in main(). Don't clobber it. > NSArray *languages = [[[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain] valueForKey:@"AppleLanguages"]; >diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm >index 50b1b13d7653210e3cf3ab79702422bd509aa75f..249b6081f0836fa2dd384ed5b390310575e91df2 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm >@@ -27,6 +27,7 @@ > #import "InjectedBundle.h" > > #import <Foundation/Foundation.h> >+#import <wtf/Environment.h> > > @interface NSSound () > + (void)_setAlertType:(NSUInteger)alertType; >@@ -39,8 +40,8 @@ void InjectedBundle::platformInitialize(WKTypeRef initializationUserData) > static const int BlueTintedAppearance = 1; > > // Work around missing /etc/catalog <rdar://problem/4292995>. >- setenv("XML_CATALOG_FILES", "", 0); >- setenv("XTYPE_ALLOW_AUTOACTIVATION", "1", 0); >+ Environment::add("XML_CATALOG_FILES", ""); >+ Environment::add("XTYPE_ALLOW_AUTOACTIVATION", "1"); > > // Language was set up earlier in main(). Don't clobber it. > NSArray *languages = [[[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain] valueForKey:@"AppleLanguages"]; >diff --git a/Tools/WebKitTestRunner/InjectedBundle/wpe/ActivateFontsWPE.cpp b/Tools/WebKitTestRunner/InjectedBundle/wpe/ActivateFontsWPE.cpp >index a49c7a292182591e2727b2b901e412b2de8e03da..0d475cca4d0d7c921c7faa29237b4a4e3f328ff0 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/wpe/ActivateFontsWPE.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/wpe/ActivateFontsWPE.cpp >@@ -27,6 +27,7 @@ > #include "ActivateFonts.h" > > #include <fontconfig/fontconfig.h> >+#include <wtf/Environment.h> > #include <wtf/glib/GLibUtilities.h> > #include <wtf/glib/GUniquePtr.h> > >@@ -34,8 +35,9 @@ namespace WTR { > > CString topLevelPath() > { >- if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL")) >- return topLevelDirectory; >+ auto topLevelDirectory = Environment::get("WEBKIT_TOP_LEVEL"); >+ if (!!topLevelDirectory) >+ return topLevelDirectory.utf8(); > > // If the environment variable wasn't provided then assume we were built into > // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build >@@ -48,9 +50,9 @@ CString topLevelPath() > > CString getOutputDir() > { >- const char* webkitOutputDir = g_getenv("WEBKIT_OUTPUTDIR"); >- if (webkitOutputDir) >- return webkitOutputDir; >+ auto webkitOutputDir = Environment::get("WEBKIT_OUTPUTDIR"); >+ if (!!webkitOutputDir) >+ return webkitOutputDir.utf8(); > > GUniquePtr<char> outputDir(g_build_filename(topLevelPath().data(), "WebKitBuild", nullptr)); > return outputDir.get(); >@@ -73,7 +75,7 @@ static CString getFontsPath() > > void activateFonts() > { >- if (g_getenv("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION")) >+ if (!!Environment::get("WEBKIT_SKIP_WEBKITTESTRUNNER_FONTCONFIG_INITIALIZATION")) > return; > > FcInit(); >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 4cc4cccc0f023876de4a00dab367ec8c681ac29b..45296b74186e9eeae4bef6dd6b119ef492522339 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -70,6 +70,7 @@ > #include <string> > #include <wtf/AutodrainedPool.h> > #include <wtf/CryptographicallyRandomNumber.h> >+#include <wtf/Environment.h> > #include <wtf/HexNumber.h> > #include <wtf/MainThread.h> > #include <wtf/ProcessPrivilege.h> >@@ -390,9 +391,9 @@ const char* TestController::libraryPathForTesting() > // FIXME: This may not be sufficient to prevent interactions/crashes > // when running more than one copy of DumpRenderTree. > // See https://bugs.webkit.org/show_bug.cgi?id=10906 >- char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP"); >- if (dumpRenderTreeTemp) >- return dumpRenderTreeTemp; >+ auto dumpRenderTreeTemp = Environment::get("DUMPRENDERTREE_TEMP"); >+ if (!!dumpRenderTreeTemp) >+ return dumpRenderTreeTemp.utf8().data(); > return platformLibraryPathForTesting(); > } > >diff --git a/Tools/WebKitTestRunner/gtk/main.cpp b/Tools/WebKitTestRunner/gtk/main.cpp >index a203956fc21048a5129f5c675e5913ee18f28344..4b8753aea01298395224b7357368c68ad090a502 100644 >--- a/Tools/WebKitTestRunner/gtk/main.cpp >+++ b/Tools/WebKitTestRunner/gtk/main.cpp >@@ -28,11 +28,12 @@ > #include "TestController.h" > #include <WebKit/WKTextCheckerGtk.h> > #include <gtk/gtk.h> >+#include <wtf/Environment.h> > #include <wtf/glib/GRefPtr.h> > > int main(int argc, char** argv) > { >- g_setenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1", FALSE); >+ Environment::add("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1"); > > gtk_init(&argc, &argv); > >diff --git a/Tools/WebKitTestRunner/wpe/main.cpp b/Tools/WebKitTestRunner/wpe/main.cpp >index d62269dd3998eae0bb5ddc0b234f1b0096480bd7..0025bae15d5d424bd28ba5f58b6bf72f0523a58d 100644 >--- a/Tools/WebKitTestRunner/wpe/main.cpp >+++ b/Tools/WebKitTestRunner/wpe/main.cpp >@@ -27,10 +27,11 @@ > > #include "TestController.h" > #include <glib.h> >+#include <wtf/Environment.h> > > int main(int argc, char** argv) > { >- g_setenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1", FALSE); >+ Environment::add("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR", "1"); > > WTR::TestController controller(argc, const_cast<const char**>(argv)); > return 0;
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