aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 048fdd4052..6f14a00949 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -242,10 +242,10 @@ int main(int argc, char **argv)
argv0 = argv[0];
- char_u *fname = NULL; // file name from command line
+ char *fname = NULL; // file name from command line
mparm_T params; // various parameters passed between
// main() and other functions.
- char_u *cwd = NULL; // current working dir on startup
+ char *cwd = NULL; // current working dir on startup
time_init();
// Many variables are in `params` so that we can pass them around easily.
@@ -279,15 +279,6 @@ int main(int argc, char **argv)
// argument list "global_alist".
command_line_scan(&params);
-#ifndef MSWIN
- int tty_fd = params.input_isatty
- ? STDIN_FILENO
- : (params.output_isatty
- ? STDOUT_FILENO
- : (params.err_isatty ? STDERR_FILENO : -1));
- pty_process_save_termios(tty_fd);
-#endif
-
nlua_init(argv, argc, params.lua_arg0);
TIME_MSG("init lua interpreter");
@@ -560,7 +551,7 @@ int main(int argc, char **argv)
// Need to jump to the tag before executing the '-c command'.
// Makes "vim -c '/return' -t main" work.
- handle_tag((char_u *)params.tagname);
+ handle_tag(params.tagname);
// Execute any "+", "-c" and "-S" arguments.
if (params.n_commands > 0) {
@@ -1215,7 +1206,7 @@ static void command_line_scan(mparm_T *parmp)
break;
case 'w': // "-w{number}" set window height
// "-w {scriptout}" write to script
- if (ascii_isdigit(((char_u *)argv[0])[argv_idx])) {
+ if (ascii_isdigit((argv[0])[argv_idx])) {
n = get_number_arg(argv[0], &argv_idx, 10);
set_option_value_give_err("window", n, NULL, 0);
break;
@@ -1356,7 +1347,7 @@ scripterror:
case 'w': // "-w {nr}" 'window' value
// "-w {scriptout}" append to script file
- if (ascii_isdigit(*((char_u *)argv[0]))) {
+ if (ascii_isdigit(*(argv[0]))) {
argv_idx = 0;
n = get_number_arg(argv[0], &argv_idx, 10);
set_option_value_give_err("window", n, NULL, 0);
@@ -1489,9 +1480,9 @@ static void init_path(const char *exename)
}
/// Get filename from command line, if any.
-static char_u *get_fname(mparm_T *parmp, char_u *cwd)
+static char *get_fname(mparm_T *parmp, char *cwd)
{
- return (char_u *)alist_name(&GARGLIST[0]);
+ return alist_name(&GARGLIST[0]);
}
// Decide about window layout for diff mode after reading vimrc.
@@ -1525,7 +1516,7 @@ static void handle_quickfix(mparm_T *paramp)
// Need to jump to the tag before executing the '-c command'.
// Makes "vim -c '/return' -t main" work.
-static void handle_tag(char_u *tagname)
+static void handle_tag(char *tagname)
{
if (tagname != NULL) {
swap_exists_did_quit = false;
@@ -1713,7 +1704,7 @@ static void create_windows(mparm_T *parmp)
/// If opened more than one window, start editing files in the other
/// windows. make_windows() has already opened the windows.
-static void edit_buffers(mparm_T *parmp, char_u *cwd)
+static void edit_buffers(mparm_T *parmp, char *cwd)
{
int arg_idx; // index in argument list
int i;
@@ -1734,7 +1725,7 @@ static void edit_buffers(mparm_T *parmp, char_u *cwd)
arg_idx = 1;
for (i = 1; i < parmp->window_count; i++) {
if (cwd != NULL) {
- os_chdir((char *)cwd);
+ os_chdir(cwd);
}
// When w_arg_idx is -1 remove the window (see create_windows()).
if (curwin->w_arg_idx == -1) {
@@ -1837,17 +1828,19 @@ static void exe_pre_commands(mparm_T *parmp)
int cnt = parmp->n_pre_commands;
int i;
- if (cnt > 0) {
- curwin->w_cursor.lnum = 0; // just in case..
- estack_push(ETYPE_ARGS, _("pre-vimrc command line"), 0);
- current_sctx.sc_sid = SID_CMDARG;
- for (i = 0; i < cnt; i++) {
- do_cmdline_cmd(cmds[i]);
- }
- estack_pop();
- current_sctx.sc_sid = 0;
- TIME_MSG("--cmd commands");
+ if (cnt <= 0) {
+ return;
}
+
+ curwin->w_cursor.lnum = 0; // just in case..
+ estack_push(ETYPE_ARGS, _("pre-vimrc command line"), 0);
+ current_sctx.sc_sid = SID_CMDARG;
+ for (i = 0; i < cnt; i++) {
+ do_cmdline_cmd(cmds[i]);
+ }
+ estack_pop();
+ current_sctx.sc_sid = 0;
+ TIME_MSG("--cmd commands");
}
// Execute "+", "-c" and "-S" arguments.
@@ -1953,13 +1946,13 @@ static bool do_user_initialization(void)
return do_exrc;
}
- char_u *init_lua_path = (char_u *)stdpaths_user_conf_subpath("init.lua");
- char_u *user_vimrc = (char_u *)stdpaths_user_conf_subpath("init.vim");
+ char *init_lua_path = stdpaths_user_conf_subpath("init.lua");
+ char *user_vimrc = stdpaths_user_conf_subpath("init.vim");
// init.lua
- if (os_path_exists((char *)init_lua_path)
- && do_source((char *)init_lua_path, true, DOSO_VIMRC)) {
- if (os_path_exists((char *)user_vimrc)) {
+ if (os_path_exists(init_lua_path)
+ && do_source(init_lua_path, true, DOSO_VIMRC)) {
+ if (os_path_exists(user_vimrc)) {
semsg(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path,
user_vimrc);
}
@@ -1972,10 +1965,10 @@ static bool do_user_initialization(void)
xfree(init_lua_path);
// init.vim
- if (do_source((char *)user_vimrc, true, DOSO_VIMRC) != FAIL) {
+ if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
do_exrc = p_exrc;
if (do_exrc) {
- do_exrc = (path_full_compare(VIMRC_FILE, (char *)user_vimrc, false, true) != kEqualFiles);
+ do_exrc = (path_full_compare(VIMRC_FILE, user_vimrc, false, true) != kEqualFiles);
}
xfree(user_vimrc);
return do_exrc;
@@ -2088,19 +2081,20 @@ static int execute_env(char *env)
FUNC_ATTR_NONNULL_ALL
{
const char *initstr = os_getenv(env);
- if (initstr != NULL) {
- estack_push(ETYPE_ENV, env, 0);
- const sctx_T save_current_sctx = current_sctx;
- current_sctx.sc_sid = SID_ENV;
- current_sctx.sc_seq = 0;
- current_sctx.sc_lnum = 0;
- do_cmdline_cmd((char *)initstr);
-
- estack_pop();
- current_sctx = save_current_sctx;
- return OK;
- }
- return FAIL;
+ if (initstr == NULL) {
+ return FAIL;
+ }
+
+ estack_push(ETYPE_ENV, env, 0);
+ const sctx_T save_current_sctx = current_sctx;
+ current_sctx.sc_sid = SID_ENV;
+ current_sctx.sc_seq = 0;
+ current_sctx.sc_lnum = 0;
+ do_cmdline_cmd((char *)initstr);
+
+ estack_pop();
+ current_sctx = save_current_sctx;
+ return OK;
}
/// Prints the following then exits: