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/option.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/option.c') 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); -- 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/option.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index f6c613ef6a..6da0058c1a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2288,7 +2288,7 @@ void set_init_3(void) * When 'helplang' is still at its default value, set it to "lang". * Only the first two characters of "lang" are used. */ -void set_helplang_default(char_u *lang) +void set_helplang_default(const char *lang) { int idx; @@ -3644,11 +3644,11 @@ did_set_string_option ( else if (varp == &p_hf) { /* May compute new values for $VIM and $VIMRUNTIME */ if (didset_vim) { - vim_setenv((char_u *)"VIM", (char_u *)""); + vim_setenv("VIM", ""); didset_vim = FALSE; } if (didset_vimruntime) { - vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); + vim_setenv("VIMRUNTIME", ""); didset_vimruntime = FALSE; } } @@ -7437,7 +7437,7 @@ void vimrc_found(char_u *fname, char_u *envname) /* Set $MYVIMRC to the first vimrc file found. */ p = FullName_save(fname, FALSE); if (p != NULL) { - vim_setenv(envname, p); + vim_setenv((char *)envname, (char *)p); xfree(p); } } else if (dofree) -- cgit From 78c77e8555f1e208bfce21ec15c943adaf904b8c Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Mon, 13 Apr 2015 02:17:20 +0000 Subject: Remove char_u: set_helplang_default() --- src/nvim/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 6da0058c1a..2306bc89ab 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2039,7 +2039,7 @@ void set_init_1(void) } /* Set the default for 'helplang'. */ - set_helplang_default(get_mess_lang()); + set_helplang_default((char *)get_mess_lang()); } /* @@ -2298,7 +2298,7 @@ void set_helplang_default(const char *lang) if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) { if (options[idx].flags & P_ALLOCED) free_string_option(p_hlg); - p_hlg = vim_strsave(lang); + p_hlg = (char_u *)xstrdup(lang); /* zh_CN becomes "cn", zh_TW becomes "tw". */ if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) { p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]); -- cgit From 08c08ecdf3c4837889d837dbe4a3ace0bd301ead Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Mon, 13 Apr 2015 02:22:02 +0000 Subject: Remove char_u: get_mess_lang() --- src/nvim/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 2306bc89ab..8b12a6f2a1 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2039,7 +2039,7 @@ void set_init_1(void) } /* Set the default for 'helplang'. */ - set_helplang_default((char *)get_mess_lang()); + set_helplang_default(get_mess_lang()); } /* -- 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/option.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 8b12a6f2a1..057937f60e 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1804,19 +1804,20 @@ void set_init_1(void) # endif int len; garray_T ga; - bool mustfree; ga_init(&ga, 1, 100); for (size_t n = 0; n < ARRAY_SIZE(names); ++n) { - mustfree = FALSE; + bool mustfree = true; # ifdef UNIX - if (*names[n] == NUL) + if (*names[n] == NUL) { p = (char_u *)"/tmp"; + mustfree = false; + } else # endif - p = (char_u *)vim_getenv(names[n], &mustfree); + p = (char_u *)vim_getenv(names[n]); if (p != NULL && *p != NUL) { - /* First time count the NUL, otherwise count the ','. */ + // First time count the NUL, otherwise count the ','. len = (int)STRLEN(p) + 3; ga_grow(&ga, len); if (!GA_EMPTY(&ga)) @@ -1826,8 +1827,9 @@ void set_init_1(void) STRCAT(ga.ga_data, "*"); ga.ga_len += len; } - if (mustfree) + if(mustfree) { xfree(p); + } } if (ga.ga_data != NULL) { set_string_default("bsk", ga.ga_data); @@ -1861,10 +1863,9 @@ void set_init_1(void) char_u *buf; int i; int j; - bool mustfree = false; /* Initialize the 'cdpath' option's default value. */ - cdpath = (char_u *)vim_getenv("CDPATH", &mustfree); + cdpath = (char_u *)vim_getenv("CDPATH"); if (cdpath != NULL) { buf = xmalloc(2 * STRLEN(cdpath) + 2); { @@ -1887,8 +1888,7 @@ void set_init_1(void) } else xfree(buf); /* cannot happen */ } - if (mustfree) - xfree(cdpath); + xfree(cdpath); } } @@ -7428,11 +7428,10 @@ static void paste_option_changed(void) /// When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. void vimrc_found(char_u *fname, char_u *envname) { - bool dofree = false; char_u *p; if (fname != NULL) { - p = (char_u *)vim_getenv((char *)envname, &dofree); + p = (char_u *)vim_getenv((char *)envname); if (p == NULL) { /* Set $MYVIMRC to the first vimrc file found. */ p = FullName_save(fname, FALSE); @@ -7440,8 +7439,9 @@ void vimrc_found(char_u *fname, char_u *envname) vim_setenv((char *)envname, (char *)p); xfree(p); } - } else if (dofree) + } else { xfree(p); + } } } -- cgit