aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Bainter <mbainter+github@gmail.com>2015-04-12 21:17:16 +0000
committerMark Bainter <mbainter+github@gmail.com>2015-04-17 14:46:58 +0000
commit4848158cc12443c27e298b01543bf620172508c3 (patch)
tree8c5fbac25fd8c2300b47b09a50420a6d1e3a0634
parent9a5e87ac83d2a0f88c183e13695910e950fd457b (diff)
downloadrneovim-4848158cc12443c27e298b01543bf620172508c3.tar.gz
rneovim-4848158cc12443c27e298b01543bf620172508c3.tar.bz2
rneovim-4848158cc12443c27e298b01543bf620172508c3.zip
Remove char_u: vim_getenv()
-rw-r--r--src/nvim/eval.c6
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/option.c6
-rw-r--r--src/nvim/os/env.c46
6 files changed, 31 insertions, 33 deletions
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);
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index c57861282d..c40808b1f1 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -5117,7 +5117,7 @@ void fix_help_buffer(void)
while (*p != NUL) {
copy_option_part(&p, NameBuff, MAXPATHL, ",");
mustfree = FALSE;
- rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
+ rt = (char_u *)vim_getenv("VIMRUNTIME", &mustfree);
if (path_full_compare(rt, NameBuff, FALSE) != kEqualFiles) {
int fcount;
char_u **fnames;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 7dac4a9565..0e54c0e983 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3849,7 +3849,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
|| (pat[1] == '.' && vim_ispathsep(pat[2])))))
path = (char_u *)".";
else {
- path = vim_getenv((char_u *)"PATH", &mustfree);
+ path = (char_u *)vim_getenv("PATH", &mustfree);
if (path == NULL)
path = (char_u *)"";
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 4753dc31c3..ffa114ce19 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -834,7 +834,7 @@ static void init_locale(void)
/* expand_env() doesn't work yet, because chartab[] is not initialized
* yet, call vim_getenv() directly */
- p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
+ p = (char_u *)vim_getenv("VIMRUNTIME", &mustfree);
if (p != NULL && *p != NUL) {
vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
bindtextdomain(VIMPACKAGE, (char *)NameBuff);
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 23a23a0814..f6c613ef6a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1814,7 +1814,7 @@ void set_init_1(void)
p = (char_u *)"/tmp";
else
# endif
- p = vim_getenv((char_u *)names[n], &mustfree);
+ p = (char_u *)vim_getenv(names[n], &mustfree);
if (p != NULL && *p != NUL) {
/* First time count the NUL, otherwise count the ','. */
len = (int)STRLEN(p) + 3;
@@ -1864,7 +1864,7 @@ void set_init_1(void)
bool mustfree = false;
/* Initialize the 'cdpath' option's default value. */
- cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
+ cdpath = (char_u *)vim_getenv("CDPATH", &mustfree);
if (cdpath != NULL) {
buf = xmalloc(2 * STRLEN(cdpath) + 2);
{
@@ -7432,7 +7432,7 @@ void vimrc_found(char_u *fname, char_u *envname)
char_u *p;
if (fname != NULL) {
- p = vim_getenv(envname, &dofree);
+ p = (char_u *)vim_getenv((char *)envname, &dofree);
if (p == NULL) {
/* Set $MYVIMRC to the first vimrc file found. */
p = FullName_save(fname, FALSE);
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 0dd5d62ce9..0378b393b1 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -262,7 +262,7 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
}
#endif
*var = NUL;
- var = vim_getenv(dst, &mustfree);
+ var = (char_u *)vim_getenv((char *)dst, &mustfree);
#if defined(UNIX)
}
#endif
@@ -423,14 +423,14 @@ static char *remove_tail(char *p, char *pend, char *name)
/// @param[out] mustfree Ouput parameter for the caller to determine if they are
/// responsible for releasing memory. Must be initialized to false
/// by the caller.
-char_u *vim_getenv(char_u *name, bool *mustfree)
+char *vim_getenv(const char *name, bool *mustfree)
{
- char_u *p;
- char_u *pend;
+ char *p;
+ char *pend;
int vimruntime;
- p = (char_u *)os_getenv((char *)name);
+ p = (char *)os_getenv(name);
if (p != NULL && *p == NUL) /* empty is the same as not set */
p = NULL;
@@ -451,15 +451,15 @@ char_u *vim_getenv(char_u *name, bool *mustfree)
&& *default_vimruntime_dir == NUL
#endif
) {
- p = (char_u *)os_getenv("VIM");
+ p = (char *)os_getenv("VIM");
if (p != NULL && *p == NUL) /* empty is the same as not set */
p = NULL;
if (p != NULL) {
- p = (char_u *)vim_version_dir((char *)p);
+ p = vim_version_dir(p);
if (p != NULL)
*mustfree = true;
else
- p = (char_u *)os_getenv("VIM");
+ p = (char *)os_getenv("VIM");
}
}
@@ -470,32 +470,30 @@ char_u *vim_getenv(char_u *name, bool *mustfree)
*/
if (p == NULL) {
if (p_hf != NULL && vim_strchr(p_hf, '$') == NULL)
- p = p_hf;
+ p = (char *)p_hf;
if (p != NULL) {
/* remove the file name */
- pend = path_tail(p);
+ pend = (char *)path_tail((char_u *)p);
/* remove "doc/" from 'helpfile', if present */
- if (p == p_hf)
- pend = (char_u *)remove_tail((char *)p, (char *)pend, "doc");
+ if (p == (char *)p_hf)
+ pend = remove_tail(p, pend, "doc");
/* for $VIM, remove "runtime/" or "vim54/", if present */
if (!vimruntime) {
- pend = (char_u *)remove_tail((char *)p, (char *)pend,
- RUNTIME_DIRNAME);
- pend = (char_u *)remove_tail((char *)p, (char *)pend,
- VIM_VERSION_NODOT);
+ pend = remove_tail(p, pend, RUNTIME_DIRNAME);
+ pend = remove_tail(p, pend, VIM_VERSION_NODOT);
}
/* remove trailing path separator */
- if (pend > p && after_pathsep((char *)p, (char *)pend))
+ if (pend > p && after_pathsep(p, pend))
--pend;
// check that the result is a directory name
assert(pend >= p);
- p = vim_strnsave(p, (size_t)(pend - p));
+ p = xstrndup(p, (size_t)(pend - p));
- if (!os_isdir(p)) {
+ if (!os_isdir((char_u *)p)) {
xfree(p);
p = NULL;
} else {
@@ -510,14 +508,14 @@ char_u *vim_getenv(char_u *name, bool *mustfree)
if (p == NULL) {
/* Only use default_vimruntime_dir when it is not empty */
if (vimruntime && *default_vimruntime_dir != NUL) {
- p = (char_u *)default_vimruntime_dir;
+ p = default_vimruntime_dir;
*mustfree = false;
} else if (*default_vim_dir != NUL) {
if (vimruntime
- && (p = (char_u *)vim_version_dir(default_vim_dir)) != NULL) {
+ && (p = vim_version_dir(default_vim_dir)) != NULL) {
*mustfree = true;
} else {
- p = (char_u *)default_vim_dir;
+ p = default_vim_dir;
*mustfree = false;
}
}
@@ -530,10 +528,10 @@ char_u *vim_getenv(char_u *name, bool *mustfree)
*/
if (p != NULL) {
if (vimruntime) {
- vim_setenv((char_u *)"VIMRUNTIME", p);
+ vim_setenv((char_u *)"VIMRUNTIME", (char_u *)p);
didset_vimruntime = true;
} else {
- vim_setenv((char_u *)"VIM", p);
+ vim_setenv((char_u *)"VIM", (char_u *)p);
didset_vim = true;
}
}