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;
|
2019-03-21 10:43:24 +01:00
|
|
|
env_vars.insert({String{String::NoCopy{}, {name, value}},
|
|
|
|
(*value == '=') ? String{String::NoCopy{}, value+1} : String{}});
|
2014-04-07 22:25:44 +02:00
|
|
|
}
|
|
|
|
return env_vars;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|