aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2021-09-22 15:25:38 +0200
committerGitHub <noreply@github.com>2021-09-22 06:25:38 -0700
commit48e67b229415b4e2b3315bd00b817e5f9ab970c8 (patch)
tree334596ac20fa458d3966e9dbc5ed7f2478ccbafa /src
parentfb6f27e86f2ca2fbff88737251d9e26016a62081 (diff)
downloadrneovim-48e67b229415b4e2b3315bd00b817e5f9ab970c8.tar.gz
rneovim-48e67b229415b4e2b3315bd00b817e5f9ab970c8.tar.bz2
rneovim-48e67b229415b4e2b3315bd00b817e5f9ab970c8.zip
refactor: format with uncrustify #15741
Diffstat (limited to 'src')
-rw-r--r--src/nvim/main.c843
-rw-r--r--src/nvim/map.c16
-rw-r--r--src/nvim/mark.c526
-rw-r--r--src/nvim/marktree.c41
-rw-r--r--src/nvim/math.c10
-rw-r--r--src/nvim/memfile.c116
-rw-r--r--src/nvim/memline.c1500
-rw-r--r--src/nvim/memory.c90
-rw-r--r--src/nvim/menu.c476
-rw-r--r--src/nvim/message.c613
-rw-r--r--src/nvim/misc1.c261
-rw-r--r--src/nvim/mouse.c150
-rw-r--r--src/nvim/move.c373
13 files changed, 2638 insertions, 2377 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 99d8a03381..d977589ad7 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -3,25 +3,22 @@
#define EXTERN
#include <assert.h>
+#include <msgpack.h>
+#include <stdbool.h>
#include <stdint.h>
#include <string.h>
-#include <stdbool.h>
-
-#include <msgpack.h>
#include "nvim/ascii.h"
-#include "nvim/channel.h"
-#include "nvim/vim.h"
-#include "nvim/main.h"
#include "nvim/aucmd.h"
#include "nvim/buffer.h"
+#include "nvim/channel.h"
#include "nvim/charset.h"
+#include "nvim/decoration.h"
#include "nvim/diff.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
-#include "nvim/decoration.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
@@ -30,29 +27,36 @@
#include "nvim/iconv.h"
#include "nvim/if_cscope.h"
#include "nvim/lua/executor.h"
+#include "nvim/main.h"
+#include "nvim/vim.h"
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
+#include "nvim/garray.h"
+#include "nvim/log.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
+#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
-#include "nvim/garray.h"
-#include "nvim/log.h"
-#include "nvim/memory.h"
-#include "nvim/move.h"
#include "nvim/mouse.h"
+#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
-#include "nvim/os_unix.h"
+#include "nvim/os/fileio.h"
+#include "nvim/os/input.h"
+#include "nvim/os/os.h"
#include "nvim/os/os_defs.h"
+#include "nvim/os/time.h"
+#include "nvim/os_unix.h"
#include "nvim/path.h"
-#include "nvim/profile.h"
#include "nvim/popupmnu.h"
+#include "nvim/profile.h"
#include "nvim/quickfix.h"
#include "nvim/screen.h"
+#include "nvim/shada.h"
#include "nvim/sign.h"
#include "nvim/state.h"
#include "nvim/strings.h"
@@ -61,24 +65,19 @@
#include "nvim/ui_compositor.h"
#include "nvim/version.h"
#include "nvim/window.h"
-#include "nvim/shada.h"
-#include "nvim/os/input.h"
-#include "nvim/os/os.h"
-#include "nvim/os/time.h"
-#include "nvim/os/fileio.h"
#ifdef WIN32
# include "nvim/os/os_win_console.h"
#endif
+#include "nvim/api/private/defs.h"
+#include "nvim/api/private/dispatch.h"
+#include "nvim/api/private/helpers.h"
+#include "nvim/api/ui.h"
#include "nvim/event/loop.h"
-#include "nvim/os/signal.h"
#include "nvim/event/process.h"
+#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/msgpack_rpc/server.h"
-#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/api/ui.h"
-#include "nvim/api/private/defs.h"
-#include "nvim/api/private/helpers.h"
-#include "nvim/api/private/dispatch.h"
+#include "nvim/os/signal.h"
#ifndef WIN32
# include "nvim/os/pty_process_unix.h"
#endif
@@ -278,9 +277,9 @@ int main(int argc, char **argv)
TIME_MSG("expanding arguments");
- if (params.diff_mode && params.window_count == -1)
- params.window_count = 0; /* open up to 3 windows */
-
+ if (params.diff_mode && params.window_count == -1) {
+ params.window_count = 0; // open up to 3 windows
+ }
// Don't redraw until much later.
RedrawingDisabled++;
@@ -586,15 +585,16 @@ void getout(int exitval)
/* When running in Ex mode an error causes us to exit with a non-zero exit
* code. POSIX requires this, although it's not 100% clear from the
* standard. */
- if (exmode_active)
+ if (exmode_active) {
exitval += ex_exitval;
+ }
set_vim_var_nr(VV_EXITING, exitval);
// Position the cursor on the last screen line, below all the text
ui_cursor_goto(Rows - 1, 0);
- /* Optionally print hashtable efficiency. */
+ // Optionally print hashtable efficiency.
hash_debug_results();
if (v_dying <= 1) {
@@ -605,7 +605,7 @@ void getout(int exitval)
next_tp = tp->tp_next;
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
if (wp->w_buffer == NULL) {
- /* Autocmd must have close the buffer already, skip. */
+ // Autocmd must have close the buffer already, skip.
continue;
}
@@ -626,7 +626,7 @@ void getout(int exitval)
}
}
- /* Trigger BufUnload for buffers that are loaded */
+ // Trigger BufUnload for buffers that are loaded
FOR_ALL_BUFFERS(buf) {
if (buf->b_ml.ml_mfp != NULL) {
bufref_T bufref;
@@ -674,8 +674,8 @@ void getout(int exitval)
profile_dump();
if (did_emsg
- ) {
- /* give the user a chance to read the (error) message */
+ ) {
+ // give the user a chance to read the (error) message
no_wait_return = FALSE;
wait_return(FALSE);
}
@@ -727,7 +727,7 @@ static void init_locale(void)
setlocale(LC_ALL, "");
# ifdef LC_NUMERIC
- /* Make sure strtod() uses a decimal point, not a comma. */
+ // Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
# endif
@@ -749,10 +749,10 @@ static void init_locale(void)
static bool edit_stdin(bool explicit, mparm_T *parmp)
{
bool implicit = !headless_mode
- && !embedded_mode
- && (!exmode_active || parmp->input_neverscript)
- && !parmp->input_isatty
- && scriptin[0] == NULL; // `-s -` was not given.
+ && !embedded_mode
+ && (!exmode_active || parmp->input_neverscript)
+ && !parmp->input_isatty
+ && scriptin[0] == NULL; // `-s -` was not given.
return explicit || implicit;
}
@@ -784,270 +784,242 @@ static void command_line_scan(mparm_T *parmp)
parmp->commands[parmp->n_commands++] = &(argv[0][1]);
}
- // Optional argument.
+ // Optional argument.
} else if (argv[0][0] == '-' && !had_minmin) {
want_argument = false;
c = argv[0][argv_idx++];
switch (c) {
- case NUL: { // "nvim -" read from stdin
- if (exmode_active) {
- // "nvim -e -" silent mode
- silent_mode = true;
- parmp->no_swap_file = true;
- } else {
- if (parmp->edit_type != EDIT_NONE
- && parmp->edit_type != EDIT_FILE
- && parmp->edit_type != EDIT_STDIN) {
- mainerr(err_too_many_args, argv[0]);
- }
- had_stdin_file = true;
- parmp->edit_type = EDIT_STDIN;
+ case NUL: // "nvim -" read from stdin
+ if (exmode_active) {
+ // "nvim -e -" silent mode
+ silent_mode = true;
+ parmp->no_swap_file = true;
+ } else {
+ if (parmp->edit_type != EDIT_NONE
+ && parmp->edit_type != EDIT_FILE
+ && parmp->edit_type != EDIT_STDIN) {
+ mainerr(err_too_many_args, argv[0]);
}
- argv_idx = -1; // skip to next argument
- break;
+ had_stdin_file = true;
+ parmp->edit_type = EDIT_STDIN;
}
- case '-': { // "--" don't take any more option arguments
- // "--help" give help message
- // "--version" give version message
- // "--noplugin[s]" skip plugins
- // "--cmd <cmd>" execute cmd before vimrc
- if (STRICMP(argv[0] + argv_idx, "help") == 0) {
- usage();
- os_exit(0);
- } else if (STRICMP(argv[0] + argv_idx, "version") == 0) {
- version();
- os_exit(0);
- } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) {
- FileDescriptor fp;
- const int fof_ret = file_open_fd(&fp, STDOUT_FILENO,
- kFileWriteOnly);
- msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
-
- if (fof_ret != 0) {
- emsgf(_("E5421: Failed to open stdin: %s"), os_strerror(fof_ret));
- }
+ argv_idx = -1; // skip to next argument
+ break;
+ case '-': // "--" don't take any more option arguments
+ // "--help" give help message
+ // "--version" give version message
+ // "--noplugin[s]" skip plugins
+ // "--cmd <cmd>" execute cmd before vimrc
+ if (STRICMP(argv[0] + argv_idx, "help") == 0) {
+ usage();
+ os_exit(0);
+ } else if (STRICMP(argv[0] + argv_idx, "version") == 0) {
+ version();
+ os_exit(0);
+ } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) {
+ FileDescriptor fp;
+ const int fof_ret = file_open_fd(&fp, STDOUT_FILENO,
+ kFileWriteOnly);
+ msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
+
+ if (fof_ret != 0) {
+ emsgf(_("E5421: Failed to open stdin: %s"), os_strerror(fof_ret));
+ }
- if (p == NULL) {
- EMSG(_(e_outofmem));
- }
+ if (p == NULL) {
+ EMSG(_(e_outofmem));
+ }
- Object md = DICTIONARY_OBJ(api_metadata());
- msgpack_rpc_from_object(md, p);
+ Object md = DICTIONARY_OBJ(api_metadata());
+ msgpack_rpc_from_object(md, p);
- msgpack_packer_free(p);
- const int ff_ret = file_flush(&fp);
- if (ff_ret < 0) {
- msgpack_file_write_error(ff_ret);
- }
- os_exit(0);
- } else if (STRICMP(argv[0] + argv_idx, "headless") == 0) {
- headless_mode = true;
- } else if (STRICMP(argv[0] + argv_idx, "embed") == 0) {
- embedded_mode = true;
- } else if (STRNICMP(argv[0] + argv_idx, "listen", 6) == 0) {
- want_argument = true;
- argv_idx += 6;
- } else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) {
- // Do nothing: file args are always literal. #7679
- } else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) {
- p_lpl = false;
- } else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) {
- want_argument = true;
- argv_idx += 3;
- } else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0) {
- want_argument = true;
- argv_idx += 11;
- } else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0) {
- parmp->use_vimrc = "NONE";
- parmp->clean = true;
- set_option_value("shadafile", 0L, "NONE", 0);
- } else {
- if (argv[0][argv_idx])
- mainerr(err_opt_unknown, argv[0]);
- had_minmin = true;
+ msgpack_packer_free(p);
+ const int ff_ret = file_flush(&fp);
+ if (ff_ret < 0) {
+ msgpack_file_write_error(ff_ret);
}
- if (!want_argument) {
- argv_idx = -1; // skip to next argument
+ os_exit(0);
+ } else if (STRICMP(argv[0] + argv_idx, "headless") == 0) {
+ headless_mode = true;
+ } else if (STRICMP(argv[0] + argv_idx, "embed") == 0) {
+ embedded_mode = true;
+ } else if (STRNICMP(argv[0] + argv_idx, "listen", 6) == 0) {
+ want_argument = true;
+ argv_idx += 6;
+ } else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) {
+ // Do nothing: file args are always literal. #7679
+ } else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) {
+ p_lpl = false;
+ } else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) {
+ want_argument = true;
+ argv_idx += 3;
+ } else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0) {
+ want_argument = true;
+ argv_idx += 11;
+ } else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0) {
+ parmp->use_vimrc = "NONE";
+ parmp->clean = true;
+ set_option_value("shadafile", 0L, "NONE", 0);
+ } else {
+ if (argv[0][argv_idx]) {
+ mainerr(err_opt_unknown, argv[0]);
}
- break;
- }
- case 'A': { // "-A" start in Arabic mode.
- set_option_value("arabic", 1L, NULL, 0);
- break;
+ had_minmin = true;
}
- case 'b': { // "-b" binary mode.
- // Needs to be effective before expanding file names, because
- // for Win32 this makes us edit a shortcut file itself,
- // instead of the file it links to.
- set_options_bin(curbuf->b_p_bin, 1, 0);
- curbuf->b_p_bin = 1; // Binary file I/O.
- break;
+ if (!want_argument) {
+ argv_idx = -1; // skip to next argument
}
+ break;
+ case 'A': // "-A" start in Arabic mode.
+ set_option_value("arabic", 1L, NULL, 0);
+ break;
+ case 'b': // "-b" binary mode.
+ // Needs to be effective before expanding file names, because
+ // for Win32 this makes us edit a shortcut file itself,
+ // instead of the file it links to.
+ set_options_bin(curbuf->b_p_bin, 1, 0);
+ curbuf->b_p_bin = 1; // Binary file I/O.
+ break;
- case 'D': { // "-D" Debugging
- parmp->use_debug_break_level = 9999;
- break;
- }
- case 'd': { // "-d" 'diff'
- parmp->diff_mode = true;
- break;
- }
- case 'e': { // "-e" Ex mode
- exmode_active = true;
- break;
- }
- case 'E': { // "-E" Ex mode
- exmode_active = true;
- parmp->input_neverscript = true;
- break;
- }
- case 'f': { // "-f" GUI: run in foreground.
- break;
- }
- case '?': // "-?" give help message (for MS-Windows)
- case 'h': { // "-h" give help message
- usage();
- os_exit(0);
- }
- case 'H': { // "-H" start in Hebrew mode: rl + hkmap set.
- p_hkmap = true;
- set_option_value("rl", 1L, NULL, 0);
- break;
- }
- case 'l': { // "-l" lisp mode, 'lisp' and 'showmatch' on.
- set_option_value("lisp", 1L, NULL, 0);
- p_sm = true;
- break;
- }
- case 'M': { // "-M" no changes or writing of files
- reset_modifiable();
- FALLTHROUGH;
- }
- case 'm': { // "-m" no writing of files
- p_write = false;
- break;
- }
+ case 'D': // "-D" Debugging
+ parmp->use_debug_break_level = 9999;
+ break;
+ case 'd': // "-d" 'diff'
+ parmp->diff_mode = true;
+ break;
+ case 'e': // "-e" Ex mode
+ exmode_active = true;
+ break;
+ case 'E': // "-E" Ex mode
+ exmode_active = true;
+ parmp->input_neverscript = true;
+ break;
+ case 'f': // "-f" GUI: run in foreground.
+ break;
+ case '?': // "-?" give help message (for MS-Windows)
+ case 'h': // "-h" give help message
+ usage();
+ os_exit(0);
+ case 'H': // "-H" start in Hebrew mode: rl + hkmap set.
+ p_hkmap = true;
+ set_option_value("rl", 1L, NULL, 0);
+ break;
+ case 'l': // "-l" lisp mode, 'lisp' and 'showmatch' on.
+ set_option_value("lisp", 1L, NULL, 0);
+ p_sm = true;
+ break;
+ case 'M': // "-M" no changes or writing of files
+ reset_modifiable();
+ FALLTHROUGH;
+ case 'm': // "-m" no writing of files
+ p_write = false;
+ break;
- case 'N': // "-N" Nocompatible
- case 'X': // "-X" Do not connect to X server
- // No-op
- break;
+ case 'N': // "-N" Nocompatible
+ case 'X': // "-X" Do not connect to X server
+ // No-op
+ break;
- case 'n': { // "-n" no swap file
- parmp->no_swap_file = true;
- break;
- }
- case 'p': { // "-p[N]" open N tab pages
- // default is 0: open window for each file
- parmp->window_count = get_number_arg(argv[0], &argv_idx, 0);
- parmp->window_layout = WIN_TABS;
- break;
- }
- case 'o': { // "-o[N]" open N horizontal split windows
- // default is 0: open window for each file
- parmp->window_count = get_number_arg(argv[0], &argv_idx, 0);
- parmp->window_layout = WIN_HOR;
- break;
- }
- case 'O': { // "-O[N]" open N vertical split windows
- // default is 0: open window for each file
- parmp->window_count = get_number_arg(argv[0], &argv_idx, 0);
- parmp->window_layout = WIN_VER;
- break;
- }
- case 'q': { // "-q" QuickFix mode
- if (parmp->edit_type != EDIT_NONE) {
- mainerr(err_too_many_args, argv[0]);
- }
- parmp->edit_type = EDIT_QF;
- if (argv[0][argv_idx]) { // "-q{errorfile}"
- parmp->use_ef = (char_u *)argv[0] + argv_idx;
- argv_idx = -1;
- } else if (argc > 1) { // "-q {errorfile}"
- want_argument = true;
- }
- break;
- }
- case 'R': { // "-R" readonly mode
- readonlymode = true;
- curbuf->b_p_ro = true;
- p_uc = 10000; // don't update very often
- break;
+ case 'n': // "-n" no swap file
+ parmp->no_swap_file = true;
+ break;
+ case 'p': // "-p[N]" open N tab pages
+ // default is 0: open window for each file
+ parmp->window_count = get_number_arg(argv[0], &argv_idx, 0);
+ parmp->window_layout = WIN_TABS;
+ break;
+ case 'o': // "-o[N]" open N horizontal split windows
+ // default is 0: open window for each file
+ parmp->window_count = get_number_arg(argv[0], &argv_idx, 0);
+ parmp->window_layout = WIN_HOR;
+ break;
+ case 'O': // "-O[N]" open N vertical split windows
+ // default is 0: open window for each file
+ parmp->window_count = get_number_arg(argv[0], &argv_idx, 0);
+ parmp->window_layout = WIN_VER;
+ break;
+ case 'q': // "-q" QuickFix mode
+ if (parmp->edit_type != EDIT_NONE) {
+ mainerr(err_too_many_args, argv[0]);
}
- case 'r': // "-r" recovery mode
- case 'L': { // "-L" recovery mode
- recoverymode = 1;
- break;
+ parmp->edit_type = EDIT_QF;
+ if (argv[0][argv_idx]) { // "-q{errorfile}"
+ parmp->use_ef = (char_u *)argv[0] + argv_idx;
+ argv_idx = -1;
+ } else if (argc > 1) { // "-q {errorfile}"
+ want_argument = true;
}
- case 's': {
- if (exmode_active) { // "-es" silent (batch) Ex-mode
- silent_mode = true;
- parmp->no_swap_file = true;
- } else { // "-s {scriptin}" read from script file
- want_argument = true;
- }
- break;
+ break;
+ case 'R': // "-R" readonly mode
+ readonlymode = true;
+ curbuf->b_p_ro = true;
+ p_uc = 10000; // don't update very often
+ break;
+ case 'r': // "-r" recovery mode
+ case 'L': // "-L" recovery mode
+ recoverymode = 1;
+ break;
+ case 's':
+ if (exmode_active) { // "-es" silent (batch) Ex-mode
+ silent_mode = true;
+ parmp->no_swap_file = true;
+ } else { // "-s {scriptin}" read from script file
+ want_argument = true;
}
- case 't': { // "-t {tag}" or "-t{tag}" jump to tag
- if (parmp->edit_type != EDIT_NONE) {
- mainerr(err_too_many_args, argv[0]);
- }
- parmp->edit_type = EDIT_TAG;
- if (argv[0][argv_idx]) { // "-t{tag}"
- parmp->tagname = (char_u *)argv[0] + argv_idx;
- argv_idx = -1;
- } else { // "-t {tag}"
- want_argument = true;
- }
- break;
+ break;
+ case 't': // "-t {tag}" or "-t{tag}" jump to tag
+ if (parmp->edit_type != EDIT_NONE) {
+ mainerr(err_too_many_args, argv[0]);
}
- case 'v': {
- version();
- os_exit(0);
+ parmp->edit_type = EDIT_TAG;
+ if (argv[0][argv_idx]) { // "-t{tag}"
+ parmp->tagname = (char_u *)argv[0] + argv_idx;
+ argv_idx = -1;
+ } else { // "-t {tag}"
+ want_argument = true;
}
- case 'V': { // "-V{N}" Verbose level
- // default is 10: a little bit verbose
- p_verbose = get_number_arg(argv[0], &argv_idx, 10);
- if (argv[0][argv_idx] != NUL) {
- set_option_value("verbosefile", 0L, argv[0] + argv_idx, 0);
- argv_idx = (int)STRLEN(argv[0]);
- }
- break;
+ break;
+ case 'v':
+ version();
+ os_exit(0);
+ case 'V': // "-V{N}" Verbose level
+ // default is 10: a little bit verbose
+ p_verbose = get_number_arg(argv[0], &argv_idx, 10);
+ if (argv[0][argv_idx] != NUL) {
+ set_option_value("verbosefile", 0L, argv[0] + argv_idx, 0);
+ argv_idx = (int)STRLEN(argv[0]);
}
- case 'w': { // "-w{number}" set window height
- // "-w {scriptout}" write to script
- if (ascii_isdigit(((char_u *)argv[0])[argv_idx])) {
- n = get_number_arg(argv[0], &argv_idx, 10);
- set_option_value("window", n, NULL, 0);
- break;
- }
- want_argument = true;
+ break;
+ case 'w': // "-w{number}" set window height
+ // "-w {scriptout}" write to script
+ if (ascii_isdigit(((char_u *)argv[0])[argv_idx])) {
+ n = get_number_arg(argv[0], &argv_idx, 10);
+ set_option_value("window", n, NULL, 0);
break;
}
+ want_argument = true;
+ break;
- case 'c': { // "-c{command}" or "-c {command}" exec command
- if (argv[0][argv_idx] != NUL) {
- if (parmp->n_commands >= MAX_ARG_CMDS) {
- mainerr(err_extra_cmd, NULL);
- }
- parmp->commands[parmp->n_commands++] = argv[0] + argv_idx;
- argv_idx = -1;
- break;
+ case 'c': // "-c{command}" or "-c {command}" exec command
+ if (argv[0][argv_idx] != NUL) {
+ if (parmp->n_commands >= MAX_ARG_CMDS) {
+ mainerr(err_extra_cmd, NULL);
}
- FALLTHROUGH;
- }
- case 'S': // "-S {file}" execute Vim script
- case 'i': // "-i {shada}" use for ShaDa file
- case 'u': // "-u {vimrc}" vim inits file
- case 'U': // "-U {gvimrc}" gvim inits file
- case 'W': { // "-W {scriptout}" overwrite
- want_argument = true;
+ parmp->commands[parmp->n_commands++] = argv[0] + argv_idx;
+ argv_idx = -1;
break;
}
+ FALLTHROUGH;
+ case 'S': // "-S {file}" execute Vim script
+ case 'i': // "-i {shada}" use for ShaDa file
+ case 'u': // "-u {vimrc}" vim inits file
+ case 'U': // "-U {gvimrc}" gvim inits file
+ case 'W': // "-W {scriptout}" overwrite
+ want_argument = true;
+ break;
- default: {
- mainerr(err_opt_unknown, argv[0]);
- }
+ default:
+ mainerr(err_opt_unknown, argv[0]);
}
// Handle option arguments with argument.
@@ -1065,130 +1037,122 @@ static void command_line_scan(mparm_T *parmp)
argv_idx = -1;
switch (c) {
- case 'c': // "-c {command}" execute command
- case 'S': { // "-S {file}" execute Vim script
- if (parmp->n_commands >= MAX_ARG_CMDS) {
- mainerr(err_extra_cmd, NULL);
- }
- if (c == 'S') {
- char *a;
-
- if (argc < 1) {
- // "-S" without argument: use default session file name.
- a = SESSION_FILE;
- } else if (argv[0][0] == '-') {
- // "-S" followed by another option: use default session file.
- a = SESSION_FILE;
- ++argc;
- --argv;
- } else {
- a = argv[0];
- }
-
- size_t s_size = STRLEN(a) + 9;
- char *s = xmalloc(s_size);
- snprintf(s, s_size, "so %s", a);
- parmp->cmds_tofree[parmp->n_commands] = true;
- parmp->commands[parmp->n_commands++] = s;
+ case 'c': // "-c {command}" execute command
+ case 'S': // "-S {file}" execute Vim script
+ if (parmp->n_commands >= MAX_ARG_CMDS) {
+ mainerr(err_extra_cmd, NULL);
+ }
+ if (c == 'S') {
+ char *a;
+
+ if (argc < 1) {
+ // "-S" without argument: use default session file name.
+ a = SESSION_FILE;
+ } else if (argv[0][0] == '-') {
+ // "-S" followed by another option: use default session file.
+ a = SESSION_FILE;
+ ++argc;
+ --argv;
} else {
- parmp->commands[parmp->n_commands++] = argv[0];
+ a = argv[0];
}
- break;
+
+ size_t s_size = STRLEN(a) + 9;
+ char *s = xmalloc(s_size);
+ snprintf(s, s_size, "so %s", a);
+ parmp->cmds_tofree[parmp->n_commands] = true;
+ parmp->commands[parmp->n_commands++] = s;
+ } else {
+ parmp->commands[parmp->n_commands++] = argv[0];
}
+ break;
- case '-': {
- if (strequal(argv[-1], "--cmd")) {
- // "--cmd {command}" execute command
- if (parmp->n_pre_commands >= MAX_ARG_CMDS) {
- mainerr(err_extra_cmd, NULL);
- }
- parmp->pre_commands[parmp->n_pre_commands++] = argv[0];
- } else if (strequal(argv[-1], "--listen")) {
- // "--listen {address}"
- parmp->listen_addr = argv[0];
+ case '-':
+ if (strequal(argv[-1], "--cmd")) {
+ // "--cmd {command}" execute command
+ if (parmp->n_pre_commands >= MAX_ARG_CMDS) {
+ mainerr(err_extra_cmd, NULL);
}
- // "--startuptime <file>" already handled
- break;
+ parmp->pre_commands[parmp->n_pre_commands++] = argv[0];
+ } else if (strequal(argv[-1], "--listen")) {
+ // "--listen {address}"
+ parmp->listen_addr = argv[0];
}
+ // "--startuptime <file>" already handled
+ break;
- case 'q': { // "-q {errorfile}" QuickFix mode
- parmp->use_ef = (char_u *)argv[0];
- break;
- }
+ case 'q': // "-q {errorfile}" QuickFix mode
+ parmp->use_ef = (char_u *)argv[0];
+ break;
- case 'i': { // "-i {shada}" use for shada
- set_option_value("shadafile", 0L, argv[0], 0);
- break;
- }
+ case 'i': // "-i {shada}" use for shada
+ set_option_value("shadafile", 0L, argv[0], 0);
+ break;
- case 's': { // "-s {scriptin}" read from script file
- if (scriptin[0] != NULL) {
+ case 's': { // "-s {scriptin}" read from script file
+ if (scriptin[0] != NULL) {
scripterror:
- vim_snprintf((char *)IObuff, IOSIZE,
- _("Attempt to open script file again: \"%s %s\"\n"),
- argv[-1], argv[0]);
- mch_errmsg((const char *)IObuff);
- os_exit(2);
- }
- int error;
- if (strequal(argv[0], "-")) {
- const int stdin_dup_fd = os_dup(STDIN_FILENO);
+ vim_snprintf((char *)IObuff, IOSIZE,
+ _("Attempt to open script file again: \"%s %s\"\n"),
+ argv[-1], argv[0]);
+ mch_errmsg((const char *)IObuff);
+ os_exit(2);
+ }
+ int error;
+ if (strequal(argv[0], "-")) {
+ const int stdin_dup_fd = os_dup(STDIN_FILENO);
#ifdef WIN32
- // Replace the original stdin with the console input handle.
- os_replace_stdin_to_conin();
+ // Replace the original stdin with the console input handle.
+ os_replace_stdin_to_conin();
#endif
- FileDescriptor *const stdin_dup = file_open_fd_new(
- &error, stdin_dup_fd, kFileReadOnly|kFileNonBlocking);
- assert(stdin_dup != NULL);
- scriptin[0] = stdin_dup;
- } else if ((scriptin[0] = file_open_new(
- &error, argv[0], kFileReadOnly|kFileNonBlocking, 0)) == NULL) {
- vim_snprintf((char *)IObuff, IOSIZE,
- _("Cannot open for reading: \"%s\": %s\n"),
- argv[0], os_strerror(error));
- mch_errmsg((const char *)IObuff);
- os_exit(2);
- }
- save_typebuf();
- break;
+ FileDescriptor *const stdin_dup = file_open_fd_new(&error, stdin_dup_fd,
+ kFileReadOnly|kFileNonBlocking);
+ assert(stdin_dup != NULL);
+ scriptin[0] = stdin_dup;
+ } else if ((scriptin[0] =
+ file_open_new(&error, argv[0], kFileReadOnly|kFileNonBlocking,
+ 0)) == NULL) {
+ vim_snprintf((char *)IObuff, IOSIZE,
+ _("Cannot open for reading: \"%s\": %s\n"),
+ argv[0], os_strerror(error));
+ mch_errmsg((const char *)IObuff);
+ os_exit(2);
}
+ save_typebuf();
+ break;
+ }
- case 't': { // "-t {tag}"
- parmp->tagname = (char_u *)argv[0];
- break;
- }
- case 'u': { // "-u {vimrc}" vim inits file
- parmp->use_vimrc = argv[0];
- break;
- }
- case 'U': { // "-U {gvimrc}" gvim inits file
+ case 't': // "-t {tag}"
+ parmp->tagname = (char_u *)argv[0];
+ break;
+ case 'u': // "-u {vimrc}" vim inits file
+ parmp->use_vimrc = argv[0];
+ break;
+ case 'U': // "-U {gvimrc}" gvim inits file
+ break;
+
+ case 'w': // "-w {nr}" 'window' value
+ // "-w {scriptout}" append to script file
+ if (ascii_isdigit(*((char_u *)argv[0]))) {
+ argv_idx = 0;
+ n = get_number_arg(argv[0], &argv_idx, 10);
+ set_option_value("window", n, NULL, 0);
+ argv_idx = -1;
break;
}
-
- case 'w': { // "-w {nr}" 'window' value
- // "-w {scriptout}" append to script file
- if (ascii_isdigit(*((char_u *)argv[0]))) {
- argv_idx = 0;
- n = get_number_arg(argv[0], &argv_idx, 10);
- set_option_value("window", n, NULL, 0);
- argv_idx = -1;
- break;
- }
- FALLTHROUGH;
+ FALLTHROUGH;
+ case 'W': // "-W {scriptout}" overwrite script file
+ if (scriptout != NULL) {
+ goto scripterror;
}
- case 'W': { // "-W {scriptout}" overwrite script file
- if (scriptout != NULL) {
- goto scripterror;
- }
- if ((scriptout = os_fopen(argv[0], c == 'w' ? APPENDBIN : WRITEBIN))
- == NULL) {
- mch_errmsg(_("Cannot open for script output: \""));
- mch_errmsg(argv[0]);
- mch_errmsg("\"\n");
- os_exit(2);
- }
- break;
+ if ((scriptout = os_fopen(argv[0], c == 'w' ? APPENDBIN : WRITEBIN))
+ == NULL) {
+ mch_errmsg(_("Cannot open for script output: \""));
+ mch_errmsg(argv[0]);
+ mch_errmsg("\"\n");
+ os_exit(2);
}
+ break;
}
}
} else { // File name argument.
@@ -1209,7 +1173,7 @@ scripterror:
if (parmp->diff_mode && os_isdir(p) && GARGCOUNT > 0
&& !os_isdir(alist_name(&GARGLIST[0]))) {
char_u *r = (char_u *)concat_fnames((char *)p,
- (char *)path_tail(alist_name(&GARGLIST[0])), true);
+