From 9cdbeb08092ae10c0fd379eb369106faf1da94a7 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 10 Sep 2025 14:44:38 +0200 Subject: [PATCH 1/2] [core] fix getenv namespace error with libc++ Fixes https://github.com/root-project/root/issues/19850 --- core/foundation/src/FoundationUtils.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/foundation/src/FoundationUtils.cxx b/core/foundation/src/FoundationUtils.cxx index 7938c55662b2f..1e5deb25e7d57 100644 --- a/core/foundation/src/FoundationUtils.cxx +++ b/core/foundation/src/FoundationUtils.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -150,7 +151,7 @@ const std::string& GetFallbackRootSys() { #ifdef ROOTPREFIX static bool IgnorePrefix() { - static bool ignorePrefix = ::getenv("ROOTIGNOREPREFIX"); + static bool ignorePrefix = std::getenv("ROOTIGNOREPREFIX"); return ignorePrefix; } #endif @@ -164,7 +165,7 @@ const std::string& GetRootSys() { #endif static std::string rootsys; if (rootsys.empty()) { - if (const char* envValue = ::getenv("ROOTSYS")) { + if (const char* envValue = std::getenv("ROOTSYS")) { rootsys = envValue; // We cannot use gSystem->UnixPathName. ConvertToUnixPath(rootsys); From 0c1f275d7eb48f010fe82d3da8f9729ba1460c24 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 10 Sep 2025 18:50:34 +0200 Subject: [PATCH 2/2] Use std::getenv consistently, and modernize C headernames --- .../clingwrapper/src/clingwrapper.cxx | 16 ++--- core/clingutils/src/TClingUtils.cxx | 8 +-- core/dictgen/src/rootcling_impl.cxx | 14 ++--- core/foundation/src/FoundationUtils.cxx | 4 +- core/metacling/src/TCling.cxx | 2 +- .../rootcling_stage1/src/rootcling_stage1.cxx | 4 +- .../src/textinput/TerminalDisplayUnix.cpp | 8 +-- core/unix/src/TUnixSystem.cxx | 6 +- core/winnt/src/TWinNTSystem.cxx | 24 ++++---- documentation/doxygen/filter.cxx | 10 ++-- .../cling/lib/Interpreter/CIFactory.cpp | 2 +- .../lib/Interpreter/DynamicLibraryManager.cpp | 2 +- .../cling/lib/UserInterface/UserInterface.cpp | 2 +- interpreter/cling/lib/Utils/Paths.cpp | 2 +- interpreter/cling/lib/Utils/PlatformWin.cpp | 8 +-- interpreter/cling/lib/Utils/UTF8.cpp | 2 +- interpreter/cling/test/Pragmas/add_env_path.C | 2 +- interpreter/cling/tools/driver/cling.cpp | 2 +- main/src/rmain.cxx | 4 +- net/davix/src/TDavixFile.cxx | 30 +++++----- net/rpdutils/src/rpdutils.cxx | 24 ++++---- .../tests/Common/CoolDBUnitTest.h | 6 +- roottest/scripts/pt_collector.cpp | 12 ++-- roottest/scripts/pt_mymalloc.cpp | 12 ++-- rootx/src/rootx.cxx | 58 +++++++++---------- test/MainEvent.cxx | 4 +- tmva/tmvagui/src/tmvaglob.cxx | 2 +- tutorials/legacy/rootalias.C | 4 +- 28 files changed, 137 insertions(+), 137 deletions(-) diff --git a/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx b/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx index cf3b9c15fa0c7..f63dff0846220 100644 --- a/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx +++ b/bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx @@ -39,7 +39,7 @@ #include "TThread.h" // Standard -#include +#include #include // for std::count, std::remove #include #include @@ -47,9 +47,9 @@ #include #include #include -#include -#include // for getenv -#include +#include +#include // for getenv +#include #include // temp @@ -229,7 +229,7 @@ class TExceptionHandlerImp : public TExceptionHandler { gInterpreter->ClearFileBusy(); } - if (!getenv("CPPYY_CRASH_QUIET")) + if (!std::getenv("CPPYY_CRASH_QUIET")) do_trace(sig); // jump back, if catch point set @@ -263,7 +263,7 @@ class ApplicationStarter { g_globalidx[nullptr] = 0; // disable fast path if requested - if (getenv("CPPYY_DISABLE_FASTPATH")) gEnableFastPath = false; + if (std::getenv("CPPYY_DISABLE_FASTPATH")) gEnableFastPath = false; // fill the set of STL names const char* stl_names[] = {"allocator", "auto_ptr", "bad_alloc", "bad_cast", @@ -296,7 +296,7 @@ class ApplicationStarter { // set opt level (default to 2 if not given; Cling itself defaults to 0) int optLevel = 2; - if (getenv("CPPYY_OPT_LEVEL")) optLevel = atoi(getenv("CPPYY_OPT_LEVEL")); + if (std::getenv("CPPYY_OPT_LEVEL")) optLevel = atoi(std::getenv("CPPYY_OPT_LEVEL")); if (optLevel != 0) { std::ostringstream s; s << "#pragma cling optimize " << optLevel; @@ -324,7 +324,7 @@ class ApplicationStarter { gInterpreter->Declare("namespace __cppyy_internal { struct Sep; }"); // retrieve all initial (ROOT) C++ names in the global scope to allow filtering later - if (!getenv("CPPYY_NO_ROOT_FILTER")) { + if (!std::getenv("CPPYY_NO_ROOT_FILTER")) { gROOT->GetListOfGlobals(true); // force initialize gROOT->GetListOfGlobalFunctions(true); // id. std::set initial; diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index d8ca763e52866..331e97180db6e 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -19,8 +19,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -5188,7 +5188,7 @@ static void replaceEnvVars(const char* varname, std::string& txt) endVar = endVarName; } - const char* val = getenv(txt.substr(beginVarName, + const char* val = std::getenv(txt.substr(beginVarName, endVarName - beginVarName).c_str()); if (!val) val = ""; @@ -5210,7 +5210,7 @@ static void replaceEnvVars(const char* varname, std::string& txt) void ROOT::TMetaUtils::SetPathsForRelocatability(std::vector& clingArgs ) { - const char* envInclPath = getenv("ROOT_INCLUDE_PATH"); + const char* envInclPath = std::getenv("ROOT_INCLUDE_PATH"); if (!envInclPath) return; diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index fb5961732e7a1..e6d20854e92e6 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -2805,11 +2805,11 @@ void CreateDictHeader(std::ostream &dictStream, const std::string &main_dictname // write one and include in there a few things for backward // compatibility. << "\n/*******************************************************************/\n" - << "#include \n" - << "#include \n" - << "#include \n" - << "#include \n" - << "#include \n" + << "#include \n" + << "#include \n" + << "#include \n" + << "#include \n" + << "#include \n" << "#define G__DICTIONARY\n" << "#include \"ROOT/RConfig.hxx\"\n" << "#include \"TClass.h\"\n" @@ -3661,7 +3661,7 @@ static void MaybeSuppressWin32CrashDialogs() { // Suppress error dialogs to avoid hangs on build nodes. // One can use an environment variable (Cling_GuiOnAssert) to enable // the error dialogs. - const char *EnablePopups = getenv("Cling_GuiOnAssert"); + const char *EnablePopups = std::getenv("Cling_GuiOnAssert"); if (EnablePopups == nullptr || EnablePopups[0] == '0') { ::_set_error_mode(_OUT_TO_STDERR); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); @@ -6018,7 +6018,7 @@ int GenReflexMain(int argc, char **argv) //std::string verbosityOption("-v4"); // To be uncommented for the testing phase. It should be -v std::string verbosityOption("-v2"); if (options[SILENT]) verbosityOption = "-v0"; - if (options[VERBOSE] || getenv ("VERBOSE")) verbosityOption = "-v3"; + if (options[VERBOSE] || std::getenv ("VERBOSE")) verbosityOption = "-v3"; if (options[DEBUG]) verbosityOption = "-v4"; genreflex::verbose = verbosityOption == "-v4"; diff --git a/core/foundation/src/FoundationUtils.cxx b/core/foundation/src/FoundationUtils.cxx index 1e5deb25e7d57..702c00377c8c2 100644 --- a/core/foundation/src/FoundationUtils.cxx +++ b/core/foundation/src/FoundationUtils.cxx @@ -24,8 +24,8 @@ #include #include -#include -#include +#include +#include #ifdef _WIN32 #include diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 911f0f280c616..b654ee0b39112 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -3547,7 +3547,7 @@ void TCling::RegisterLoadedSharedLibrary(const char* filename) // Check that this is not a system library static const int bufsize = 260; char posixwindir[bufsize]; - char *windir = getenv("WINDIR"); + char *windir = std::getenv("WINDIR"); if (windir) cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize); else diff --git a/core/rootcling_stage1/src/rootcling_stage1.cxx b/core/rootcling_stage1/src/rootcling_stage1.cxx index 73c76d1e38ab0..6f4071149646f 100644 --- a/core/rootcling_stage1/src/rootcling_stage1.cxx +++ b/core/rootcling_stage1/src/rootcling_stage1.cxx @@ -24,7 +24,7 @@ static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym; ROOT::Internal::RootCling::TROOTSYSSetter gROOTSYSSetter; static const char *GetIncludeDir() { - auto renv = getenv("ROOTSYS"); + auto renv = std::getenv("ROOTSYS"); if (!renv) return nullptr; static std::string incdir = std::string(renv) + "/include"; @@ -32,7 +32,7 @@ static const char *GetIncludeDir() { } static const char *GetEtcDir() { - auto renv = getenv("ROOTSYS"); + auto renv = std::getenv("ROOTSYS"); if (!renv) return nullptr; static std::string etcdir = std::string(renv) + "/etc"; diff --git a/core/textinput/src/textinput/TerminalDisplayUnix.cpp b/core/textinput/src/textinput/TerminalDisplayUnix.cpp index df5c2cac1a274..cf0f03232b51d 100644 --- a/core/textinput/src/textinput/TerminalDisplayUnix.cpp +++ b/core/textinput/src/textinput/TerminalDisplayUnix.cpp @@ -18,9 +18,9 @@ #include "textinput/TerminalDisplayUnix.h" #include -#include +#include // putenv not in cstdlib on Solaris -#include +#include #include #include #include @@ -118,7 +118,7 @@ namespace textinput { TerminalConfigUnix::Get().TIOS()->c_lflag &= ~(ECHO); TerminalConfigUnix::Get().TIOS()->c_lflag |= ECHOCTL|ECHOKE|ECHOE; #endif - const char* TERM = getenv("TERM"); + const char* TERM = std::getenv("TERM"); if (TERM && strstr(TERM, "256")) { fNColors = 256; } @@ -153,7 +153,7 @@ namespace textinput { } #else // try $COLUMNS - const char* COLUMNS = getenv("COLUMNS"); + const char* COLUMNS = std::getenv("COLUMNS"); if (COLUMNS) { long width = atol(COLUMNS); if (width > 4 && width < 1024*16) { diff --git a/core/unix/src/TUnixSystem.cxx b/core/unix/src/TUnixSystem.cxx index de53edc99fd5f..96be304d40302 100644 --- a/core/unix/src/TUnixSystem.cxx +++ b/core/unix/src/TUnixSystem.cxx @@ -46,7 +46,7 @@ //#define G__OLDEXPAND #include -#include +#include #include #if defined(R__SUN) || defined(R__AIX) || \ defined(R__LINUX) || defined(R__SOLARIS) || \ @@ -704,7 +704,7 @@ void TUnixSystem::SetDisplay() } } #ifndef R__HAS_COCOA - if (!gROOT->IsBatch() && !getenv("DISPLAY")) { + if (!gROOT->IsBatch() && !std::getenv("DISPLAY")) { Error("SetDisplay", "Can't figure out DISPLAY, set it manually\n" "In case you run a remote ssh session, restart your ssh session with:\n" "=========> ssh -Y"); @@ -2139,7 +2139,7 @@ void TUnixSystem::Setenv(const char *name, const char *value) const char *TUnixSystem::Getenv(const char *name) { - return ::getenv(name); + return std::getenv(name); } //////////////////////////////////////////////////////////////////////////////// diff --git a/core/winnt/src/TWinNTSystem.cxx b/core/winnt/src/TWinNTSystem.cxx index 1809f7f4e080f..820d8c5367ce6 100644 --- a/core/winnt/src/TWinNTSystem.cxx +++ b/core/winnt/src/TWinNTSystem.cxx @@ -50,9 +50,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include #include @@ -827,7 +827,7 @@ namespace { // determine the fileopen.C file path: TString fileopen = "fileopen.C"; TString rootmacrodir = "macros"; - sys->PrependPathName(getenv("ROOTSYS"), rootmacrodir); + sys->PrependPathName(std::getenv("ROOTSYS"), rootmacrodir); sys->PrependPathName(rootmacrodir.Data(), fileopen); if (regROOTwrite) { @@ -1283,7 +1283,7 @@ Int_t TWinNTSystem::GetCryptoRandom(void *buf, Int_t len) const char *TWinNTSystem::HostName() { if (fHostname == "") - fHostname = ::getenv("COMPUTERNAME"); + fHostname = std::getenv("COMPUTERNAME"); if (fHostname == "") { // This requires a DNS query - but we need it for fallback char hn[64]; @@ -2225,23 +2225,23 @@ std::string TWinNTSystem::GetHomeDirectory(const char *userName) const void TWinNTSystem::FillWithHomeDirectory(const char *userName, char *mydir) const { const char *h = nullptr; - if (!(h = ::getenv("home"))) h = ::getenv("HOME"); + if (!(h = std::getenv("home"))) h = std::getenv("HOME"); if (h) { strlcpy(mydir, h,kMAXPATHLEN); } else { // for Windows NT HOME might be defined as either $(HOMESHARE)/$(HOMEPATH) // or $(HOMEDRIVE)/$(HOMEPATH) - h = ::getenv("HOMESHARE"); - if (!h) h = ::getenv("HOMEDRIVE"); + h = std::getenv("HOMESHARE"); + if (!h) h = std::getenv("HOMEDRIVE"); if (h) { strlcpy(mydir, h,kMAXPATHLEN); - h = ::getenv("HOMEPATH"); + h = std::getenv("HOMEPATH"); if(h) strlcat(mydir, h,kMAXPATHLEN); } // on Windows Vista HOME is usually defined as $(USERPROFILE) if (!h) { - h = ::getenv("USERPROFILE"); + h = std::getenv("USERPROFILE"); if (h) strlcpy(mydir, h,kMAXPATHLEN); } } @@ -3861,7 +3861,7 @@ void TWinNTSystem::Setenv(const char *name, const char *value) const char *TWinNTSystem::Getenv(const char *name) { - const char *env = ::getenv(name); + const char *env = std::getenv(name); if (!env) { if (::_stricmp(name,"home") == 0 ) { env = HomeDirectory(); diff --git a/documentation/doxygen/filter.cxx b/documentation/doxygen/filter.cxx index e5af9117be3ea..bcf606ef52373 100644 --- a/documentation/doxygen/filter.cxx +++ b/documentation/doxygen/filter.cxx @@ -85,8 +85,8 @@ #include #include #include -#include -#include +#include +#include #include using std::string; @@ -161,15 +161,15 @@ int main(int argc, char *argv[]) gCwd = gFileName.substr(0,last); // Retrieve the output directory - gOutDir = getenv("DOXYGEN_OUTPUT_DIRECTORY"); + gOutDir = std::getenv("DOXYGEN_OUTPUT_DIRECTORY"); ReplaceAll(gOutDir,"\"",""); // Retrieve the source directory - gSourceDir = getenv("DOXYGEN_SOURCE_DIRECTORY"); + gSourceDir = std::getenv("DOXYGEN_SOURCE_DIRECTORY"); ReplaceAll(gSourceDir,"\"",""); // Retrieve the python executable - gPythonExec = getenv("Python3_EXECUTABLE"); + gPythonExec = std::getenv("Python3_EXECUTABLE"); ReplaceAll(gPythonExec,"\"",""); // Open the input file name. diff --git a/interpreter/cling/lib/Interpreter/CIFactory.cpp b/interpreter/cling/lib/Interpreter/CIFactory.cpp index fd5452f4426d9..a2a8efde12170 100644 --- a/interpreter/cling/lib/Interpreter/CIFactory.cpp +++ b/interpreter/cling/lib/Interpreter/CIFactory.cpp @@ -786,7 +786,7 @@ namespace { clang::HeaderSearchOptions& HSOpts = CI.getHeaderSearchOpts(); // Register prebuilt module paths where we will lookup module files. addPrebuiltModulePaths(HSOpts, - getPathsFromEnv(getenv("CLING_PREBUILT_MODULE_PATH"))); + getPathsFromEnv(std::getenv("CLING_PREBUILT_MODULE_PATH"))); // Register all modulemaps necessary for cling to run. If we have specified // -fno-implicit-module-maps then we have to add them explicitly to the list diff --git a/interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp b/interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp index 50d7f3b672f94..111ef7f334f63 100644 --- a/interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp +++ b/interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp @@ -47,7 +47,7 @@ namespace cling { // Behaviour is to not add paths that don't exist...In an interpreted env // does this make sense? Path could pop into existance at any time. for (const char* Var : kSysLibraryEnv) { - if (const char* Env = ::getenv(Var)) { + if (const char* Env = std::getenv(Var)) { llvm::SmallVector CurPaths; SplitPaths(Env, CurPaths, utils::kPruneNonExistant, platform::kEnvDelim); for (const auto& Path : CurPaths) diff --git a/interpreter/cling/lib/UserInterface/UserInterface.cpp b/interpreter/cling/lib/UserInterface/UserInterface.cpp index e4e26b86b4b7e..92cda1591adb0 100644 --- a/interpreter/cling/lib/UserInterface/UserInterface.cpp +++ b/interpreter/cling/lib/UserInterface/UserInterface.cpp @@ -69,7 +69,7 @@ namespace { }; llvm::SmallString<512> GetHistoryFilePath() { - if (getenv("CLING_NOHISTORY")) { + if (std::getenv("CLING_NOHISTORY")) { return {}; } diff --git a/interpreter/cling/lib/Utils/Paths.cpp b/interpreter/cling/lib/Utils/Paths.cpp index 2a182beef4bbd..86c4d95087ff0 100644 --- a/interpreter/cling/lib/Utils/Paths.cpp +++ b/interpreter/cling/lib/Utils/Paths.cpp @@ -39,7 +39,7 @@ bool ExpandEnvVars(std::string& Str, bool Path) { std::string EnvVar = Str.substr(DPos + 1, Length -1); //"HOME" std::string FullPath; - if (const char* Tok = ::getenv(EnvVar.c_str())) + if (const char* Tok = std::getenv(EnvVar.c_str())) FullPath = Tok; Str.replace(DPos, Length, FullPath); diff --git a/interpreter/cling/lib/Utils/PlatformWin.cpp b/interpreter/cling/lib/Utils/PlatformWin.cpp index 0e9200bb5d695..b059df42ea7d1 100644 --- a/interpreter/cling/lib/Utils/PlatformWin.cpp +++ b/interpreter/cling/lib/Utils/PlatformWin.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -178,7 +178,7 @@ static bool getVSEnvironmentString(int VSVersion, std::string& Path, const char* Verbose) { std::ostringstream Key; Key << "VS" << VSVersion * 10 << "COMNTOOLS"; - const char* Tools = ::getenv(Key.str().c_str()); + const char* Tools = std::getenv(Key.str().c_str()); if (!Tools) { if (Verbose) logSearch("Environment", Key.str()); @@ -437,7 +437,7 @@ bool GetVisualStudioDirs(std::string& Path, std::string* WinSDK, // The Visual Studio 2017 path is very different than the previous versions, // and even the registry entries are different, so for now let's try the // trivial way first (using the 'VCToolsInstallDir' environment variable) - if (const char* VCToolsInstall = ::getenv("VCToolsInstallDir")) { + if (const char* VCToolsInstall = std::getenv("VCToolsInstallDir")) { trimString(VCToolsInstall, "\\DUMMY", Path); if (Verbose) cling::errs() << "Using VCToolsInstallDir '" << VCToolsInstall << "'\n"; @@ -453,7 +453,7 @@ bool GetVisualStudioDirs(std::string& Path, std::string* WinSDK, // Check the environment variables that vsvars32.bat sets. // We don't do this first so we can run from other VSStudio shells properly - if (const char* VCInstall = ::getenv("VCINSTALLDIR")) { + if (const char* VCInstall = std::getenv("VCINSTALLDIR")) { trimString(VCInstall, "\\VC", Path); if (Verbose) cling::errs() << "Using VCINSTALLDIR '" << VCInstall << "'\n"; diff --git a/interpreter/cling/lib/Utils/UTF8.cpp b/interpreter/cling/lib/Utils/UTF8.cpp index 8d70189088bdd..a8be68d8f2815 100644 --- a/interpreter/cling/lib/Utils/UTF8.cpp +++ b/interpreter/cling/lib/Utils/UTF8.cpp @@ -258,7 +258,7 @@ class EscapeSequence::ByteDumper { EscapeSequence::EscapeSequence() : m_Utf8Out(false) { #if !defined(_WIN32) if (!::strcasestr(m_Loc.name().c_str(), "utf-8")) { - if (const char* LANG = ::getenv("LANG")) { + if (const char* LANG = std::getenv("LANG")) { if (::strcasestr(LANG, "utf-8")) { #if !defined(__APPLE__) || !defined(__GLIBCXX__) m_Loc = std::locale(LANG); diff --git a/interpreter/cling/test/Pragmas/add_env_path.C b/interpreter/cling/test/Pragmas/add_env_path.C index 91ed6809c99c1..99ac809e7f9bd 100644 --- a/interpreter/cling/test/Pragmas/add_env_path.C +++ b/interpreter/cling/test/Pragmas/add_env_path.C @@ -14,7 +14,7 @@ extern "C" int cling_testlibrary_function(); #ifndef _WIN32 - #include + #include #else extern "C" int _putenv_s(const char *name, const char *value); #define setenv(n, v, o) _putenv_s(n,v) diff --git a/interpreter/cling/tools/driver/cling.cpp b/interpreter/cling/tools/driver/cling.cpp index 1c7ae3800d8f6..fbcdea29fd854 100644 --- a/interpreter/cling/tools/driver/cling.cpp +++ b/interpreter/cling/tools/driver/cling.cpp @@ -118,7 +118,7 @@ int main( int argc, char **argv ) { // Suppress error dialogs to avoid hangs on build nodes. // One can use an environment variable (Cling_GuiOnAssert) to enable // the error dialogs. - const char *EnablePopups = getenv("Cling_GuiOnAssert"); + const char *EnablePopups = std::getenv("Cling_GuiOnAssert"); if (EnablePopups == nullptr || EnablePopups[0] == '0') { ::_set_error_mode(_OUT_TO_STDERR); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); diff --git a/main/src/rmain.cxx b/main/src/rmain.cxx index 578dbadba6500..a4236e028216f 100644 --- a/main/src/rmain.cxx +++ b/main/src/rmain.cxx @@ -41,9 +41,9 @@ void handle_notebook_option(int argc, char **argv) if (notebook > 0) { // Build command #ifdef ROOTBINDIR - if (getenv("ROOTIGNOREPREFIX")) + if (std::getenv("ROOTIGNOREPREFIX")) #endif - snprintf(arg0, sizeof(arg0), "%s/bin/%s", getenv("ROOTSYS"), ROOTNBBINARY); + snprintf(arg0, sizeof(arg0), "%s/bin/%s", std::getenv("ROOTSYS"), ROOTNBBINARY); #ifdef ROOTBINDIR else snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTNBBINARY); diff --git a/net/davix/src/TDavixFile.cxx b/net/davix/src/TDavixFile.cxx index 6610b6ddfff12..87094581b060a 100644 --- a/net/davix/src/TDavixFile.cxx +++ b/net/davix/src/TDavixFile.cxx @@ -213,14 +213,14 @@ bool findTokenInFile(const std::string &token_file, std::string &output_token) // https://github.com/WLCG-AuthZ-WG/bearer-token-discovery/blob/master/specification.md std::string DiscoverToken() { - const char *bearer_token = getenv("BEARER_TOKEN"); + const char *bearer_token = std::getenv("BEARER_TOKEN"); std::string token; if (bearer_token && *bearer_token){ if (!normalizeToken(bearer_token, token)) {return "";} if (!token.empty()) {return token;} } - const char *bearer_token_file = getenv("BEARER_TOKEN_FILE"); + const char *bearer_token_file = std::getenv("BEARER_TOKEN_FILE"); if (bearer_token_file) { if (!findTokenInFile(bearer_token_file, token)) {return "";} if (!token.empty()) {return token;} @@ -231,7 +231,7 @@ std::string DiscoverToken() std::string fname = "/bt_u"; fname += std::to_string(euid); - const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); + const char *xdg_runtime_dir = std::getenv("XDG_RUNTIME_DIR"); if (xdg_runtime_dir) { std::string xdg_token_file = std::string(xdg_runtime_dir) + fname; if (!findTokenInFile(xdg_token_file, token)) {return "";} @@ -266,10 +266,10 @@ static void TDavixFile_http_get_ucert(std::string &ucert, std::string &ukey) } // Try explicit environment for proxy - if (getenv("X509_USER_PROXY")) { + if (std::getenv("X509_USER_PROXY")) { if (gDebug > 0) Info("TDavixFile_http_get_ucert", "Found proxy in X509_USER_PROXY"); - ucert = ukey = getenv("X509_USER_PROXY"); + ucert = ukey = std::getenv("X509_USER_PROXY"); return; } @@ -297,10 +297,10 @@ static void TDavixFile_http_get_ucert(std::string &ucert, std::string &ukey) } // try with X509_* environment - if (getenv("X509_USER_CERT")) - ucert = getenv("X509_USER_CERT"); - if (getenv("X509_USER_KEY")) - ukey = getenv("X509_USER_KEY"); + if (std::getenv("X509_USER_CERT")) + ucert = std::getenv("X509_USER_CERT"); + if (std::getenv("X509_USER_KEY")) + ukey = std::getenv("X509_USER_KEY"); if ((ucert.size() > 0) || (ukey.size() > 0)) { if (gDebug > 0) @@ -411,7 +411,7 @@ void TDavixFileInternal::enableGridMode() if (gDebug > 1) Info("enableGridMode", " grid mode enabled !"); - if( ( env_var = getenv("X509_CERT_DIR")) == NULL){ + if( ( env_var = std::getenv("X509_CERT_DIR")) == NULL){ env_var= "/etc/grid-security/certificates/"; } davixParam->addCertificateAuthorityPath(env_var); @@ -533,21 +533,21 @@ void TDavixFileInternal::parseConfig() } // S3 Auth - if (((env_var = gEnv->GetValue("Davix.S3.SecretKey", getenv("S3_SECRET_KEY"))) != NULL) - && ((env_var2 = gEnv->GetValue("Davix.S3.AccessKey", getenv("S3_ACCESS_KEY"))) != NULL)) { + if (((env_var = gEnv->GetValue("Davix.S3.SecretKey", std::getenv("S3_SECRET_KEY"))) != NULL) + && ((env_var2 = gEnv->GetValue("Davix.S3.AccessKey", std::getenv("S3_ACCESS_KEY"))) != NULL)) { Info("parseConfig", "Setting S3 SecretKey and AccessKey. Access Key : %s ", env_var2); davixParam->setAwsAuthorizationKeys(env_var, env_var2); // need to set region? - if ( (env_var = gEnv->GetValue("Davix.S3.Region", getenv("S3_REGION"))) != NULL) { + if ( (env_var = gEnv->GetValue("Davix.S3.Region", std::getenv("S3_REGION"))) != NULL) { setAwsRegion(env_var); } // need to set STS token? - if( (env_var = gEnv->GetValue("Davix.S3.Token", getenv("S3_TOKEN"))) != NULL) { + if( (env_var = gEnv->GetValue("Davix.S3.Token", std::getenv("S3_TOKEN"))) != NULL) { setAwsToken(env_var); } // need to set aws alternate? - if( (env_var = gEnv->GetValue("Davix.S3.Alternate", getenv("S3_ALTERNATE"))) != NULL) { + if( (env_var = gEnv->GetValue("Davix.S3.Alternate", std::getenv("S3_ALTERNATE"))) != NULL) { setAwsAlternate(strToBool(env_var, false)); } } diff --git a/net/rpdutils/src/rpdutils.cxx b/net/rpdutils/src/rpdutils.cxx index afcdb004aeff8..f36b01180014c 100644 --- a/net/rpdutils/src/rpdutils.cxx +++ b/net/rpdutils/src/rpdutils.cxx @@ -25,19 +25,19 @@ #include #include #include -#include -#include +#include +#include #include -#include +#include #include -#include +#include #include #include #include #include -#include +#include #include -#include +#include #include "snprintf.h" #if defined(__CYGWIN__) && defined(__GNUC__) @@ -1509,8 +1509,8 @@ int RpdCheckAuthAllow(int Sec, const char *Host) std::string theDaemonRc; // Check if a non-standard file has been requested - if (getenv("ROOTDAEMONRC")) - theDaemonRc = getenv("ROOTDAEMONRC"); + if (std::getenv("ROOTDAEMONRC")) + theDaemonRc = std::getenv("ROOTDAEMONRC"); if (theDaemonRc.length() <= 0) { if (getuid()) { @@ -1520,16 +1520,16 @@ int RpdCheckAuthAllow(int Sec, const char *Host) theDaemonRc = std::string(pw->pw_dir).append("/"); theDaemonRc.append(gDaemonRc); } else { - if (getenv("ROOTETCDIR")) { - theDaemonRc = std::string(getenv("ROOTETCDIR")).append("/system"); + if (std::getenv("ROOTETCDIR")) { + theDaemonRc = std::string(std::getenv("ROOTETCDIR")).append("/system"); theDaemonRc.append(gDaemonRc); } else theDaemonRc = std::string("/etc/root/system").append(gDaemonRc); } } else { // If running as super-user, check system file only - if (getenv("ROOTETCDIR")) { - theDaemonRc = std::string(getenv("ROOTETCDIR")).append("/system"); + if (std::getenv("ROOTETCDIR")) { + theDaemonRc = std::string(std::getenv("ROOTETCDIR")).append("/system"); theDaemonRc.append(gDaemonRc); } else theDaemonRc = std::string("/etc/root/system").append(gDaemonRc); diff --git a/roottest/root/meta/genreflex/ROOT-5768/RelationalCool/tests/Common/CoolDBUnitTest.h b/roottest/root/meta/genreflex/ROOT-5768/RelationalCool/tests/Common/CoolDBUnitTest.h index 8e5bd0cb6b2d4..1dceeba678e43 100644 --- a/roottest/root/meta/genreflex/ROOT-5768/RelationalCool/tests/Common/CoolDBUnitTest.h +++ b/roottest/root/meta/genreflex/ROOT-5768/RelationalCool/tests/Common/CoolDBUnitTest.h @@ -66,9 +66,9 @@ namespace cool s_app = new CoralApplication(); // Connection string - if ( getenv( COOLTESTDB ) ) + if ( std::getenv( COOLTESTDB ) ) { - s_connectionString = getenv( COOLTESTDB ); + s_connectionString = std::getenv( COOLTESTDB ); } else { @@ -94,7 +94,7 @@ namespace cool if ( sleepFor01466Prefix == "" ) { sleepFor01466Prefix = s_coolDBName; - if ( ::getenv( "CORAL_TESTSUITE_SLEEPFOR01466" ) ) + if ( std::getenv( "CORAL_TESTSUITE_SLEEPFOR01466" ) ) ::setenv( "CORAL_TESTSUITE_SLEEPFOR01466_PREFIX", sleepFor01466Prefix.c_str(), 1 ); } // Workaround for ORA-01466 (bug #87935) - END diff --git a/roottest/scripts/pt_collector.cpp b/roottest/scripts/pt_collector.cpp index c46972ebda708..609eb6a8806fa 100644 --- a/roottest/scripts/pt_collector.cpp +++ b/roottest/scripts/pt_collector.cpp @@ -1,17 +1,17 @@ -#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include #include #include -#include +#include #include #include "TAxis.h" diff --git a/roottest/scripts/pt_mymalloc.cpp b/roottest/scripts/pt_mymalloc.cpp index 83012a81275fa..ed81f3d448574 100644 --- a/roottest/scripts/pt_mymalloc.cpp +++ b/roottest/scripts/pt_mymalloc.cpp @@ -1,16 +1,16 @@ #include -#include +#include #include #include #if defined(__APPLE__) -#include +#include #else #include #endif #include -#include -#include -#include +#include +#include +#include #include // Intercepts calls to malloc, realloc, free, by planting replacement symbols. @@ -61,7 +61,7 @@ class PerfTrackMallocInterposition { // Open the FIFO: static const char* fifoenv = "PT_FIFONAME"; - const char* fifoname = getenv(fifoenv); + const char* fifoname = std::getenv(fifoenv); if (fifoname) { fFifoFD = open(fifoname, O_WRONLY); if (fFifoFD < 0) { diff --git a/rootx/src/rootx.cxx b/rootx/src/rootx.cxx index 978b428511a77..9f90c9250bae8 100644 --- a/rootx/src/rootx.cxx +++ b/rootx/src/rootx.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -123,62 +123,62 @@ static void SetRootSys() static void SetLibraryPath() { # ifdef ROOTPREFIX - if (getenv("ROOTIGNOREPREFIX")) { + if (std::getenv("ROOTIGNOREPREFIX")) { # endif // Set library path for the different platforms. char *msg; #if defined(__hpux) || defined(_HIUX_SOURCE) - if (getenv("SHLIB_PATH")) { - const auto msgLen = strlen(getenv("ROOTSYS")) + strlen(getenv("SHLIB_PATH")) + 100; + if (std::getenv("SHLIB_PATH")) { + const auto msgLen = strlen(std::getenv("ROOTSYS")) + strlen(std::getenv("SHLIB_PATH")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "SHLIB_PATH=%s/lib:%s", getenv("ROOTSYS"), getenv("SHLIB_PATH")); + snprintf(msg, msgLen, "SHLIB_PATH=%s/lib:%s", std::getenv("ROOTSYS"), std::getenv("SHLIB_PATH")); } else { - const auto msgLen = strlen(getenv("ROOTSYS")) + 100; + const auto msgLen = strlen(std::getenv("ROOTSYS")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "SHLIB_PATH=%s/lib", getenv("ROOTSYS")); + snprintf(msg, msgLen, "SHLIB_PATH=%s/lib", std::getenv("ROOTSYS")); } #elif defined(_AIX) - if (getenv("LIBPATH")) { - const auto msgLen = strlen(getenv("ROOTSYS")) + strlen(getenv("LIBPATH")) + 100; + if (std::getenv("LIBPATH")) { + const auto msgLen = strlen(std::getenv("ROOTSYS")) + strlen(std::getenv("LIBPATH")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "LIBPATH=%s/lib:%s", getenv("ROOTSYS"), getenv("LIBPATH")); + snprintf(msg, msgLen, "LIBPATH=%s/lib:%s", std::getenv("ROOTSYS"), std::getenv("LIBPATH")); } else { - const auto msgLen = strlen(getenv("ROOTSYS")) + 100; + const auto msgLen = strlen(std::getenv("ROOTSYS")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "LIBPATH=%s/lib:/lib:/usr/lib", getenv("ROOTSYS")); + snprintf(msg, msgLen, "LIBPATH=%s/lib:/lib:/usr/lib", std::getenv("ROOTSYS")); } #elif defined(__APPLE__) - if (getenv("DYLD_LIBRARY_PATH")) { - const auto msgLen = strlen(getenv("ROOTSYS")) + strlen(getenv("DYLD_LIBRARY_PATH")) + 100; + if (std::getenv("DYLD_LIBRARY_PATH")) { + const auto msgLen = strlen(std::getenv("ROOTSYS")) + strlen(std::getenv("DYLD_LIBRARY_PATH")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "DYLD_LIBRARY_PATH=%s/lib:%s", getenv("ROOTSYS"), getenv("DYLD_LIBRARY_PATH")); + snprintf(msg, msgLen, "DYLD_LIBRARY_PATH=%s/lib:%s", std::getenv("ROOTSYS"), std::getenv("DYLD_LIBRARY_PATH")); } else { - const auto msgLen = strlen(getenv("ROOTSYS")) + 100; + const auto msgLen = strlen(std::getenv("ROOTSYS")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "DYLD_LIBRARY_PATH=%s/lib", getenv("ROOTSYS")); + snprintf(msg, msgLen, "DYLD_LIBRARY_PATH=%s/lib", std::getenv("ROOTSYS")); } #else - if (getenv("LD_LIBRARY_PATH")) { - const auto msgLen = strlen(getenv("ROOTSYS")) + strlen(getenv("LD_LIBRARY_PATH")) + 100; + if (std::getenv("LD_LIBRARY_PATH")) { + const auto msgLen = strlen(std::getenv("ROOTSYS")) + strlen(std::getenv("LD_LIBRARY_PATH")) + 100; msg = new char[msgLen]; - snprintf(msg, msgLen, "LD_LIBRARY_PATH=%s/lib:%s", getenv("ROOTSYS"), getenv("LD_LIBRARY_PATH")); + snprintf(msg, msgLen, "LD_LIBRARY_PATH=%s/lib:%s", std::getenv("ROOTSYS"), std::getenv("LD_LIBRARY_PATH")); } else { - const auto msgLen = strlen(getenv("ROOTSYS")) + 100; + const auto msgLen = strlen(std::getenv("ROOTSYS")) + 100; msg = new char[msgLen]; #if defined(__sun) - snprintf(msg, msgLen, "LD_LIBRARY_PATH=%s/lib:/usr/dt/lib", getenv("ROOTSYS")); + snprintf(msg, msgLen, "LD_LIBRARY_PATH=%s/lib:/usr/dt/lib", std::getenv("ROOTSYS")); #else - snprintf(msg, msgLen, "LD_LIBRARY_PATH=%s/lib", getenv("ROOTSYS")); + snprintf(msg, msgLen, "LD_LIBRARY_PATH=%s/lib", std::getenv("ROOTSYS")); #endif } #endif putenv(msg); # ifdef ROOTPREFIX - } else /* if (getenv("ROOTIGNOREPREFIX")) */ { + } else /* if (std::getenv("ROOTIGNOREPREFIX")) */ { std::string ldLibPath = "LD_LIBRARY_PATH=" ROOTLIBDIR; - if (const char *oldLdLibPath = getenv("LD_LIBRARY_PATH")) + if (const char *oldLdLibPath = std::getenv("LD_LIBRARY_PATH")) ldLibPath += std::string(":") + oldLdLibPath; char *msg = strdup(ldLibPath.c_str()); putenv(msg); @@ -236,12 +236,12 @@ int main(int argc, char **argv) char arg0[kMAXPATHLEN]; #ifdef ROOTPREFIX - if (getenv("ROOTIGNOREPREFIX")) { + if (std::getenv("ROOTIGNOREPREFIX")) { #endif // Try to set ROOTSYS depending on pathname of the executable SetRootSys(); - if (!getenv("ROOTSYS")) { + if (!std::getenv("ROOTSYS")) { fprintf(stderr, "%s: ROOTSYS not set. Set it before trying to run %s.\n", argv[0], argv[0]); return 1; @@ -315,9 +315,9 @@ int main(int argc, char **argv) // Build argv vector argvv = new char* [argc+1]; #ifdef ROOTBINDIR - if (getenv("ROOTIGNOREPREFIX")) + if (std::getenv("ROOTIGNOREPREFIX")) #endif - snprintf(arg0, sizeof(arg0), "%s/bin/%s", getenv("ROOTSYS"), ROOTBINARY); + snprintf(arg0, sizeof(arg0), "%s/bin/%s", std::getenv("ROOTSYS"), ROOTBINARY); #ifdef ROOTBINDIR else snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTBINARY); diff --git a/test/MainEvent.cxx b/test/MainEvent.cxx index 4e6e7b4bcd055..df81d67020222 100644 --- a/test/MainEvent.cxx +++ b/test/MainEvent.cxx @@ -91,7 +91,7 @@ // //////////////////////////////////////////////////////////////////////// -#include +#include #include "Riostream.h" #include "TROOT.h" @@ -185,7 +185,7 @@ int MainEvent(int nevent, int comp, int split, int arg4, int arg5, int enable_im Int_t nentries = (Int_t)tree->GetEntries(); nevent = TMath::Min(nevent,nentries); if (read == 1) { //read sequential - ioperf = getenv("ENABLE_TTREEPERFSTATS") ? new TTreePerfStats("Perf Stats", tree) : nullptr; + ioperf = std::getenv("ENABLE_TTREEPERFSTATS") ? new TTreePerfStats("Perf Stats", tree) : nullptr; //by setting the read cache to -1 we set it to the AutoFlush value when writing Int_t cachesize = -1; if (punzip) tree->SetParallelUnzip(); diff --git a/tmva/tmvagui/src/tmvaglob.cxx b/tmva/tmvagui/src/tmvaglob.cxx index dde7a4fb8f53a..1340191ff7010 100644 --- a/tmva/tmvagui/src/tmvaglob.cxx +++ b/tmva/tmvagui/src/tmvaglob.cxx @@ -253,7 +253,7 @@ TImage * TMVA::TMVAGlob::findImage(const char * imageName) { // looks for the image in tutorialpath //TString tutorialPath = "$ROOTSYS/tutorials/machine_learning"; // look for the image in here - TString tutorialPath = getenv ("ROOTSYS"); + TString tutorialPath = std::getenv ("ROOTSYS"); tutorialPath+="/tutorials/machine_learning"; TImage *img = nullptr; TString fullName = TString::Format("%s/%s", tutorialPath.Data(), imageName); diff --git a/tutorials/legacy/rootalias.C b/tutorials/legacy/rootalias.C index a7196ebdfaf43..a830bdfcd30f9 100644 --- a/tutorials/legacy/rootalias.C +++ b/tutorials/legacy/rootalias.C @@ -16,12 +16,12 @@ void edit(char *file) { char s[64], *e; if (!strcmp(gSystem->GetName(), "WinNT")) { - if ((e = getenv("EDITOR"))) + if ((e = std::getenv("EDITOR"))) sprintf(s, "start %s %s", e, file); else sprintf(s, "start notepad %s", file); } else { - if ((e = getenv("EDITOR"))) + if ((e = std::getenv("EDITOR"))) sprintf(s, "%s %s", e, file); else sprintf(s, "xterm -e vi %s &", file);