From 9a5e87ac83d2a0f88c183e13695910e950fd457b Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Sun, 12 Apr 2015 20:36:34 +0000 Subject: Remove char_u: after_pathstep() See: #459 --- src/nvim/eval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d6a8351330..8444432350 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12417,7 +12417,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) is_relative_to_current = TRUE; len = STRLEN(p); - if (len > 0 && after_pathsep(p, p + len)) { + if (len > 0 && after_pathsep((char *)p, (char *)p + len)) { has_trailing_pathsep = TRUE; p[len - 1] = NUL; /* the trailing slash breaks readlink() */ } @@ -12531,7 +12531,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) * if the argument had none. But keep "/" or "//". */ if (!has_trailing_pathsep) { q = p + STRLEN(p); - if (after_pathsep(p, q)) + if (after_pathsep((char *)p, (char *)q)) *path_tail_with_sep(p) = NUL; } @@ -19921,7 +19921,7 @@ repeat: valid |= VALID_HEAD; *usedlen += 2; s = get_past_head(*fnamep); - while (tail > s && after_pathsep(s, tail)) + while (tail > s && after_pathsep((char *)s, (char *)tail)) mb_ptr_back(*fnamep, tail); *fnamelen = (int)(tail - *fnamep); if (*fnamelen == 0) { @@ -19930,7 +19930,7 @@ repeat: *bufp = *fnamep = tail = vim_strsave((char_u *)"."); *fnamelen = 1; } else { - while (tail > s && !after_pathsep(s, tail)) + while (tail > s && !after_pathsep((char *)s, (char *)tail)) mb_ptr_back(*fnamep, tail); } } -- cgit From 4848158cc12443c27e298b01543bf620172508c3 Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Sun, 12 Apr 2015 21:17:16 +0000 Subject: Remove char_u: vim_getenv() --- src/nvim/eval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8444432350..58d646cd3b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1752,10 +1752,10 @@ ex_let_one ( p = get_tv_string_chk(tv); if (p != NULL && op != NULL && *op == '.') { bool mustfree = false; - char_u *s = vim_getenv(name, &mustfree); + char *s = vim_getenv((char *)name, &mustfree); if (s != NULL) { - p = tofree = concat_str(s, p); + p = tofree = concat_str((char_u *)s, p); if (mustfree) xfree(s); } @@ -6372,7 +6372,7 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) cc = name[len]; name[len] = NUL; // First try vim_getenv(), fast for normal environment vars. - string = vim_getenv(name, &mustfree); + string = (char_u *)vim_getenv((char *)name, &mustfree); if (string != NULL && *string != NUL) { if (!mustfree) { string = vim_strsave(string); -- cgit From a4e51f72ab5dac1149b415c6fc0bf1c87a11acda Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Sun, 12 Apr 2015 21:26:06 +0000 Subject: Remove char_u: vim_setenv() --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 58d646cd3b..405b2b1e98 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1761,7 +1761,7 @@ ex_let_one ( } } if (p != NULL) { - vim_setenv(name, p); + vim_setenv((char *)name, (char *)p); if (STRICMP(name, "HOME") == 0) init_homedir(); else if (didset_vim && STRICMP(name, "VIM") == 0) -- cgit From a7e17de048b0791329cf1ad4d4c291290a99040a Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Sun, 12 Apr 2015 22:31:00 +0000 Subject: Refactor get_env() to respect const qualifier Without the casts*, the compiler rightly warns about the os_getenv losing the qualifier. This refactor adds a variable to manage this properly, and renames the original variables to increase clarity. --- src/nvim/eval.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 405b2b1e98..6cabdcc45e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1751,13 +1751,11 @@ ex_let_one ( name[len] = NUL; p = get_tv_string_chk(tv); if (p != NULL && op != NULL && *op == '.') { - bool mustfree = false; - char *s = vim_getenv((char *)name, &mustfree); + char *s = vim_getenv((char *)name); if (s != NULL) { p = tofree = concat_str((char_u *)s, p); - if (mustfree) - xfree(s); + xfree(s); } } if (p != NULL) { @@ -6357,7 +6355,6 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) { char_u *name; char_u *string = NULL; - bool mustfree = false; int len; int cc; @@ -6372,15 +6369,9 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) cc = name[len]; name[len] = NUL; // First try vim_getenv(), fast for normal environment vars. - string = (char_u *)vim_getenv((char *)name, &mustfree); - if (string != NULL && *string != NUL) { - if (!mustfree) { - string = vim_strsave(string); - } - } else { - if (mustfree) { - xfree(string); - } + string = (char_u *)vim_getenv((char *)name); + if (string == NULL || *string == NUL) { + xfree(string); // Next try expanding things like $VIM and ${HOME}. string = expand_env_save(name - 1); -- cgit