diff options
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 74 |
1 files changed, 25 insertions, 49 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index c5625d7882..03f943b1b1 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -583,10 +583,10 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, ++no_wait_return; verbose_enter_scroll(); - smsg(_("line %" PRId64 ": %s"), - (int64_t)sourcing_lnum, cmdline_copy); - if (msg_silent == 0) - msg_puts((char_u *)"\n"); /* don't overwrite this */ + smsg(_("line %" PRIdLINENR ": %s"), sourcing_lnum, cmdline_copy); + if (msg_silent == 0) { + msg_puts("\n"); // don't overwrite this either + } verbose_leave_scroll(); --no_wait_return; @@ -1815,9 +1815,9 @@ static char_u * do_one_cmd(char_u **cmdlinep, errormsg = (char_u *)_("E493: Backwards range given"); goto doend; } - if (ask_yesno((char_u *) - _("Backwards range given, OK to swap"), FALSE) != 'y') + if (ask_yesno(_("Backwards range given, OK to swap"), false) != 'y') { goto doend; + } } lnum = ea.line1; ea.line1 = ea.line2; @@ -2582,27 +2582,29 @@ int modifier_len(char_u *cmd) * Return 2 if there is an exact match. * Return 3 if there is an ambiguous match. */ -int cmd_exists(char_u *name) +int cmd_exists(const char *const name) { exarg_T ea; - int full = FALSE; - int i; - int j; char_u *p; - /* Check command modifiers. */ - for (i = 0; i < (int)ARRAY_SIZE(cmdmods); ++i) { - for (j = 0; name[j] != NUL; ++j) - if (name[j] != cmdmods[i].name[j]) + // Check command modifiers. + for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) { + int j; + for (j = 0; name[j] != NUL; j++) { + if (name[j] != (char)cmdmods[i].name[j]) { break; - if (name[j] == NUL && j >= cmdmods[i].minlen) + } + } + if (name[j] == NUL && j >= cmdmods[i].minlen) { return cmdmods[i].name[j] == NUL ? 2 : 1; + } } /* Check built-in commands and user defined commands. * For ":2match" and ":3match" we need to skip the number. */ - ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; + ea.cmd = (char_u *)((*name == '2' || *name == '3') ? name + 1 : name); ea.cmdidx = (cmdidx_T)0; + int full = false; p = find_command(&ea, &full); if (p == NULL) return 3; @@ -3940,8 +3942,6 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) * Don't do this for: * - replacement that already has been escaped: "##" * - shell commands (may have to use quotes instead). - * - non-unix systems when there is a single argument (spaces don't - * separate arguments then). */ if (!eap->usefilter && !escaped @@ -3952,9 +3952,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) && eap->cmdidx != CMD_lgrep && eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd -#ifndef UNIX && !(eap->argt & NOSPC) -#endif ) { char_u *l; #ifdef BACKSLASH_IN_FILENAME @@ -4016,28 +4014,6 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) } } - // Replace any other wildcards, remove backslashes. -#ifdef UNIX - /* - * Only for Unix we check for more than one file name. - * For other systems spaces are considered to be part - * of the file name. - * Only check here if there is no wildcard, otherwise - * ExpandOne() will check for errors. This allows - * ":e `ls ve*.c`" on Unix. - */ - if (!has_wildcards) - for (p = eap->arg; *p; ++p) { - /* skip escaped characters */ - if (p[1] && (*p == '\\' || *p == Ctrl_V)) - ++p; - else if (ascii_iswhite(*p)) { - *errormsgp = (char_u *)_("E172: Only one file name allowed"); - return FAIL; - } - } -#endif - /* * Halve the number of backslashes (this is Vi compatible). * For Unix, when wildcards are expanded, this is @@ -8246,9 +8222,9 @@ eval_vars ( char_u *resultbuf = NULL; size_t resultlen; buf_T *buf; - int valid = VALID_HEAD + VALID_PATH; /* assume valid result */ - int skip_mod = FALSE; - char_u strbuf[30]; + int valid = VALID_HEAD | VALID_PATH; // Assume valid result. + int skip_mod = false; + char strbuf[30]; *errormsg = NULL; if (escaped != NULL) @@ -8380,8 +8356,8 @@ eval_vars ( "E496: no autocommand buffer number to substitute for \"<abuf>\""); return NULL; } - sprintf((char *)strbuf, "%d", autocmd_bufnr); - result = strbuf; + snprintf(strbuf, sizeof(strbuf), "%d", autocmd_bufnr); + result = (char_u *)strbuf; break; case SPEC_AMATCH: /* match name for autocommand */ @@ -8406,8 +8382,8 @@ eval_vars ( *errormsg = (char_u *)_("E842: no line number to use for \"<slnum>\""); return NULL; } - sprintf((char *)strbuf, "%" PRId64, (int64_t)sourcing_lnum); - result = strbuf; + snprintf(strbuf, sizeof(strbuf), "%" PRIdLINENR, sourcing_lnum); + result = (char_u *)strbuf; break; default: // should not happen |