os/env: use libuv v1.12 getenv/setenv API

- Minimum required libuv is now v1.12
- Because `uv_os_getenv` requires allocating, we must manage a map
  (`envmap` in `env.c`) to maintain the old behavior of `os_getenv` .
- free() map-items after removal. khash.h does not make copies of
  anything, so even its keys must be memory-managed by the caller.

closes #8398
closes #9267
This commit is contained in:
Justin M. Keyes
2019-02-24 20:09:14 +01:00
parent 1d8e768360
commit 89515304e4
14 changed files with 226 additions and 95 deletions

View File

@@ -184,6 +184,7 @@ bool event_teardown(void)
void early_init(void)
{
log_init();
env_init();
fs_init();
handle_init();
eval_init(); // init global variables
@@ -1769,7 +1770,7 @@ static bool do_user_initialization(void)
FUNC_ATTR_WARN_UNUSED_RESULT
{
bool do_exrc = p_exrc;
if (process_env("VIMINIT") == OK) {
if (execute_env("VIMINIT") == OK) {
do_exrc = p_exrc;
return do_exrc;
}
@@ -1814,7 +1815,7 @@ static bool do_user_initialization(void)
} while (iter != NULL);
xfree(config_dirs);
}
if (process_env("EXINIT") == OK) {
if (execute_env("EXINIT") == OK) {
do_exrc = p_exrc;
return do_exrc;
}
@@ -1878,7 +1879,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
///
/// @return FAIL if the environment variable was not executed,
/// OK otherwise.
static int process_env(char *env)
static int execute_env(char *env)
FUNC_ATTR_NONNULL_ALL
{
const char *initstr = os_getenv(env);