aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/config.h.in1
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/ex_cmds2.c16
-rw-r--r--src/nvim/main.c26
-rw-r--r--src/nvim/option.c6
-rw-r--r--src/nvim/os/env.c20
6 files changed, 25 insertions, 46 deletions
diff --git a/config/config.h.in b/config/config.h.in
index 15881c4430..ae04c38272 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -13,7 +13,6 @@
#endif
#define PROJECT_NAME "@PROJECT_NAME@"
-#define LOCALE_INSTALL_DIR "@CMAKE_INSTALL_FULL_LOCALEDIR@"
#cmakedefine HAVE__NSGETENVIRON
#cmakedefine HAVE_FD_CLOEXEC
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 988435fd19..942f8d5e09 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1890,7 +1890,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
}
}
if (p != NULL) {
- vim_setenv(name, p);
+ os_setenv(name, p, 1);
if (STRICMP(name, "HOME") == 0) {
init_homedir();
} else if (didset_vim && STRICMP(name, "VIM") == 0) {
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 3202f82a29..5ad285c387 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -2821,10 +2821,10 @@ void ex_packadd(exarg_T *eap)
/// ":options"
void ex_options(exarg_T *eap)
{
- vim_setenv("OPTWIN_CMD", cmdmod.tab ? "tab" : "");
- vim_setenv("OPTWIN_CMD",
- cmdmod.tab ? "tab" :
- (cmdmod.split & WSP_VERT) ? "vert" : "");
+ os_setenv("OPTWIN_CMD", cmdmod.tab ? "tab" : "", 1);
+ os_setenv("OPTWIN_CMD",
+ cmdmod.tab ? "tab" :
+ (cmdmod.split & WSP_VERT) ? "vert" : "", 1);
cmd_source((char_u *)SYS_OPTWIN_FILE, NULL);
}
@@ -3916,19 +3916,19 @@ void ex_language(exarg_T *eap)
_nl_msg_cat_cntr++;
#endif
// Reset $LC_ALL, otherwise it would overrule everything.
- vim_setenv("LC_ALL", "");
+ os_setenv("LC_ALL", "", 1);
if (what != LC_TIME) {
// Tell gettext() what to translate to. It apparently doesn't
// use the currently effective locale.
if (what == LC_ALL) {
- vim_setenv("LANG", (char *)name);
+ os_setenv("LANG", (char *)name, 1);
// Clear $LANGUAGE because GNU gettext uses it.
- vim_setenv("LANGUAGE", "");
+ os_setenv("LANGUAGE", "", 1);
}
if (what != LC_CTYPE) {
- vim_setenv("LC_MESSAGES", (char *)name);
+ os_setenv("LC_MESSAGES", (char *)name, 1);
set_helplang_default((char *)name);
}
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 8ff873e127..e0d3c1e9be 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -712,22 +712,18 @@ static void init_locale(void)
setlocale(LC_NUMERIC, "C");
# endif
-# ifdef LOCALE_INSTALL_DIR // gnu/linux standard: $prefix/share/locale
- bindtextdomain(PROJECT_NAME, LOCALE_INSTALL_DIR);
-# else // old vim style: $runtime/lang
- {
- char_u *p;
-
- // expand_env() doesn't work yet, because g_chartab[] is not
- // initialized yet, call vim_getenv() directly
- p = (char_u *)vim_getenv("VIMRUNTIME");
- if (p != NULL && *p != NUL) {
- vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
- bindtextdomain(PROJECT_NAME, (char *)NameBuff);
- }
- xfree(p);
+ char localepath[MAXPATHL] = { 0 };
+ char *exepath = localepath;
+ size_t exepathlen = MAXPATHL;
+ if (os_exepath(exepath, &exepathlen) != 0) {
+ path_guess_exepath(argv0 ? argv0 : "nvim", exepath, sizeof(exepath));
}
-# endif
+ char *tail = (char *)path_tail_with_sep((char_u *)exepath);
+ *tail = NUL;
+ tail = (char *)path_tail((char_u *)exepath);
+ xstrlcpy(tail, "share/locale",
+ sizeof(localepath) - (size_t)(tail - localepath));
+ bindtextdomain(PROJECT_NAME, localepath);
textdomain(PROJECT_NAME);
TIME_MSG("locale set");
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index fde1116cc9..8ff62d5b12 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -2598,11 +2598,11 @@ did_set_string_option(
} else if (varp == &p_hf) { // 'helpfile'
// May compute new values for $VIM and $VIMRUNTIME
if (didset_vim) {
- vim_setenv("VIM", "");
+ os_setenv("VIM", "", 1);
didset_vim = false;
}
if (didset_vimruntime) {
- vim_setenv("VIMRUNTIME", "");
+ os_setenv("VIMRUNTIME", "", 1);
didset_vimruntime = false;
}
} else if (varp == &curwin->w_p_cc) { // 'colorcolumn'
@@ -6744,7 +6744,7 @@ void vimrc_found(char_u *fname, char_u *envname)
// Set $MYVIMRC to the first vimrc file found.
p = FullName_save((char *)fname, false);
if (p != NULL) {
- vim_setenv((char *)envname, p);
+ os_setenv((char *)envname, p, 1);
xfree(p);
}
} else {
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index b067de608b..871298f415 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -805,10 +805,10 @@ char *vim_getenv(const char *name)
// next time, and others can also use it (e.g. Perl).
if (vim_path != NULL) {
if (vimruntime) {
- vim_setenv("VIMRUNTIME", vim_path);
+ os_setenv("VIMRUNTIME", vim_path, 1);
didset_vimruntime = true;
} else {
- vim_setenv("VIM", vim_path);
+ os_setenv("VIM", vim_path, 1);
didset_vim = true;
}
}
@@ -955,22 +955,6 @@ char_u * home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET
return dst;
}
-/// Vim setenv() wrapper with special handling for $VIMRUNTIME to keep the
-/// localization machinery sane.
-void vim_setenv(const char *name, const char *val)
-{
- os_setenv(name, val, 1);
-#ifndef LOCALE_INSTALL_DIR
- // When setting $VIMRUNTIME adjust the directory to find message
- // translations to $VIMRUNTIME/lang.
- if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) {
- char *buf = (char *)concat_str((char_u *)val, (char_u *)"/lang");
- bindtextdomain(PROJECT_NAME, buf);
- xfree(buf);
- }
-#endif
-}
-
/// Function given to ExpandGeneric() to obtain an environment variable name.
char_u *get_env_name(expand_T *xp, int idx)