summaryrefslogtreecommitdiff
path: root/src/env_vars.cc
blob: f89fe7ff652995a84bf89a8f50759f0eb8deeea4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "env_vars.hh"

#include "string.hh"

extern char **environ;

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;
        env_vars[String{name, value}] = (*value == '=') ? value+1 : value;
    }
    return env_vars;
}

}