forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept only true values for CLING_PROFILE and CLING_DEBUG
This implementation of ConvertEnvValueToBool uses const char* as input intentionally in order to be able to accept nullptr for when environment variables are not set, but also because using something like std::string would require bringing in several extra headers.
- Loading branch information
Showing
3 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//--------------------------------------------------------------------*- C++ -*- | ||
// CLING - the C++ LLVM-based InterpreterG :) | ||
// author: Guilherme Amadio <amadio@cern.ch> | ||
// | ||
// This file is dual-licensed: you can choose to license it under the University | ||
// of Illinois Open Source License or the GNU Lesser General Public License. See | ||
// LICENSE.TXT for details. | ||
//------------------------------------------------------------------------------ | ||
|
||
#include <cstdlib> | ||
#include <cstring> | ||
|
||
#ifndef CLING_UTILS_UTILS_H | ||
#define CLING_UTILS_UTILS_H | ||
|
||
#if defined(_MSC_VER) && !defined(strcasecmp) | ||
#define strcasecmp _stricmp | ||
#endif | ||
|
||
namespace cling { | ||
namespace utils { | ||
/** Convert @p value to boolean */ | ||
static inline bool ConvertEnvValueToBool(const char* value) { | ||
const char* true_strs[] = {"1", "true", "on", "yes"}; | ||
|
||
if (!value) | ||
return false; | ||
|
||
for (auto str : true_strs) | ||
if (strcasecmp(value, str) == 0) | ||
return true; | ||
|
||
return false; | ||
} | ||
} // namespace utils | ||
} // namespace cling | ||
|
||
#endif // CLING_UTILS_UTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters