2014-04-07 22:25:44 +02:00
|
|
|
#include "env_vars.hh"
|
|
|
|
|
2014-11-12 22:27:07 +01:00
|
|
|
#include "string.hh"
|
|
|
|
|
2014-04-10 21:23:39 +02:00
|
|
|
extern char **environ;
|
|
|
|
|
2014-04-07 22:25:44 +02:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
EnvVarMap get_env_vars()
|
|
|
|
{
|
|
|
|
EnvVarMap env_vars;
|
|
|
|
for (char** it = environ; *it; ++it)
|
|
|
|
{
|
|
|
|
const char* name = *it;
|
|
|
|
const char* value = name;
|
|
|
|
while (*value != 0 and *value != '=')
|
|
|
|
++value;
|
2015-03-11 20:41:44 +01:00
|
|
|
env_vars[{name, value}] = (*value == '=') ? value+1 : String{};
|
2014-04-07 22:25:44 +02:00
|
|
|
}
|
|
|
|
return env_vars;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|