diff options
Diffstat (limited to 'src/nvim/ex_docmd.c')
| -rw-r--r-- | src/nvim/ex_docmd.c | 48 | 
1 files changed, 25 insertions, 23 deletions
| diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 1ae5038325..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; @@ -8220,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) @@ -8354,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 */ @@ -8380,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 | 
