Created
October 12, 2016 16:37
-
-
Save mattn/c37ee015504861284d25a87c6af4c177 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/evalfunc.c b/src/evalfunc.c | |
index 84eaa8c..a3639ff 100644 | |
--- a/src/evalfunc.c | |
+++ b/src/evalfunc.c | |
@@ -117,6 +117,7 @@ static void f_delete(typval_T *argvars, typval_T *rettv); | |
static void f_did_filetype(typval_T *argvars, typval_T *rettv); | |
static void f_diff_filler(typval_T *argvars, typval_T *rettv); | |
static void f_diff_hlID(typval_T *argvars, typval_T *rettv); | |
+static void f_environ(typval_T *argvars, typval_T *rettv); | |
static void f_empty(typval_T *argvars, typval_T *rettv); | |
static void f_escape(typval_T *argvars, typval_T *rettv); | |
static void f_eval(typval_T *argvars, typval_T *rettv); | |
@@ -541,6 +542,7 @@ static struct fst | |
{"diff_filler", 1, 1, f_diff_filler}, | |
{"diff_hlID", 2, 2, f_diff_hlID}, | |
{"empty", 1, 1, f_empty}, | |
+ {"environ", 0, 0, f_environ}, | |
{"escape", 2, 2, f_escape}, | |
{"eval", 1, 1, f_eval}, | |
{"eventhandler", 0, 0, f_eventhandler}, | |
@@ -2594,6 +2596,32 @@ f_diff_hlID(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | |
} | |
/* | |
+ * "environ()" function | |
+ */ | |
+ static void | |
+f_environ(typval_T *argvars, typval_T *rettv) | |
+{ | |
+ int i; | |
+ if (rettv_dict_alloc(rettv) != FAIL) | |
+ { | |
+ for (i = 0; environ[i]; i++) | |
+ { | |
+ char_u *env = (char_u *)environ[i]; | |
+ char_u *p = vim_strchr(env, '='); | |
+ if (p != NULL) | |
+ { | |
+ char_u *key = vim_strnsave(env, p - env); | |
+ if (key != NULL) | |
+ { | |
+ dict_add_nr_str(rettv->vval.v_dict, (char*)key, 0L, p+1); | |
+ vim_free(key); | |
+ } | |
+ } | |
+ } | |
+ } | |
+} | |
+ | |
+/* | |
* "empty({expr})" function | |
*/ | |
static void |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment