mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 05:35:10 -07:00
startup: init v:progpath before calling vim_getenv (#6755)
This commit is contained in:
parent
96ede7c567
commit
060ce0e0bc
@ -124,7 +124,7 @@ typedef struct {
|
|||||||
|
|
||||||
Loop main_loop;
|
Loop main_loop;
|
||||||
|
|
||||||
static char *argv0;
|
static char *argv0 = NULL;
|
||||||
|
|
||||||
// Error messages
|
// Error messages
|
||||||
static const char *err_arg_missing = N_("Argument missing after");
|
static const char *err_arg_missing = N_("Argument missing after");
|
||||||
@ -179,11 +179,9 @@ void early_init(void)
|
|||||||
log_init();
|
log_init();
|
||||||
fs_init();
|
fs_init();
|
||||||
handle_init();
|
handle_init();
|
||||||
|
|
||||||
eval_init(); // init global variables
|
eval_init(); // init global variables
|
||||||
|
init_path(argv0 ? argv0 : "nvim");
|
||||||
// Init the table of Normal mode commands.
|
init_normal_cmds(); // Init the table of Normal mode commands.
|
||||||
init_normal_cmds();
|
|
||||||
|
|
||||||
#if defined(HAVE_LOCALE_H)
|
#if defined(HAVE_LOCALE_H)
|
||||||
// Setup to use the current locale (for ctype() and many other things).
|
// Setup to use the current locale (for ctype() and many other things).
|
||||||
@ -221,7 +219,7 @@ int nvim_main(int argc, char **argv)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
argv0 = (char *)path_tail((char_u *)argv[0]);
|
argv0 = argv[0];
|
||||||
|
|
||||||
char_u *fname = NULL; // file name from command line
|
char_u *fname = NULL; // file name from command line
|
||||||
mparm_T params; // various parameters passed between
|
mparm_T params; // various parameters passed between
|
||||||
@ -241,8 +239,6 @@ int main(int argc, char **argv)
|
|||||||
// Check if we have an interactive window.
|
// Check if we have an interactive window.
|
||||||
check_and_set_isatty(¶ms);
|
check_and_set_isatty(¶ms);
|
||||||
|
|
||||||
init_path(argv[0]);
|
|
||||||
|
|
||||||
event_init();
|
event_init();
|
||||||
/*
|
/*
|
||||||
* Process the command line arguments. File names are put in the global
|
* Process the command line arguments. File names are put in the global
|
||||||
@ -1217,7 +1213,8 @@ static void check_and_set_isatty(mparm_T *paramp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sets v:progname and v:progpath. Also modifies $PATH on Windows.
|
// Sets v:progname and v:progpath. Also modifies $PATH on Windows.
|
||||||
static void init_path(char *exename)
|
static void init_path(const char *exename)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char exepath[MAXPATHL] = { 0 };
|
char exepath[MAXPATHL] = { 0 };
|
||||||
size_t exepathlen = MAXPATHL;
|
size_t exepathlen = MAXPATHL;
|
||||||
@ -1834,9 +1831,11 @@ static bool file_owned(const char *fname)
|
|||||||
/// @param str string to append to the primary error message, or NULL
|
/// @param str string to append to the primary error message, or NULL
|
||||||
static void mainerr(const char *errstr, const char *str)
|
static void mainerr(const char *errstr, const char *str)
|
||||||
{
|
{
|
||||||
|
char *prgname = (char *)path_tail((char_u *)argv0);
|
||||||
|
|
||||||
signal_stop(); // kill us with CTRL-C here, if you like
|
signal_stop(); // kill us with CTRL-C here, if you like
|
||||||
|
|
||||||
mch_errmsg(argv0);
|
mch_errmsg(prgname);
|
||||||
mch_errmsg(": ");
|
mch_errmsg(": ");
|
||||||
mch_errmsg(_(errstr));
|
mch_errmsg(_(errstr));
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
@ -1845,7 +1844,7 @@ static void mainerr(const char *errstr, const char *str)
|
|||||||
mch_errmsg("\"");
|
mch_errmsg("\"");
|
||||||
}
|
}
|
||||||
mch_errmsg(_("\nMore info with \""));
|
mch_errmsg(_("\nMore info with \""));
|
||||||
mch_errmsg(argv0);
|
mch_errmsg(prgname);
|
||||||
mch_errmsg(" -h\"\n");
|
mch_errmsg(" -h\"\n");
|
||||||
|
|
||||||
mch_exit(1);
|
mch_exit(1);
|
||||||
|
@ -600,6 +600,10 @@ const void *vim_env_iter_rev(const char delim,
|
|||||||
/// @param name Environment variable to expand
|
/// @param name Environment variable to expand
|
||||||
char *vim_getenv(const char *name)
|
char *vim_getenv(const char *name)
|
||||||
{
|
{
|
||||||
|
// init_path() should have been called before now.
|
||||||
|
assert(get_vim_var_str(VV_PROGPATH)
|
||||||
|
&& get_vim_var_str(VV_PROGPATH)[0] != NUL);
|
||||||
|
|
||||||
const char *kos_env_path = os_getenv(name);
|
const char *kos_env_path = os_getenv(name);
|
||||||
if (kos_env_path != NULL) {
|
if (kos_env_path != NULL) {
|
||||||
return xstrdup(kos_env_path);
|
return xstrdup(kos_env_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user