Commit cb9cfb27 authored by Martin Marinov's avatar Martin Marinov
Browse files

Fix a bug in System::Environment::variable() on non Windows platforms

parent bfb151f4
......@@ -13,7 +13,7 @@
namespace System {
namespace Environment {
bool variable(const char* _vrbl_name, std::string& _vrbl)
bool variable(const char* const _vrbl_name, std::string& _vrbl)
{
#ifdef WIN32 // The Windows implementation uses the secure getenv_s()
size_t char_nmbr;
......@@ -24,7 +24,7 @@ bool variable(const char* _vrbl_name, std::string& _vrbl)
getenv_s(&char_nmbr, &_vrbl[0], char_nmbr, _vrbl_name);
_vrbl.resize(char_nmbr - 1); // remove the trailing \0 char
#else
const char* vrbl_env = std::getenv("REFORM_DEB_CONFIG");
const char* const vrbl_env = std::getenv(_vrbl_name);
if (vrbl_env == NULL)
return false;
_vrbl = vrbl_env;
......
......@@ -16,10 +16,10 @@ undefined, return an empty string.
Returns false if the variable is undefined, the input string is unchanged.
*/
bool variable(const char* _vrbl_name, std::string& _str);
bool variable(const char* const _vrbl_name, std::string& _str);
//! Same as above, but returns an empty string if the variable is undefined.
inline std::string variable(const char* _vrbl_name)
inline std::string variable(const char* const _vrbl_name)
{
std::string vrbl;
variable(_vrbl_name, vrbl);
......@@ -27,7 +27,8 @@ inline std::string variable(const char* _vrbl_name)
}
//! Same as above, but returns a default string if the variable is undefined.
inline std::string variable(const char* _vrbl_name, const char* _vrbl_dflt)
inline std::string variable(const char* const _vrbl_name,
const char* const _vrbl_dflt)
{
std::string vrbl(_vrbl_dflt);
variable(_vrbl_name, vrbl);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment