Skip to content

Commit 61a328b

Browse files
committed
Use std::getenv consistently, and modernize C headernames
1 parent 9cdbeb0 commit 61a328b

File tree

29 files changed

+138
-138
lines changed

29 files changed

+138
-138
lines changed

bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@
3939
#include "TThread.h"
4040

4141
// Standard
42-
#include <assert.h>
42+
#include <cassert>
4343
#include <algorithm> // for std::count, std::remove
4444
#include <climits>
4545
#include <stdexcept>
4646
#include <map>
4747
#include <new>
4848
#include <set>
4949
#include <sstream>
50-
#include <signal.h>
51-
#include <stdlib.h> // for getenv
52-
#include <string.h>
50+
#include <csignal>
51+
#include <cstdlib> // for getenv
52+
#include <cstring>
5353
#include <typeinfo>
5454

5555
// temp
@@ -229,7 +229,7 @@ class TExceptionHandlerImp : public TExceptionHandler {
229229
gInterpreter->ClearFileBusy();
230230
}
231231

232-
if (!getenv("CPPYY_CRASH_QUIET"))
232+
if (!std::getenv("CPPYY_CRASH_QUIET"))
233233
do_trace(sig);
234234

235235
// jump back, if catch point set
@@ -263,7 +263,7 @@ class ApplicationStarter {
263263
g_globalidx[nullptr] = 0;
264264

265265
// disable fast path if requested
266-
if (getenv("CPPYY_DISABLE_FASTPATH")) gEnableFastPath = false;
266+
if (std::getenv("CPPYY_DISABLE_FASTPATH")) gEnableFastPath = false;
267267

268268
// fill the set of STL names
269269
const char* stl_names[] = {"allocator", "auto_ptr", "bad_alloc", "bad_cast",
@@ -296,7 +296,7 @@ class ApplicationStarter {
296296

297297
// set opt level (default to 2 if not given; Cling itself defaults to 0)
298298
int optLevel = 2;
299-
if (getenv("CPPYY_OPT_LEVEL")) optLevel = atoi(getenv("CPPYY_OPT_LEVEL"));
299+
if (std::getenv("CPPYY_OPT_LEVEL")) optLevel = atoi(std::getenv("CPPYY_OPT_LEVEL"));
300300
if (optLevel != 0) {
301301
std::ostringstream s;
302302
s << "#pragma cling optimize " << optLevel;
@@ -324,7 +324,7 @@ class ApplicationStarter {
324324
gInterpreter->Declare("namespace __cppyy_internal { struct Sep; }");
325325

326326
// retrieve all initial (ROOT) C++ names in the global scope to allow filtering later
327-
if (!getenv("CPPYY_NO_ROOT_FILTER")) {
327+
if (!std::getenv("CPPYY_NO_ROOT_FILTER")) {
328328
gROOT->GetListOfGlobals(true); // force initialize
329329
gROOT->GetListOfGlobalFunctions(true); // id.
330330
std::set<std::string> initial;

core/clingutils/src/TClingUtils.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <algorithm>
2020
#include <iostream>
2121
#include <sstream>
22-
#include <stdlib.h>
23-
#include <stdio.h>
22+
#include <cstdlib>
23+
#include <cstdio>
2424
#include <unordered_set>
2525
#include <cctype>
2626

@@ -5188,7 +5188,7 @@ static void replaceEnvVars(const char* varname, std::string& txt)
51885188
endVar = endVarName;
51895189
}
51905190

5191-
const char* val = getenv(txt.substr(beginVarName,
5191+
const char* val = std::getenv(txt.substr(beginVarName,
51925192
endVarName - beginVarName).c_str());
51935193
if (!val) val = "";
51945194

@@ -5210,7 +5210,7 @@ static void replaceEnvVars(const char* varname, std::string& txt)
52105210

52115211
void ROOT::TMetaUtils::SetPathsForRelocatability(std::vector<std::string>& clingArgs )
52125212
{
5213-
const char* envInclPath = getenv("ROOT_INCLUDE_PATH");
5213+
const char* envInclPath = std::getenv("ROOT_INCLUDE_PATH");
52145214

52155215
if (!envInclPath)
52165216
return;

core/dictgen/src/rootcling_impl.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,11 +2805,11 @@ void CreateDictHeader(std::ostream &dictStream, const std::string &main_dictname
28052805
// write one and include in there a few things for backward
28062806
// compatibility.
28072807
<< "\n/*******************************************************************/\n"
2808-
<< "#include <stddef.h>\n"
2809-
<< "#include <stdio.h>\n"
2810-
<< "#include <stdlib.h>\n"
2811-
<< "#include <string.h>\n"
2812-
<< "#include <assert.h>\n"
2808+
<< "#include <cstddef>\n"
2809+
<< "#include <cstdio>\n"
2810+
<< "#include <cstdlib>\n"
2811+
<< "#include <cstring>\n"
2812+
<< "#include <cassert>\n"
28132813
<< "#define G__DICTIONARY\n"
28142814
<< "#include \"ROOT/RConfig.hxx\"\n"
28152815
<< "#include \"TClass.h\"\n"
@@ -3661,7 +3661,7 @@ static void MaybeSuppressWin32CrashDialogs() {
36613661
// Suppress error dialogs to avoid hangs on build nodes.
36623662
// One can use an environment variable (Cling_GuiOnAssert) to enable
36633663
// the error dialogs.
3664-
const char *EnablePopups = getenv("Cling_GuiOnAssert");
3664+
const char *EnablePopups = std::getenv("Cling_GuiOnAssert");
36653665
if (EnablePopups == nullptr || EnablePopups[0] == '0') {
36663666
::_set_error_mode(_OUT_TO_STDERR);
36673667
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
@@ -6018,7 +6018,7 @@ int GenReflexMain(int argc, char **argv)
60186018
//std::string verbosityOption("-v4"); // To be uncommented for the testing phase. It should be -v
60196019
std::string verbosityOption("-v2");
60206020
if (options[SILENT]) verbosityOption = "-v0";
6021-
if (options[VERBOSE] || getenv ("VERBOSE")) verbosityOption = "-v3";
6021+
if (options[VERBOSE] || std::getenv ("VERBOSE")) verbosityOption = "-v3";
60226022
if (options[DEBUG]) verbosityOption = "-v4";
60236023

60246024
genreflex::verbose = verbosityOption == "-v4";

core/foundation/src/FoundationUtils.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include <cassert>
2525
#include <cstdlib>
2626

27-
#include <errno.h>
28-
#include <string.h>
27+
#include <cerrno>
28+
#include <cstring>
2929

3030
#ifdef _WIN32
3131
#include <direct.h>

core/metacling/src/TCling.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3547,7 +3547,7 @@ void TCling::RegisterLoadedSharedLibrary(const char* filename)
35473547
// Check that this is not a system library
35483548
static const int bufsize = 260;
35493549
char posixwindir[bufsize];
3550-
char *windir = getenv("WINDIR");
3550+
char *windir = std::getenv("WINDIR");
35513551
if (windir)
35523552
cygwin_conv_path(CCP_WIN_A_TO_POSIX, windir, posixwindir, bufsize);
35533553
else

core/rootcling_stage1/src/rootcling_stage1.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym;
2424
ROOT::Internal::RootCling::TROOTSYSSetter gROOTSYSSetter;
2525

2626
static const char *GetIncludeDir() {
27-
auto renv = getenv("ROOTSYS");
27+
auto renv = std::getenv("ROOTSYS");
2828
if (!renv)
2929
return nullptr;
3030
static std::string incdir = std::string(renv) + "/include";
3131
return incdir.c_str();
3232
}
3333

3434
static const char *GetEtcDir() {
35-
auto renv = getenv("ROOTSYS");
35+
auto renv = std::getenv("ROOTSYS");
3636
if (!renv)
3737
return nullptr;
3838
static std::string etcdir = std::string(renv) + "/etc";

core/textinput/src/textinput/TerminalDisplayUnix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include "textinput/TerminalDisplayUnix.h"
1919

2020
#include <fcntl.h>
21-
#include <stdio.h>
21+
#include <cstdio>
2222
// putenv not in cstdlib on Solaris
23-
#include <stdlib.h>
23+
#include <cstdlib>
2424
#include <unistd.h>
2525
#include <sys/ioctl.h>
2626
#include <termios.h>
@@ -118,7 +118,7 @@ namespace textinput {
118118
TerminalConfigUnix::Get().TIOS()->c_lflag &= ~(ECHO);
119119
TerminalConfigUnix::Get().TIOS()->c_lflag |= ECHOCTL|ECHOKE|ECHOE;
120120
#endif
121-
const char* TERM = getenv("TERM");
121+
const char* TERM = std::getenv("TERM");
122122
if (TERM && strstr(TERM, "256")) {
123123
fNColors = 256;
124124
}
@@ -153,7 +153,7 @@ namespace textinput {
153153
}
154154
#else
155155
// try $COLUMNS
156-
const char* COLUMNS = getenv("COLUMNS");
156+
const char* COLUMNS = std::getenv("COLUMNS");
157157
if (COLUMNS) {
158158
long width = atol(COLUMNS);
159159
if (width > 4 && width < 1024*16) {

core/unix/src/TUnixSystem.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
//#define G__OLDEXPAND
4747

4848
#include <unistd.h>
49-
#include <stdlib.h>
49+
#include <cstdlib>
5050
#include <sys/types.h>
5151
#if defined(R__SUN) || defined(R__AIX) || \
5252
defined(R__LINUX) || defined(R__SOLARIS) || \
@@ -704,7 +704,7 @@ void TUnixSystem::SetDisplay()
704704
}
705705
}
706706
#ifndef R__HAS_COCOA
707-
if (!gROOT->IsBatch() && !getenv("DISPLAY")) {
707+
if (!gROOT->IsBatch() && !std::getenv("DISPLAY")) {
708708
Error("SetDisplay", "Can't figure out DISPLAY, set it manually\n"
709709
"In case you run a remote ssh session, restart your ssh session with:\n"
710710
"=========> ssh -Y");
@@ -2139,7 +2139,7 @@ void TUnixSystem::Setenv(const char *name, const char *value)
21392139

21402140
const char *TUnixSystem::Getenv(const char *name)
21412141
{
2142-
return ::getenv(name);
2142+
return std::getenv(name);
21432143
}
21442144

21452145
////////////////////////////////////////////////////////////////////////////////

core/winnt/src/TWinNTSystem.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
#include <ctype.h>
5151
#include <float.h>
5252
#include <sys/stat.h>
53-
#include <signal.h>
54-
#include <stdio.h>
55-
#include <errno.h>
53+
#include <csignal>
54+
#include <cstdio>
55+
#include <cerrno>
5656
#include <lm.h>
5757
#include <dbghelp.h>
5858
#include <Tlhelp32.h>
@@ -61,7 +61,7 @@
6161
#include <list>
6262
#include <shlobj.h>
6363
#include <conio.h>
64-
#include <time.h>
64+
#include <ctime>
6565
#include <bcrypt.h>
6666
#include <chrono>
6767
#include <thread>
@@ -827,7 +827,7 @@ namespace {
827827
// determine the fileopen.C file path:
828828
TString fileopen = "fileopen.C";
829829
TString rootmacrodir = "macros";
830-
sys->PrependPathName(getenv("ROOTSYS"), rootmacrodir);
830+
sys->PrependPathName(std::getenv("ROOTSYS"), rootmacrodir);
831831
sys->PrependPathName(rootmacrodir.Data(), fileopen);
832832

833833
if (regROOTwrite) {
@@ -1283,7 +1283,7 @@ Int_t TWinNTSystem::GetCryptoRandom(void *buf, Int_t len)
12831283
const char *TWinNTSystem::HostName()
12841284
{
12851285
if (fHostname == "")
1286-
fHostname = ::getenv("COMPUTERNAME");
1286+
fHostname = std::getenv("COMPUTERNAME");
12871287
if (fHostname == "") {
12881288
// This requires a DNS query - but we need it for fallback
12891289
char hn[64];
@@ -2225,23 +2225,23 @@ std::string TWinNTSystem::GetHomeDirectory(const char *userName) const
22252225
void TWinNTSystem::FillWithHomeDirectory(const char *userName, char *mydir) const
22262226
{
22272227
const char *h = nullptr;
2228-
if (!(h = ::getenv("home"))) h = ::getenv("HOME");
2228+
if (!(h = std::getenv("home"))) h = std::getenv("HOME");
22292229

22302230
if (h) {
22312231
strlcpy(mydir, h,kMAXPATHLEN);
22322232
} else {
22332233
// for Windows NT HOME might be defined as either $(HOMESHARE)/$(HOMEPATH)
22342234
// or $(HOMEDRIVE)/$(HOMEPATH)
2235-
h = ::getenv("HOMESHARE");
2236-
if (!h) h = ::getenv("HOMEDRIVE");
2235+
h = std::getenv("HOMESHARE");
2236+
if (!h) h = std::getenv("HOMEDRIVE");
22372237
if (h) {
22382238
strlcpy(mydir, h,kMAXPATHLEN);
2239-
h = ::getenv("HOMEPATH");
2239+
h = std::getenv("HOMEPATH");
22402240
if(h) strlcat(mydir, h,kMAXPATHLEN);
22412241
}
22422242
// on Windows Vista HOME is usually defined as $(USERPROFILE)
22432243
if (!h) {
2244-
h = ::getenv("USERPROFILE");
2244+
h = std::getenv("USERPROFILE");
22452245
if (h) strlcpy(mydir, h,kMAXPATHLEN);
22462246
}
22472247
}
@@ -3861,7 +3861,7 @@ void TWinNTSystem::Setenv(const char *name, const char *value)
38613861

38623862
const char *TWinNTSystem::Getenv(const char *name)
38633863
{
3864-
const char *env = ::getenv(name);
3864+
const char *env = std::getenv(name);
38653865
if (!env) {
38663866
if (::_stricmp(name,"home") == 0 ) {
38673867
env = HomeDirectory();

documentation/doxygen/filter.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
#include <cstring>
8686
#include <iostream>
8787
#include <fstream>
88-
#include <stdlib.h>
89-
#include <stdarg.h>
88+
#include <cstdlib>
89+
#include <cstdarg>
9090
#include <memory>
9191

9292
using std::string;
@@ -161,15 +161,15 @@ int main(int argc, char *argv[])
161161
gCwd = gFileName.substr(0,last);
162162

163163
// Retrieve the output directory
164-
gOutDir = getenv("DOXYGEN_OUTPUT_DIRECTORY");
164+
gOutDir = std::getenv("DOXYGEN_OUTPUT_DIRECTORY");
165165
ReplaceAll(gOutDir,"\"","");
166166

167167
// Retrieve the source directory
168-
gSourceDir = getenv("DOXYGEN_SOURCE_DIRECTORY");
168+
gSourceDir = std::getenv("DOXYGEN_SOURCE_DIRECTORY");
169169
ReplaceAll(gSourceDir,"\"","");
170170

171171
// Retrieve the python executable
172-
gPythonExec = getenv("Python3_EXECUTABLE");
172+
gPythonExec = std::getenv("Python3_EXECUTABLE");
173173
ReplaceAll(gPythonExec,"\"","");
174174

175175
// Open the input file name.

0 commit comments

Comments
 (0)