mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
Enable -Wconversion: normal.c.
Refactor summary: - extern int opcount --> extern long opcount - bool find_decl(..., int len, ...) --> bool find_decl(..., size_t len, ...) * int find_ident_under_cursor(...) --> size_t find_ident_under_cursor(...) - int find_ident_at_pos(...) --> size_t find_ident_at_pos(...) - int modify_fname(..., int *usedlen, ..., int *fnamelen) --> int modify_fname(..., size_t *usedlen, ..., size_t *fnamelen) * char_u *eval_vars(..., int *usedlen, ...) --> char_u *eval_vars(..., size_t *usedlen, ...) - int find_cmdline_var(..., int *usedlen) --> ssize_t find_cmdline_var(..., size_t *usedlen) - static char_u *repl_cmdline(..., int srclen, ...) --> static char_u *repl_cmdline(..., size_t srclen, ...) - bool get_visual_text(..., int *lenp) --> bool get_visual_text(..., size_t *lenp) * char_u *find_file_name_in_path(..., int len, ...) --> char_u *find_file_name_in_path(..., size_t len, ...) - static char_u *eval_includeexpr(..., int len) --> static char_u *eval_includeexpr(..., size_t len) - char_u *find_file_in_path(..., int len, ...) --> char_u *find_file_in_path(..., size_t len, ...) * char_u *find_file_in_path_option(..., int len, ...) --> char_u *find_file_in_path_option(..., size_t len, ...) - char_u *find_directory_in_path(..., int len, ...) --> char_u *find_directory_in_path(..., size_t len, ...) * int spell_move_to(...) --> size_t spell_move_to(...) - int spell_check(...) --> size_t spell_check(...) - static int spell_bad_len --> static size_t spell_bad_len - void find_pattern_in_path(..., int len, ...) --> void find_pattern_in_path(..., size_t len, ...) Helped-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -60,7 +60,6 @@ set(CONV_SOURCES
|
||||
menu.c
|
||||
message.c
|
||||
misc1.c
|
||||
normal.c
|
||||
ops.c
|
||||
path.c
|
||||
quickfix.c
|
||||
|
@@ -192,7 +192,7 @@ static int compl_opt_refresh_always = FALSE;
|
||||
#define BACKSPACE_WORD_NOT_SPACE 3
|
||||
#define BACKSPACE_LINE 4
|
||||
|
||||
static int spell_bad_len = 0; /* length of located bad word */
|
||||
static size_t spell_bad_len = 0; /* length of located bad word */
|
||||
|
||||
static colnr_T Insstart_textlen; /* length of line when insert started */
|
||||
static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */
|
||||
@@ -3539,11 +3539,12 @@ static int ins_compl_get_exp(pos_T *ini)
|
||||
case CTRL_X_PATH_PATTERNS:
|
||||
case CTRL_X_PATH_DEFINES:
|
||||
find_pattern_in_path(compl_pattern, compl_direction,
|
||||
(int)STRLEN(compl_pattern), FALSE, FALSE,
|
||||
(type == CTRL_X_PATH_DEFINES
|
||||
STRLEN(compl_pattern), FALSE, FALSE,
|
||||
((type == CTRL_X_PATH_DEFINES
|
||||
&& !(compl_cont_status & CONT_SOL))
|
||||
? FIND_DEFINE : FIND_ANY, 1L, ACTION_EXPAND,
|
||||
(linenr_T)1, (linenr_T)MAXLNUM);
|
||||
? FIND_DEFINE
|
||||
: FIND_ANY),
|
||||
1L, ACTION_EXPAND, 1, MAXLNUM);
|
||||
break;
|
||||
|
||||
case CTRL_X_DICTIONARY:
|
||||
@@ -4401,8 +4402,10 @@ static int ins_complete(int c)
|
||||
compl_length = curs_col - compl_col;
|
||||
compl_pattern = vim_strnsave(line + compl_col, compl_length);
|
||||
} else if (ctrl_x_mode == CTRL_X_SPELL) {
|
||||
if (spell_bad_len > 0)
|
||||
compl_col = curs_col - spell_bad_len;
|
||||
if (spell_bad_len > 0) {
|
||||
assert(spell_bad_len <= INT_MAX);
|
||||
compl_col = curs_col - (int)spell_bad_len;
|
||||
}
|
||||
else
|
||||
compl_col = spell_word_start(startcol);
|
||||
if (compl_col >= (colnr_T)startcol) {
|
||||
@@ -5590,7 +5593,6 @@ static void check_spell_redraw(void)
|
||||
static void spell_back_to_badword(void)
|
||||
{
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
|
||||
spell_bad_len = spell_move_to(curwin, BACKWARD, TRUE, TRUE, NULL);
|
||||
if (curwin->w_cursor.col != tpos.col)
|
||||
start_arrow(&tpos);
|
||||
|
@@ -8262,7 +8262,7 @@ static void f_exp(typval_T *argvars, typval_T *rettv)
|
||||
static void f_expand(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *s;
|
||||
int len;
|
||||
size_t len;
|
||||
char_u *errormsg;
|
||||
int options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
|
||||
expand_T xpc;
|
||||
@@ -8531,12 +8531,12 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what)
|
||||
if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST)
|
||||
xfree(fresult);
|
||||
fresult = find_file_in_path_option(first ? fname : NULL,
|
||||
first ? (int)STRLEN(fname) : 0,
|
||||
first ? STRLEN(fname) : 0,
|
||||
0, first, path,
|
||||
find_what,
|
||||
curbuf->b_ffname,
|
||||
find_what == FINDFILE_DIR
|
||||
? (char_u *)"" : curbuf->b_p_sua);
|
||||
find_what, curbuf->b_ffname,
|
||||
(find_what == FINDFILE_DIR
|
||||
? (char_u *)""
|
||||
: curbuf->b_p_sua));
|
||||
first = FALSE;
|
||||
|
||||
if (fresult != NULL && rettv->v_type == VAR_LIST)
|
||||
@@ -8773,8 +8773,8 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *fname;
|
||||
char_u *mods;
|
||||
int usedlen = 0;
|
||||
int len;
|
||||
size_t usedlen = 0;
|
||||
size_t len;
|
||||
char_u *fbuf = NULL;
|
||||
char_u buf[NUMBUFLEN];
|
||||
|
||||
@@ -8783,7 +8783,7 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv)
|
||||
if (fname == NULL || mods == NULL)
|
||||
fname = NULL;
|
||||
else {
|
||||
len = (int)STRLEN(fname);
|
||||
len = STRLEN(fname);
|
||||
(void)modify_fname(mods, &usedlen, &fname, &fbuf, &len);
|
||||
}
|
||||
|
||||
@@ -13017,19 +13017,18 @@ static void f_searchdecl(typval_T *argvars, typval_T *rettv)
|
||||
int locally = 1;
|
||||
int thisblock = 0;
|
||||
int error = FALSE;
|
||||
char_u *name;
|
||||
|
||||
rettv->vval.v_number = 1; /* default: FAIL */
|
||||
|
||||
name = get_tv_string_chk(&argvars[0]);
|
||||
char_u *name = get_tv_string_chk(&argvars[0]);
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
locally = get_tv_number_chk(&argvars[1], &error) == 0;
|
||||
if (!error && argvars[2].v_type != VAR_UNKNOWN)
|
||||
thisblock = get_tv_number_chk(&argvars[2], &error) != 0;
|
||||
}
|
||||
if (!error && name != NULL)
|
||||
rettv->vval.v_number = find_decl(name, (int)STRLEN(name),
|
||||
locally, thisblock, SEARCH_KEEP) == FAIL;
|
||||
rettv->vval.v_number = find_decl(name, STRLEN(name), locally,
|
||||
thisblock, SEARCH_KEEP) == FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -14201,7 +14200,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *word = (char_u *)"";
|
||||
hlf_T attr = HLF_COUNT;
|
||||
int len = 0;
|
||||
size_t len = 0;
|
||||
|
||||
rettv_list_alloc(rettv);
|
||||
|
||||
@@ -14227,13 +14226,15 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
|
||||
list_append_string(rettv->vval.v_list, word, len);
|
||||
list_append_string(rettv->vval.v_list, (char_u *)(
|
||||
attr == HLF_SPB ? "bad" :
|
||||
assert(len <= INT_MAX);
|
||||
list_append_string(rettv->vval.v_list, word, (int)len);
|
||||
list_append_string(rettv->vval.v_list,
|
||||
(char_u *)(attr == HLF_SPB ? "bad" :
|
||||
attr == HLF_SPR ? "rare" :
|
||||
attr == HLF_SPL ? "local" :
|
||||
attr == HLF_SPC ? "caps" :
|
||||
""), -1);
|
||||
""),
|
||||
-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -19803,10 +19804,10 @@ void ex_oldfiles(exarg_T *eap)
|
||||
int
|
||||
modify_fname (
|
||||
char_u *src, /* string with modifiers */
|
||||
int *usedlen, /* characters after src that are used */
|
||||
size_t *usedlen, /* characters after src that are used */
|
||||
char_u **fnamep, /* file name so far */
|
||||
char_u **bufp, /* buffer for allocated file name or NULL */
|
||||
int *fnamelen /* length of fnamep */
|
||||
size_t *fnamelen /* length of fnamep */
|
||||
)
|
||||
{
|
||||
int valid = 0;
|
||||
@@ -19865,7 +19866,7 @@ repeat:
|
||||
/* Append a path separator to a directory. */
|
||||
if (os_isdir(*fnamep)) {
|
||||
/* Make room for one or two extra characters. */
|
||||
*fnamep = vim_strnsave(*fnamep, (int)STRLEN(*fnamep) + 2);
|
||||
*fnamep = vim_strnsave(*fnamep, STRLEN(*fnamep) + 2);
|
||||
xfree(*bufp); /* free any allocated file name */
|
||||
*bufp = *fnamep;
|
||||
if (*fnamep == NULL)
|
||||
@@ -19922,7 +19923,7 @@ repeat:
|
||||
}
|
||||
|
||||
tail = path_tail(*fnamep);
|
||||
*fnamelen = (int)STRLEN(*fnamep);
|
||||
*fnamelen = STRLEN(*fnamep);
|
||||
|
||||
/* ":h" - head, remove "/file_name", can be repeated */
|
||||
/* Don't remove the first "/" or "c:\" */
|
||||
@@ -19932,7 +19933,7 @@ repeat:
|
||||
s = get_past_head(*fnamep);
|
||||
while (tail > s && after_pathsep((char *)s, (char *)tail))
|
||||
mb_ptr_back(*fnamep, tail);
|
||||
*fnamelen = (int)(tail - *fnamep);
|
||||
*fnamelen = (size_t)(tail - *fnamep);
|
||||
if (*fnamelen == 0) {
|
||||
/* Result is empty. Turn it into "." to make ":cd %:h" work. */
|
||||
xfree(*bufp);
|
||||
@@ -19953,7 +19954,7 @@ repeat:
|
||||
/* ":t" - tail, just the basename */
|
||||
if (src[*usedlen] == ':' && src[*usedlen + 1] == 't') {
|
||||
*usedlen += 2;
|
||||
*fnamelen -= (int)(tail - *fnamep);
|
||||
*fnamelen -= (size_t)(tail - *fnamep);
|
||||
*fnamep = tail;
|
||||
}
|
||||
|
||||
@@ -19974,13 +19975,13 @@ repeat:
|
||||
break;
|
||||
if (src[*usedlen + 1] == 'e') { /* :e */
|
||||
if (s > tail) {
|
||||
*fnamelen += (int)(*fnamep - (s + 1));
|
||||
*fnamelen += (size_t)(*fnamep - (s + 1));
|
||||
*fnamep = s + 1;
|
||||
} else if (*fnamep <= tail)
|
||||
*fnamelen = 0;
|
||||
} else { /* :r */
|
||||
if (s > tail) /* remove one extension */
|
||||
*fnamelen = (int)(s - *fnamep);
|
||||
*fnamelen = (size_t)(s - *fnamep);
|
||||
}
|
||||
*usedlen += 2;
|
||||
}
|
||||
@@ -20016,10 +20017,10 @@ repeat:
|
||||
if (p != NULL) {
|
||||
sub = vim_strnsave(s, (int)(p - s));
|
||||
str = vim_strnsave(*fnamep, *fnamelen);
|
||||
*usedlen = (int)(p + 1 - src);
|
||||
*usedlen = (size_t)(p + 1 - src);
|
||||
s = do_string_sub(str, pat, sub, flags);
|
||||
*fnamep = s;
|
||||
*fnamelen = (int)STRLEN(s);
|
||||
*fnamelen = STRLEN(s);
|
||||
xfree(*bufp);
|
||||
*bufp = s;
|
||||
didit = TRUE;
|
||||
@@ -20038,7 +20039,7 @@ repeat:
|
||||
p = vim_strsave_shellescape(*fnamep, false, false);
|
||||
xfree(*bufp);
|
||||
*bufp = *fnamep = p;
|
||||
*fnamelen = (int)STRLEN(p);
|
||||
*fnamelen = STRLEN(p);
|
||||
*usedlen += 2;
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
* ex_docmd.c: functions for executing an Ex command line.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -3415,7 +3416,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
||||
{
|
||||
int has_wildcards; /* need to expand wildcards */
|
||||
char_u *repl;
|
||||
int srclen;
|
||||
size_t srclen;
|
||||
char_u *p;
|
||||
int escaped;
|
||||
|
||||
@@ -3543,8 +3544,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
||||
} else
|
||||
p = NULL;
|
||||
if (p != NULL) {
|
||||
(void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg),
|
||||
p, cmdlinep);
|
||||
(void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, cmdlinep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3593,8 +3593,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
||||
if (p == NULL)
|
||||
return FAIL;
|
||||
if (p != NULL) {
|
||||
(void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg),
|
||||
p, cmdlinep);
|
||||
(void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, cmdlinep);
|
||||
xfree(p);
|
||||
}
|
||||
}
|
||||
@@ -3609,22 +3608,19 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
||||
* "repl" is the replacement string.
|
||||
* Returns a pointer to the character after the replaced string.
|
||||
*/
|
||||
static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep)
|
||||
static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen,
|
||||
char_u *repl, char_u **cmdlinep)
|
||||
{
|
||||
int len;
|
||||
int i;
|
||||
char_u *new_cmdline;
|
||||
|
||||
/*
|
||||
* The new command line is build in new_cmdline[].
|
||||
* First allocate it.
|
||||
* Careful: a "+cmd" argument may have been NUL terminated.
|
||||
*/
|
||||
len = (int)STRLEN(repl);
|
||||
i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
|
||||
size_t len = STRLEN(repl);
|
||||
size_t i = (size_t)(src - *cmdlinep) + STRLEN(src + srclen) + len + 3;
|
||||
if (eap->nextcmd != NULL)
|
||||
i += (int)STRLEN(eap->nextcmd); /* add space for next command */
|
||||
new_cmdline = xmalloc(i);
|
||||
i += STRLEN(eap->nextcmd); /* add space for next command */
|
||||
char_u *new_cmdline = xmalloc(i);
|
||||
|
||||
/*
|
||||
* Copy the stuff before the expanded part.
|
||||
@@ -3632,16 +3628,16 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl,
|
||||
* Copy what came after the expanded part.
|
||||
* Copy the next commands, if there are any.
|
||||
*/
|
||||
i = (int)(src - *cmdlinep); /* length of part before match */
|
||||
memmove(new_cmdline, *cmdlinep, (size_t)i);
|
||||
i = (size_t)(src - *cmdlinep); /* length of part before match */
|
||||
memmove(new_cmdline, *cmdlinep, i);
|
||||
|
||||
memmove(new_cmdline + i, repl, (size_t)len);
|
||||
memmove(new_cmdline + i, repl, len);
|
||||
i += len; /* remember the end of the string */
|
||||
STRCPY(new_cmdline + i, src + srclen);
|
||||
src = new_cmdline + i; /* remember where to continue */
|
||||
|
||||
if (eap->nextcmd != NULL) { /* append next command */
|
||||
i = (int)STRLEN(new_cmdline) + 1;
|
||||
i = STRLEN(new_cmdline) + 1;
|
||||
STRCPY(new_cmdline + i, eap->nextcmd);
|
||||
eap->nextcmd = new_cmdline + i;
|
||||
}
|
||||
@@ -5688,7 +5684,7 @@ void ex_splitview(exarg_T *eap)
|
||||
}
|
||||
|
||||
if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) {
|
||||
fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg),
|
||||
fname = find_file_in_path(eap->arg, STRLEN(eap->arg),
|
||||
FNAME_MESS, TRUE, curbuf->b_ffname);
|
||||
if (fname == NULL)
|
||||
goto theend;
|
||||
@@ -5901,16 +5897,15 @@ static void ex_find(exarg_T *eap)
|
||||
char_u *fname;
|
||||
int count;
|
||||
|
||||
fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS,
|
||||
TRUE, curbuf->b_ffname);
|
||||
fname = find_file_in_path(eap->arg, STRLEN(eap->arg),
|
||||
FNAME_MESS, TRUE, curbuf->b_ffname);
|
||||
if (eap->addr_count > 0) {
|
||||
/* Repeat finding the file "count" times. This matters when it
|
||||
* appears several times in the path. */
|
||||
count = eap->line2;
|
||||
while (fname != NULL && --count > 0) {
|
||||
xfree(fname);
|
||||
fname = find_file_in_path(NULL, 0, FNAME_MESS,
|
||||
FALSE, curbuf->b_ffname);
|
||||
fname = find_file_in_path(NULL, 0, FNAME_MESS, FALSE, curbuf->b_ffname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7090,7 +7085,7 @@ static void ex_normal(exarg_T *eap)
|
||||
tasave_T tabuf;
|
||||
int save_insertmode = p_im;
|
||||
int save_finish_op = finish_op;
|
||||
int save_opcount = opcount;
|
||||
long save_opcount = opcount;
|
||||
char_u *arg = NULL;
|
||||
int l;
|
||||
char_u *p;
|
||||
@@ -7312,8 +7307,7 @@ static void ex_findpat(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
if (!eap->skip)
|
||||
find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg),
|
||||
whole, !eap->forceit,
|
||||
find_pattern_in_path(eap->arg, 0, STRLEN(eap->arg), whole, !eap->forceit,
|
||||
*eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY,
|
||||
n, action, eap->line1, eap->line2);
|
||||
}
|
||||
@@ -7414,10 +7408,10 @@ static void ex_tag_cmd(exarg_T *eap, char_u *name)
|
||||
* If found return one of the SPEC_ values and set "*usedlen" to the length of
|
||||
* the variable. Otherwise return -1 and "*usedlen" is unchanged.
|
||||
*/
|
||||
int find_cmdline_var(const char_u *src, int *usedlen) FUNC_ATTR_NONNULL_ALL
|
||||
ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int len;
|
||||
int i;
|
||||
size_t len;
|
||||
static char *(spec_str[]) = {
|
||||
"%",
|
||||
#define SPEC_PERC 0
|
||||
@@ -7441,11 +7435,12 @@ int find_cmdline_var(const char_u *src, int *usedlen) FUNC_ATTR_NONNULL_ALL
|
||||
# define SPEC_AMATCH 9
|
||||
};
|
||||
|
||||
for (i = 0; i < (int)ARRAY_SIZE(spec_str); ++i) {
|
||||
len = (int)STRLEN(spec_str[i]);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(spec_str); ++i) {
|
||||
len = STRLEN(spec_str[i]);
|
||||
if (STRNCMP(src, spec_str[i], len) == 0) {
|
||||
*usedlen = len;
|
||||
return i;
|
||||
assert(i <= SSIZE_MAX);
|
||||
return (ssize_t)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -7475,7 +7470,7 @@ char_u *
|
||||
eval_vars (
|
||||
char_u *src, /* pointer into commandline */
|
||||
char_u *srcstart, /* beginning of valid memory for src */
|
||||
int *usedlen, /* characters after src that are used */
|
||||
size_t *usedlen, /* characters after src that are used */
|
||||
linenr_T *lnump, /* line number for :e command, or NULL */
|
||||
char_u **errormsg, /* pointer to error message */
|
||||
int *escaped /* return value has escaped white space (can
|
||||
@@ -7486,10 +7481,9 @@ eval_vars (
|
||||
char_u *s;
|
||||
char_u *result;
|
||||
char_u *resultbuf = NULL;
|
||||
int resultlen;
|
||||
size_t resultlen;
|
||||
buf_T *buf;
|
||||
int valid = VALID_HEAD + VALID_PATH; /* assume valid result */
|
||||
int spec_idx;
|
||||
int skip_mod = FALSE;
|
||||
char_u strbuf[30];
|
||||
|
||||
@@ -7500,7 +7494,7 @@ eval_vars (
|
||||
/*
|
||||
* Check if there is something to do.
|
||||
*/
|
||||
spec_idx = find_cmdline_var(src, usedlen);
|
||||
ssize_t spec_idx = find_cmdline_var(src, usedlen);
|
||||
if (spec_idx < 0) { /* no match */
|
||||
*usedlen = 1;
|
||||
return NULL;
|
||||
@@ -7520,8 +7514,9 @@ eval_vars (
|
||||
* word or WORD under cursor
|
||||
*/
|
||||
if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD) {
|
||||
resultlen = find_ident_under_cursor(&result, spec_idx == SPEC_CWORD ?
|
||||
(FIND_IDENT|FIND_STRING) : FIND_STRING);
|
||||
resultlen = find_ident_under_cursor(&result, (spec_idx == SPEC_CWORD
|
||||
? (FIND_IDENT|FIND_STRING)
|
||||
: FIND_STRING));
|
||||
if (resultlen == 0) {
|
||||
*errormsg = (char_u *)"";
|
||||
return NULL;
|
||||
@@ -7558,7 +7553,7 @@ eval_vars (
|
||||
if (*s == '<') /* "#<99" uses v:oldfiles */
|
||||
++s;
|
||||
i = getdigits_int(&s);
|
||||
*usedlen = (int)(s - src); /* length of what we expand */
|
||||
*usedlen = (size_t)(s - src); /* length of what we expand */
|
||||
|
||||
if (src[1] == '<') {
|
||||
if (*usedlen < 2) {
|
||||
@@ -7657,14 +7652,13 @@ eval_vars (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resultlen = (int)STRLEN(result); /* length of new string */
|
||||
resultlen = STRLEN(result); /* length of new string */
|
||||
if (src[*usedlen] == '<') { /* remove the file name extension */
|
||||
++*usedlen;
|
||||
if ((s = vim_strrchr(result, '.')) != NULL && s >= path_tail(result))
|
||||
resultlen = (int)(s - result);
|
||||
resultlen = (size_t)(s - result);
|
||||
} else if (!skip_mod) {
|
||||
valid |= modify_fname(src, usedlen, &result, &resultbuf,
|
||||
&resultlen);
|
||||
valid |= modify_fname(src, usedlen, &result, &resultbuf, &resultlen);
|
||||
if (result == NULL) {
|
||||
*errormsg = (char_u *)"";
|
||||
return NULL;
|
||||
@@ -7750,11 +7744,11 @@ static char_u *arg_all(void)
|
||||
char_u *expand_sfile(char_u *arg)
|
||||
{
|
||||
char_u *errormsg;
|
||||
int len;
|
||||
size_t len;
|
||||
char_u *result;
|
||||
char_u *newres;
|
||||
char_u *repl;
|
||||
int srclen;
|
||||
size_t srclen;
|
||||
char_u *p;
|
||||
|
||||
result = vim_strsave(arg);
|
||||
@@ -7775,11 +7769,11 @@ char_u *expand_sfile(char_u *arg)
|
||||
p += srclen;
|
||||
continue;
|
||||
}
|
||||
len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1;
|
||||
len = STRLEN(result) - srclen + STRLEN(repl) + 1;
|
||||
newres = xmalloc(len);
|
||||
memmove(newres, result, (size_t)(p - result));
|
||||
STRCPY(newres + (p - result), repl);
|
||||
len = (int)STRLEN(newres);
|
||||
len = STRLEN(newres);
|
||||
STRCAT(newres, p + srclen);
|
||||
xfree(repl);
|
||||
xfree(result);
|
||||
|
@@ -1310,14 +1310,16 @@ static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
|
||||
char_u *
|
||||
find_file_in_path (
|
||||
char_u *ptr, /* file name */
|
||||
int len, /* length of file name */
|
||||
size_t len, /* length of file name */
|
||||
int options,
|
||||
int first, /* use count'th matching file name */
|
||||
char_u *rel_fname /* file name searching relative to */
|
||||
)
|
||||
{
|
||||
return find_file_in_path_option(ptr, len, options, first,
|
||||
*curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path,
|
||||
(*curbuf->b_p_path == NUL
|
||||
? p_path
|
||||
: curbuf->b_p_path),
|
||||
FINDFILE_BOTH, rel_fname, curbuf->b_p_sua);
|
||||
}
|
||||
|
||||
@@ -1347,7 +1349,7 @@ void free_findfile(void)
|
||||
char_u *
|
||||
find_directory_in_path (
|
||||
char_u *ptr, /* file name */
|
||||
int len, /* length of file name */
|
||||
size_t len, /* length of file name */
|
||||
int options,
|
||||
char_u *rel_fname /* file name searching relative to */
|
||||
)
|
||||
@@ -1359,7 +1361,7 @@ find_directory_in_path (
|
||||
char_u *
|
||||
find_file_in_path_option (
|
||||
char_u *ptr, /* file name */
|
||||
int len, /* length of file name */
|
||||
size_t len, /* length of file name */
|
||||
int options,
|
||||
int first, /* use count'th matching file name */
|
||||
char_u *path_option, /* p_path or p_cdpath */
|
||||
|
@@ -802,7 +802,7 @@ EXTERN int State INIT(= NORMAL); /* This is the current state of the
|
||||
* command interpreter. */
|
||||
|
||||
EXTERN int finish_op INIT(= FALSE); /* TRUE while an operator is pending */
|
||||
EXTERN int opcount INIT(= 0); /* count for pending operator */
|
||||
EXTERN long opcount INIT(= 0); /* count for pending operator */
|
||||
|
||||
/*
|
||||
* ex mode (Q) state
|
||||
|
@@ -455,18 +455,16 @@ cs_add_common (
|
||||
char *fname2 = NULL;
|
||||
char *ppath = NULL;
|
||||
int i;
|
||||
int len;
|
||||
int usedlen = 0;
|
||||
size_t usedlen = 0;
|
||||
char_u *fbuf = NULL;
|
||||
|
||||
/* get the filename (arg1), expand it, and try to stat it */
|
||||
fname = xmalloc(MAXPATHL + 1);
|
||||
|
||||
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
|
||||
len = (int)STRLEN(fname);
|
||||
size_t len = STRLEN(fname);
|
||||
fbuf = (char_u *)fname;
|
||||
(void)modify_fname((char_u *)":p", &usedlen,
|
||||
(char_u **)&fname, &fbuf, &len);
|
||||
(void)modify_fname((char_u *)":p", &usedlen, (char_u **)&fname, &fbuf, &len);
|
||||
if (fname == NULL)
|
||||
goto add_err;
|
||||
fname = (char *)vim_strnsave((char_u *)fname, len);
|
||||
|
@@ -382,7 +382,7 @@ int vim_chdir(char_u *new_dir)
|
||||
char_u *dir_name;
|
||||
int r;
|
||||
|
||||
dir_name = find_directory_in_path(new_dir, (int)STRLEN(new_dir),
|
||||
dir_name = find_directory_in_path(new_dir, STRLEN(new_dir),
|
||||
FNAME_MESS, curbuf->b_ffname);
|
||||
if (dir_name == NULL)
|
||||
return -1;
|
||||
|
@@ -350,19 +350,23 @@ static int nv_compare(const void *s1, const void *s2)
|
||||
*/
|
||||
void init_normal_cmds(void)
|
||||
{
|
||||
int i;
|
||||
assert(NV_CMDS_SIZE <= SHRT_MAX);
|
||||
|
||||
/* Fill the index table with a one to one relation. */
|
||||
for (i = 0; i < (int)NV_CMDS_SIZE; ++i)
|
||||
for (short int i = 0; i < (short int)NV_CMDS_SIZE; ++i) {
|
||||
nv_cmd_idx[i] = i;
|
||||
}
|
||||
|
||||
/* Sort the commands by the command character. */
|
||||
qsort((void *)&nv_cmd_idx, (size_t)NV_CMDS_SIZE, sizeof(short), nv_compare);
|
||||
qsort(&nv_cmd_idx, NV_CMDS_SIZE, sizeof(short), nv_compare);
|
||||
|
||||
/* Find the first entry that can't be indexed by the command character. */
|
||||
for (i = 0; i < (int)NV_CMDS_SIZE; ++i)
|
||||
if (i != nv_cmds[nv_cmd_idx[i]].cmd_char)
|
||||
short int i;
|
||||
for (i = 0; i < (short int)NV_CMDS_SIZE; ++i) {
|
||||
if (i != nv_cmds[nv_cmd_idx[i]].cmd_char) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
nv_max_linear = i - 1;
|
||||
}
|
||||
|
||||
@@ -1846,7 +1850,7 @@ do_mouse (
|
||||
static pos_T orig_cursor;
|
||||
colnr_T leftcol, rightcol;
|
||||
pos_T end_visual;
|
||||
int diff;
|
||||
long diff;
|
||||
int old_active = VIsual_active;
|
||||
int old_mode = VIsual_mode;
|
||||
int regname;
|
||||
@@ -2589,7 +2593,7 @@ void reset_VIsual(void)
|
||||
* If a string is found, a pointer to the string is put in "*string". This
|
||||
* string is not always NUL terminated.
|
||||
*/
|
||||
int find_ident_under_cursor(char_u **string, int find_type)
|
||||
size_t find_ident_under_cursor(char_u **string, int find_type)
|
||||
{
|
||||
return find_ident_at_pos(curwin, curwin->w_cursor.lnum,
|
||||
curwin->w_cursor.col, string, find_type);
|
||||
@@ -2599,7 +2603,8 @@ int find_ident_under_cursor(char_u **string, int find_type)
|
||||
* Like find_ident_under_cursor(), but for any window and any position.
|
||||
* However: Uses 'iskeyword' from the current window!.
|
||||
*/
|
||||
int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **string, int find_type)
|
||||
size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol,
|
||||
char_u **string, int find_type)
|
||||
{
|
||||
char_u *ptr;
|
||||
int col = 0; /* init to shut up GCC */
|
||||
@@ -2707,7 +2712,8 @@ int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **strin
|
||||
++col;
|
||||
}
|
||||
|
||||
return col;
|
||||
assert(col >= 0);
|
||||
return (size_t)col;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2899,9 +2905,6 @@ void clear_showcmd(void)
|
||||
bool add_to_showcmd(int c)
|
||||
{
|
||||
char_u *p;
|
||||
int old_len;
|
||||
int extra_len;
|
||||
int overflow;
|
||||
int i;
|
||||
static int ignore[] =
|
||||
{
|
||||
@@ -2932,12 +2935,12 @@ bool add_to_showcmd(int c)
|
||||
p = transchar(c);
|
||||
if (*p == ' ')
|
||||
STRCPY(p, "<20>");
|
||||
old_len = (int)STRLEN(showcmd_buf);
|
||||
extra_len = (int)STRLEN(p);
|
||||
overflow = old_len + extra_len - SHOWCMD_COLS;
|
||||
if (overflow > 0)
|
||||
memmove(showcmd_buf, showcmd_buf + overflow,
|
||||
old_len - overflow + 1);
|
||||
size_t old_len = STRLEN(showcmd_buf);
|
||||
size_t extra_len = STRLEN(p);
|
||||
if (old_len + extra_len > SHOWCMD_COLS) {
|
||||
size_t overflow = old_len + extra_len - SHOWCMD_COLS;
|
||||
memmove(showcmd_buf, showcmd_buf + overflow, old_len - overflow + 1);
|
||||
}
|
||||
STRCAT(showcmd_buf, p);
|
||||
|
||||
if (char_avail())
|
||||
@@ -3220,11 +3223,10 @@ nv_gd (
|
||||
int thisblock /* 1 for "1gd" and "1gD" */
|
||||
)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
char_u *ptr;
|
||||
|
||||
if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0
|
||||
|| find_decl(ptr, len, nchar == 'd', thisblock, 0) == false)
|
||||
|| !find_decl(ptr, len, nchar == 'd', thisblock, 0))
|
||||
clearopbeep(oap);
|
||||
else if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
|
||||
foldOpenCursor();
|
||||
@@ -3240,7 +3242,7 @@ nv_gd (
|
||||
bool
|
||||
find_decl (
|
||||
char_u *ptr,
|
||||
int len,
|
||||
size_t len,
|
||||
bool locally,
|
||||
bool thisblock,
|
||||
int searchflags /* flags passed to searchit() */
|
||||
@@ -3260,8 +3262,9 @@ find_decl (
|
||||
|
||||
/* Put "\V" before the pattern to avoid that the special meaning of "."
|
||||
* and "~" causes trouble. */
|
||||
assert(len <= INT_MAX);
|
||||
sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s",
|
||||
len, ptr);
|
||||
(int)len, ptr);
|
||||
old_pos = curwin->w_cursor;
|
||||
save_p_ws = p_ws;
|
||||
save_p_scs = p_scs;
|
||||
@@ -3586,13 +3589,16 @@ void scroll_redraw(int up, long count)
|
||||
*/
|
||||
static void nv_zet(cmdarg_T *cap)
|
||||
{
|
||||
long n;
|
||||
int n;
|
||||
colnr_T col;
|
||||
int nchar = cap->nchar;
|
||||
long old_fdl = curwin->w_p_fdl;
|
||||
int old_fen = curwin->w_p_fen;
|
||||
bool undo = false;
|
||||
|
||||
assert(p_siso <= INT_MAX);
|
||||
int l_p_siso = (int)p_siso;
|
||||
|
||||
if (ascii_isdigit(nchar)) {
|
||||
/*
|
||||
* "z123{nchar}": edit the count before obtaining {nchar}
|
||||
@@ -3613,7 +3619,7 @@ static void nv_zet(cmdarg_T *cap)
|
||||
else if (ascii_isdigit(nchar))
|
||||
n = n * 10 + (nchar - '0');
|
||||
else if (nchar == CAR) {
|
||||
win_setheight((int)n);
|
||||
win_setheight(n);
|
||||
break;
|
||||
} else if (nchar == 'l'
|
||||
|| nchar == 'h'
|
||||
@@ -3744,8 +3750,8 @@ dozet:
|
||||
col = 0; /* like the cursor is in col 0 */
|
||||
else
|
||||
getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL);
|
||||
if ((long)col > p_siso)
|
||||
col -= p_siso;
|
||||
if (col > l_p_siso)
|
||||
col -= l_p_siso;
|
||||
else
|
||||
col = 0;
|
||||
if (curwin->w_leftcol != col) {
|
||||
@@ -3762,10 +3768,10 @@ dozet:
|
||||
else
|
||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
||||
n = curwin->w_width - curwin_col_off();
|
||||
if ((long)col + p_siso < n)
|
||||
if (col + l_p_siso < n)
|
||||
col = 0;
|
||||
else
|
||||
col = col + p_siso - n + 1;
|
||||
col = col + l_p_siso - n + 1;
|
||||
if (curwin->w_leftcol != col) {
|
||||
curwin->w_leftcol = col;
|
||||
redraw_later(NOT_VALID);
|
||||
@@ -3941,12 +3947,11 @@ dozet:
|
||||
case 'W': /* "zW": add wrong word to temp word list */
|
||||
{
|
||||
char_u *ptr = NULL;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (checkclearop(cap->oap))
|
||||
break;
|
||||
if (VIsual_active && get_visual_text(cap, &ptr, &len)
|
||||
== false)
|
||||
if (VIsual_active && !get_visual_text(cap, &ptr, &len))
|
||||
return;
|
||||
if (ptr == NULL) {
|
||||
pos_T pos = curwin->w_cursor;
|
||||
@@ -3962,12 +3967,11 @@ dozet:
|
||||
curwin->w_cursor = pos;
|
||||
}
|
||||
|
||||
if (ptr == NULL && (len = find_ident_under_cursor(&ptr,
|
||||
FIND_IDENT)) == 0)
|
||||
if (ptr == NULL && (len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0)
|
||||
return;
|
||||
spell_add_word(ptr, len, nchar == 'w' || nchar == 'W',
|
||||
(nchar == 'G' || nchar == 'W')
|
||||
? 0 : (int)cap->count1,
|
||||
assert(len <= INT_MAX);
|
||||
spell_add_word(ptr, (int)len, nchar == 'w' || nchar == 'W',
|
||||
(nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1,
|
||||
undo);
|
||||
}
|
||||
break;
|
||||
@@ -4187,7 +4191,7 @@ static void nv_ident(cmdarg_T *cap)
|
||||
char_u *p;
|
||||
char_u *kp; /* value of 'keywordprg' */
|
||||
bool kp_help; /* 'keywordprg' is ":help" */
|
||||
int n = 0; /* init for GCC */
|
||||
size_t n = 0; /* init for GCC */
|
||||
int cmdchar;
|
||||
bool g_cmd; /* "g" command */
|
||||
bool tag_cmd = false;
|
||||
@@ -4217,8 +4221,10 @@ static void nv_ident(cmdarg_T *cap)
|
||||
}
|
||||
|
||||
if (ptr == NULL && (n = find_ident_under_cursor(&ptr,
|
||||
(cmdchar == '*' || cmdchar == '#')
|
||||
? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0) {
|
||||
((cmdchar == '*'
|
||||
|| cmdchar == '#')
|
||||
? FIND_IDENT|FIND_STRING
|
||||
: FIND_IDENT))) == 0) {
|
||||
clearop(cap->oap);
|
||||
return;
|
||||
}
|
||||
@@ -4339,10 +4345,8 @@ static void nv_ident(cmdarg_T *cap)
|
||||
/* When current byte is a part of multibyte character, copy all
|
||||
* bytes of that character. */
|
||||
if (has_mbyte) {
|
||||
int i;
|
||||
int len = (*mb_ptr2len)(ptr) - 1;
|
||||
|
||||
for (i = 0; i < len && n >= 1; ++i, --n)
|
||||
size_t len = (size_t)((*mb_ptr2len)(ptr) - 1);
|
||||
for (size_t i = 0; i < len && n > 0; ++i, --n)
|
||||
*p++ = *ptr++;
|
||||
}
|
||||
*p++ = *ptr++;
|
||||
@@ -4376,7 +4380,7 @@ bool
|
||||
get_visual_text (
|
||||
cmdarg_T *cap,
|
||||
char_u **pp, /* return: start of selected text */
|
||||
int *lenp /* return: length of selected text */
|
||||
size_t *lenp /* return: length of selected text */
|
||||
)
|
||||
{
|
||||
if (VIsual_mode != 'V')
|
||||
@@ -4388,18 +4392,18 @@ get_visual_text (
|
||||
}
|
||||
if (VIsual_mode == 'V') {
|
||||
*pp = get_cursor_line_ptr();
|
||||
*lenp = (int)STRLEN(*pp);
|
||||
*lenp = STRLEN(*pp);
|
||||
} else {
|
||||
if (lt(curwin->w_cursor, VIsual)) {
|
||||
*pp = ml_get_pos(&curwin->w_cursor);
|
||||
*lenp = VIsual.col - curwin->w_cursor.col + 1;
|
||||
*lenp = (size_t)(VIsual.col - curwin->w_cursor.col + 1);
|
||||
} else {
|
||||
*pp = ml_get_pos(&VIsual);
|
||||
*lenp = curwin->w_cursor.col - VIsual.col + 1;
|
||||
*lenp = (size_t)(curwin->w_cursor.col - VIsual.col + 1);
|
||||
}
|
||||
if (has_mbyte)
|
||||
/* Correct the length to include the whole last character. */
|
||||
*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
|
||||
*lenp += (size_t)((*mb_ptr2len)(*pp + (*lenp - 1)) - 1);
|
||||
}
|
||||
reset_VIsual_and_resel();
|
||||
return true;
|
||||
@@ -4919,19 +4923,24 @@ static void nv_brackets(cmdarg_T *cap)
|
||||
"iI\011dD\004",
|
||||
cap->nchar) != NULL) {
|
||||
char_u *ptr;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0)
|
||||
clearop(cap->oap);
|
||||
else {
|
||||
find_pattern_in_path(ptr, 0, len, true,
|
||||
cap->count0 == 0 ? !isupper(cap->nchar) : false,
|
||||
((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY,
|
||||
(((cap->nchar & 0xf) == ('d' & 0xf))
|
||||
? FIND_DEFINE
|
||||
: FIND_ANY),
|
||||
cap->count1,
|
||||
isupper(cap->nchar) ? ACTION_SHOW_ALL :
|
||||
islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO,
|
||||
cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1,
|
||||
(linenr_T)MAXLNUM);
|
||||
(isupper(cap->nchar) ? ACTION_SHOW_ALL :
|
||||
islower(cap->nchar) ? ACTION_SHOW :
|
||||
ACTION_GOTO),
|
||||
(cap->cmdchar == ']'
|
||||
? curwin->w_cursor.lnum + 1
|
||||
: (linenr_T)1),
|
||||
MAXLNUM);
|
||||
curwin->w_set_curswant = true;
|
||||
}
|
||||
} else
|
||||
@@ -5076,7 +5085,7 @@ static void nv_brackets(cmdarg_T *cap)
|
||||
int dir = (cap->cmdchar == ']' && cap->nchar == 'p') ? FORWARD : BACKWARD;
|
||||
int regname = cap->oap->regname;
|
||||
int was_visual = VIsual_active;
|
||||
int line_count = curbuf->b_ml.ml_line_count;
|
||||
linenr_T line_count = curbuf->b_ml.ml_line_count;
|
||||
pos_T start, end;
|
||||
|
||||
if (VIsual_active) {
|
||||
@@ -5159,7 +5168,7 @@ static void nv_brackets(cmdarg_T *cap)
|
||||
setpcmark();
|
||||
for (n = 0; n < cap->count1; ++n)
|
||||
if (spell_move_to(curwin, cap->cmdchar == ']' ? FORWARD : BACKWARD,
|
||||
cap->nchar == 's' ? true : false, false, NULL) == 0) {
|
||||
cap->nchar == 's', false, NULL) == 0) {
|
||||
clearopbeep(cap->oap);
|
||||
break;
|
||||
}
|
||||
@@ -5347,7 +5356,8 @@ static void nv_replace(cmdarg_T *cap)
|
||||
if (gchar_cursor() == NUL) {
|
||||
/* Add extra space and put the cursor on the first one. */
|
||||
coladvance_force((colnr_T)(getviscol() + cap->count1));
|
||||
curwin->w_cursor.col -= cap->count1;
|
||||
assert(cap->count1 <= INT_MAX);
|
||||
curwin->w_cursor.col -= (colnr_T)cap->count1;
|
||||
} else if (gchar_cursor() == TAB)
|
||||
coladvance_force(getviscol());
|
||||
}
|
||||
@@ -5444,9 +5454,11 @@ static void nv_replace(cmdarg_T *cap)
|
||||
int c = ins_copychar(curwin->w_cursor.lnum
|
||||
+ (cap->nchar == Ctrl_Y ? -1 : 1));
|
||||
if (c != NUL)
|
||||
ptr[curwin->w_cursor.col] = c;
|
||||
assert(c >= 0 && c <= UCHAR_MAX);
|
||||
ptr[curwin->w_cursor.col] = (char_u)c;
|
||||
} else
|
||||
ptr[curwin->w_cursor.col] = cap->nchar;
|
||||
assert(cap->nchar >= 0 && cap->nchar <= UCHAR_MAX);
|
||||
ptr[curwin->w_cursor.col] = (char_u)cap->nchar;
|
||||
if (p_sm && msg_silent == 0)
|
||||
showmatch(cap->nchar);
|
||||
++curwin->w_cursor.col;
|
||||
@@ -5867,8 +5879,9 @@ static void nv_visual(cmdarg_T *cap)
|
||||
if (VIsual_mode == 'v') {
|
||||
if (resel_VIsual_line_count <= 1) {
|
||||
validate_virtcol();
|
||||
curwin->w_curswant = curwin->w_virtcol
|
||||
+ resel_VIsual_vcol * cap->count0 - 1;
|
||||
assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX);
|
||||
curwin->w_curswant = (curwin->w_virtcol
|
||||
+ resel_VIsual_vcol * (int)cap->count0 - 1);
|
||||
} else
|
||||
curwin->w_curswant = resel_VIsual_vcol;
|
||||
coladvance(curwin->w_curswant);
|
||||
@@ -5878,8 +5891,9 @@ static void nv_visual(cmdarg_T *cap)
|
||||
coladvance((colnr_T)MAXCOL);
|
||||
} else if (VIsual_mode == Ctrl_V) {
|
||||
validate_virtcol();
|
||||
curwin->w_curswant = curwin->w_virtcol
|
||||
+ resel_VIsual_vcol * cap->count0 - 1;
|
||||
assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX);
|
||||
curwin->w_curswant = (curwin->w_virtcol
|
||||
+ resel_VIsual_vcol * (int)cap->count0 - 1);
|
||||
coladvance(curwin->w_curswant);
|
||||
} else
|
||||
curwin->w_set_curswant = true;
|
||||
@@ -6609,8 +6623,14 @@ static void set_op_var(int optype)
|
||||
if (optype == OP_NOP)
|
||||
set_vim_var_string(VV_OP, NULL, 0);
|
||||
else {
|
||||
opchars[0] = get_op_char(optype);
|
||||
opchars[1] = get_extra_op_char(optype);
|
||||
int opchar0 = get_op_char(optype);
|
||||
assert(opchar0 >= 0 && opchar0 <= UCHAR_MAX);
|
||||
opchars[0] = (char_u)opchar0;
|
||||
|
||||
int opchar1 = get_extra_op_char(optype);
|
||||
assert(opchar1 >= 0 && opchar1 <= UCHAR_MAX);
|
||||
opchars[1] = (char_u)opchar1;
|
||||
|
||||
opchars[2] = NUL;
|
||||
set_vim_var_string(VV_OP, opchars, -1);
|
||||
}
|
||||
|
@@ -1189,7 +1189,7 @@ get_spec_reg (
|
||||
int errmsg /* give error message when failing */
|
||||
)
|
||||
{
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
|
||||
*argp = NULL;
|
||||
*allocated = FALSE;
|
||||
@@ -1241,8 +1241,9 @@ get_spec_reg (
|
||||
case Ctrl_A: /* WORD (mnemonic All) under cursor */
|
||||
if (!errmsg)
|
||||
return FALSE;
|
||||
cnt = find_ident_under_cursor(argp, regname == Ctrl_W
|
||||
? (FIND_IDENT|FIND_STRING) : FIND_STRING);
|
||||
cnt = find_ident_under_cursor(argp, (regname == Ctrl_W
|
||||
? (FIND_IDENT|FIND_STRING)
|
||||
: FIND_STRING));
|
||||
*argp = cnt ? vim_strnsave(*argp, cnt) : NULL;
|
||||
*allocated = TRUE;
|
||||
return TRUE;
|
||||
|
@@ -561,14 +561,11 @@ void home_replace(buf_T *buf, char_u *src, char_u *dst, int dstlen, bool one)
|
||||
homedir_env = NULL;
|
||||
|
||||
if (homedir_env != NULL && vim_strchr(homedir_env, '~') != NULL) {
|
||||
int usedlen = 0;
|
||||
int flen;
|
||||
size_t usedlen = 0;
|
||||
size_t flen = STRLEN(homedir_env);
|
||||
char_u *fbuf = NULL;
|
||||
|
||||
flen = (int)STRLEN(homedir_env);
|
||||
(void)modify_fname((char_u *)":p", &usedlen,
|
||||
&homedir_env, &fbuf, &flen);
|
||||
flen = (int)STRLEN(homedir_env);
|
||||
(void)modify_fname((char_u *)":p", &usedlen, &homedir_env, &fbuf, &flen);
|
||||
flen = STRLEN(homedir_env);
|
||||
if (flen > 0 && vim_ispathsep(homedir_env[flen - 1]))
|
||||
/* Remove the trailing / that is added to a directory. */
|
||||
homedir_env[flen - 1] = NUL;
|
||||
|
@@ -1445,13 +1445,13 @@ void simplify_filename(char_u *filename)
|
||||
} while (*p != NUL);
|
||||
}
|
||||
|
||||
static char_u *eval_includeexpr(char_u *ptr, int len)
|
||||
static char_u *eval_includeexpr(char_u *ptr, size_t len)
|
||||
{
|
||||
char_u *res;
|
||||
|
||||
set_vim_var_string(VV_FNAME, ptr, len);
|
||||
res = eval_to_string_safe(curbuf->b_p_inex, NULL,
|
||||
was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL));
|
||||
assert(len <= INT_MAX);
|
||||
set_vim_var_string(VV_FNAME, ptr, (int)len);
|
||||
char_u *res = eval_to_string_safe(curbuf->b_p_inex, NULL,
|
||||
was_set_insecurely((char_u *)"includeexpr",
|
||||
OPT_LOCAL));
|
||||
set_vim_var_string(VV_FNAME, NULL, 0);
|
||||
return res;
|
||||
}
|
||||
@@ -1463,7 +1463,7 @@ static char_u *eval_includeexpr(char_u *ptr, int len)
|
||||
char_u *
|
||||
find_file_name_in_path (
|
||||
char_u *ptr,
|
||||
int len,
|
||||
size_t len,
|
||||
int options,
|
||||
long count,
|
||||
char_u *rel_fname /* file we are searching relative to */
|
||||
@@ -1477,7 +1477,7 @@ find_file_name_in_path (
|
||||
tofree = eval_includeexpr(ptr, len);
|
||||
if (tofree != NULL) {
|
||||
ptr = tofree;
|
||||
len = (int)STRLEN(ptr);
|
||||
len = STRLEN(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1494,7 +1494,7 @@ find_file_name_in_path (
|
||||
tofree = eval_includeexpr(ptr, len);
|
||||
if (tofree != NULL) {
|
||||
ptr = tofree;
|
||||
len = (int)STRLEN(ptr);
|
||||
len = STRLEN(ptr);
|
||||
file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
|
||||
TRUE, rel_fname);
|
||||
}
|
||||
@@ -1839,7 +1839,7 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
|
||||
char_u *eval_pat = NULL;
|
||||
char_u *exp_pat = *pat;
|
||||
char_u *ignored_msg;
|
||||
int usedlen;
|
||||
size_t usedlen;
|
||||
|
||||
if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<') {
|
||||
++emsg_off;
|
||||
|
@@ -2465,7 +2465,7 @@ win_line (
|
||||
/* When spell checking a word we need to figure out the start of the
|
||||
* word and if it's badly spelled or not. */
|
||||
if (has_spell) {
|
||||
int len;
|
||||
size_t len;
|
||||
colnr_T linecol = (colnr_T)(ptr - line);
|
||||
hlf_T spell_hlf = HLF_COUNT;
|
||||
|
||||
@@ -2485,7 +2485,8 @@ win_line (
|
||||
word_end = (int)(spell_to_word_end(ptr, wp) - line + 1);
|
||||
} else {
|
||||
/* bad word found, use attributes until end of word */
|
||||
word_end = wp->w_cursor.col + len + 1;
|
||||
assert(len <= INT_MAX);
|
||||
word_end = wp->w_cursor.col + (int)len + 1;
|
||||
|
||||
/* Turn index into actual attributes. */
|
||||
if (spell_hlf != HLF_COUNT)
|
||||
@@ -3252,8 +3253,9 @@ win_line (
|
||||
else
|
||||
p = prev_ptr;
|
||||
cap_col -= (int)(prev_ptr - line);
|
||||
len = spell_check(wp, p, &spell_hlf, &cap_col,
|
||||
nochange);
|
||||
size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, nochange);
|
||||
assert(tmplen <= INT_MAX);
|
||||
len = (int)tmplen;
|
||||
word_end = v + len;
|
||||
|
||||
/* In Insert mode only highlight a word that
|
||||
|
@@ -3947,7 +3947,7 @@ void
|
||||
find_pattern_in_path (
|
||||
char_u *ptr, /* pointer to search pattern */
|
||||
int dir, /* direction of expansion */
|
||||
int len, /* length of search pattern */
|
||||
size_t len, /* length of search pattern */
|
||||
int whole, /* match whole words only */
|
||||
int skip_comments, /* don't match inside comments */
|
||||
int type, /* Type of search; are we looking for a type?
|
||||
@@ -4002,7 +4002,8 @@ find_pattern_in_path (
|
||||
&& !(compl_cont_status & CONT_SOL)
|
||||
) {
|
||||
pat = xmalloc(len + 5);
|
||||
sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr);
|
||||
assert(len <= INT_MAX);
|
||||
sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", (int)len, ptr);
|
||||
/* ignore case according to p_ic, p_scs and pat */
|
||||
regmatch.rm_ic = ignorecase(pat);
|
||||
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
|
||||
@@ -4044,8 +4045,10 @@ find_pattern_in_path (
|
||||
if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL)
|
||||
/* Use text from '\zs' to '\ze' (or end) of 'include'. */
|
||||
new_fname = find_file_name_in_path(incl_regmatch.startp[0],
|
||||
(int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]),
|
||||
FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname);
|
||||
(size_t)(incl_regmatch.endp[0]
|
||||
- incl_regmatch.startp[0]),
|
||||
FNAME_EXP|FNAME_INCL|FNAME_REL,
|
||||
1L, p_fname);
|
||||
else
|
||||
/* Use text after match with 'include'. */
|
||||
new_fname = file_name_in_line(incl_regmatch.endp[0], 0,
|
||||
@@ -4235,8 +4238,7 @@ search_line:
|
||||
/* compare the first "len" chars from "ptr" */
|
||||
startp = skipwhite(p);
|
||||
if (p_ic) {
|
||||
assert(len >= 0);
|
||||
matched = !mb_strnicmp(startp, ptr, (size_t)len);
|
||||
matched = !mb_strnicmp(startp, ptr, len);
|
||||
}
|
||||
else
|
||||
matched = !STRNCMP(startp, ptr, len);
|
||||
|
@@ -1070,7 +1070,7 @@ static char_u *repl_to = NULL;
|
||||
//
|
||||
// Returns the length of the word in bytes, also when it's OK, so that the
|
||||
// caller can skip over the word.
|
||||
int
|
||||
size_t
|
||||
spell_check (
|
||||
win_T *wp, // current window
|
||||
char_u *ptr,
|
||||
@@ -1081,9 +1081,9 @@ spell_check (
|
||||
{
|
||||
matchinf_T mi; // Most things are put in "mi" so that it can
|
||||
// be passed to functions quickly.
|
||||
int nrlen = 0; // found a number first
|
||||
size_t nrlen = 0; // found a number first
|
||||
int c;
|
||||
int wrongcaplen = 0;
|
||||
size_t wrongcaplen = 0;
|
||||
int lpi;
|
||||
bool count_word = docount;
|
||||
|
||||
@@ -1106,7 +1106,7 @@ spell_check (
|
||||
mi.mi_end = skiphex(ptr + 2);
|
||||
else
|
||||
mi.mi_end = skipdigits(ptr);
|
||||
nrlen = (int)(mi.mi_end - ptr);
|
||||
nrlen = (size_t)(mi.mi_end - ptr);
|
||||
}
|
||||
|
||||
// Find the normal end of the word (until the next non-word character).
|
||||
@@ -1121,7 +1121,7 @@ spell_check (
|
||||
// Check word starting with capital letter.
|
||||
c = PTR2CHAR(ptr);
|
||||
if (!SPELL_ISUPPER(c))
|
||||
wrongcaplen = (int)(mi.mi_fend - ptr);
|
||||
wrongcaplen = (size_t)(mi.mi_fend - ptr);
|
||||
}
|
||||
}
|
||||
if (capcol != NULL)
|
||||
@@ -1141,8 +1141,7 @@ spell_check (
|
||||
if (*mi.mi_fend != NUL)
|
||||
mb_ptr_adv(mi.mi_fend);
|
||||
|
||||
(void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
|
||||
MAXWLEN + 1);
|
||||
(void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1);
|
||||
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
|
||||
|
||||
// The word is bad unless we recognize it.
|
||||
@@ -1209,7 +1208,7 @@ spell_check (
|
||||
}
|
||||
|
||||
if (has_mbyte) {
|
||||
return (*mb_ptr2len)(ptr);
|
||||
return (size_t)(*mb_ptr2len)(ptr);
|
||||
}
|
||||
return 1;
|
||||
} else if (mi.mi_end == ptr)
|
||||
@@ -1257,7 +1256,7 @@ spell_check (
|
||||
return wrongcaplen;
|
||||
}
|
||||
|
||||
return (int)(mi.mi_end - ptr);
|
||||
return (size_t)(mi.mi_end - ptr);
|
||||
}
|
||||
|
||||
// Check if the word at "mip->mi_word" is in the tree.
|
||||
@@ -2046,7 +2045,7 @@ static bool no_spell_checking(win_T *wp)
|
||||
// For Insert mode completion "dir" is BACKWARD and "curline" is true: move
|
||||
// to after badly spelled word before the cursor.
|
||||
// Return 0 if not found, length of the badly spelled word otherwise.
|
||||
int
|
||||
size_t
|
||||
spell_move_to (
|
||||
win_T *wp,
|
||||
int dir, // FORWARD or BACKWARD
|
||||
@@ -2058,17 +2057,17 @@ spell_move_to (
|
||||
{
|
||||
linenr_T lnum;
|
||||
pos_T found_pos;
|
||||
int found_len = 0;
|
||||
size_t found_len = 0;
|
||||
char_u *line;
|
||||
char_u *p;
|
||||
char_u *endp;
|
||||
hlf_T attr = HLF_COUNT;
|
||||
int len;
|
||||
size_t len;
|
||||
int has_syntax = syntax_present(wp);
|
||||
int col;
|
||||
bool can_spell;
|
||||
char_u *buf = NULL;
|
||||
int buflen = 0;
|
||||
size_t buflen = 0;
|
||||
int skip = 0;
|
||||
int capcol = -1;
|
||||
bool found_one = false;
|
||||
@@ -2092,7 +2091,7 @@ spell_move_to (
|
||||
while (!got_int) {
|
||||
line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
||||
|
||||
len = (int)STRLEN(line);
|
||||
len = STRLEN(line);
|
||||
if (buflen < len + MAXWLEN + 2) {
|
||||
xfree(buf);
|
||||
buflen = len + MAXWLEN + 2;
|
||||
@@ -2123,8 +2122,8 @@ spell_move_to (
|
||||
STRCPY(buf, line);
|
||||
if (lnum < wp->w_buffer->b_ml.ml_line_count)
|
||||
spell_cat_line(buf + STRLEN(buf),
|
||||
ml_get_buf(wp->w_buffer, lnum + 1, FALSE), MAXWLEN);
|
||||
|
||||
ml_get_buf(wp->w_buffer, lnum + 1, FALSE),
|
||||
MAXWLEN);
|
||||
p = buf + skip;
|
||||
endp = buf + len;
|
||||
while (p < endp) {
|
||||
@@ -2149,9 +2148,10 @@ spell_move_to (
|
||||
|| lnum != wp->w_cursor.lnum
|
||||
|| (lnum == wp->w_cursor.lnum
|
||||
&& (wrapped
|
||||
|| (colnr_T)(curline ? p - buf + len
|
||||
|| ((colnr_T)(curline
|
||||
? p - buf + (ptrdiff_t)len
|
||||
: p - buf)
|
||||
> wp->w_cursor.col))) {
|
||||
> wp->w_cursor.col)))) {
|
||||
if (has_syntax) {
|
||||
col = (int)(p - buf);
|
||||
(void)syn_get_id(wp, lnum, (colnr_T)col,
|
||||
@@ -2176,7 +2176,8 @@ spell_move_to (
|
||||
} else if (curline)
|
||||
// Insert mode completion: put cursor after
|
||||
// the bad word.
|
||||
found_pos.col += len;
|
||||
assert(len <= INT_MAX);
|
||||
found_pos.col += (int)len;
|
||||
found_len = len;
|
||||
}
|
||||
} else
|
||||
@@ -2186,7 +2187,8 @@ spell_move_to (
|
||||
|
||||
// advance to character after the word
|
||||
p += len;
|
||||
capcol -= len;
|
||||
assert(len <= INT_MAX);
|
||||
capcol -= (int)len;
|
||||
}
|
||||
|
||||
if (dir == BACKWARD && found_pos.lnum != 0) {
|
||||
@@ -8770,8 +8772,11 @@ spell_find_suggest (
|
||||
su->su_badptr = badptr;
|
||||
if (badlen != 0)
|
||||
su->su_badlen = badlen;
|
||||
else
|
||||
su->su_badlen = spell_check(curwin, su->su_badptr, &attr, NULL, false);
|
||||
else {
|
||||
size_t tmplen = spell_check(curwin, su->su_badptr, &attr, NULL, false);
|
||||
assert(tmplen <= INT_MAX);
|
||||
su->su_badlen = (int)tmplen;
|
||||
}
|
||||
su->su_maxcount = maxcount;
|
||||
su->su_maxscore = SCORE_MAXINIT;
|
||||
|
||||
|
@@ -137,7 +137,7 @@ char_u *vim_strsave_shellescape(const char_u *string,
|
||||
{
|
||||
char_u *d;
|
||||
char_u *escaped_string;
|
||||
int l;
|
||||
size_t l;
|
||||
int csh_like;
|
||||
|
||||
/* Only csh and similar shells expand '!' within single quotes. For sh and
|
||||
@@ -189,7 +189,7 @@ char_u *vim_strsave_shellescape(const char_u *string,
|
||||
}
|
||||
if (do_special && find_cmdline_var(p, &l) >= 0) {
|
||||
*d++ = '\\'; /* insert backslash */
|
||||
while (--l >= 0) /* copy the var */
|
||||
while (--l != SIZE_MAX) /* copy the var */
|
||||
*d++ = *p++;
|
||||
continue;
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ do_window (
|
||||
char_u *ptr;
|
||||
linenr_T lnum = -1;
|
||||
int type = FIND_DEFINE;
|
||||
int len;
|
||||
size_t len;
|
||||
char_u cbuf[40];
|
||||
|
||||
if (Prenum == 0)
|
||||
@@ -418,8 +418,8 @@ wingotofile:
|
||||
if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0)
|
||||
break;
|
||||
find_pattern_in_path(ptr, 0, len, TRUE,
|
||||
Prenum == 0 ? TRUE : FALSE, type,
|
||||
Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM);
|
||||
Prenum == 0 ? TRUE : FALSE,
|
||||
type, Prenum1, ACTION_SPLIT, 1, MAXLNUM);
|
||||
curwin->w_set_curswant = TRUE;
|
||||
break;
|
||||
|
||||
@@ -4830,17 +4830,16 @@ static void frame_add_height(frame_T *frp, int n)
|
||||
char_u *grab_file_name(long count, linenr_T *file_lnum)
|
||||
{
|
||||
if (VIsual_active) {
|
||||
int len;
|
||||
size_t len;
|
||||
char_u *ptr;
|
||||
|
||||
if (get_visual_text(NULL, &ptr, &len) == FAIL)
|
||||
return NULL;
|
||||
return find_file_name_in_path(ptr, len,
|
||||
FNAME_MESS|FNAME_EXP|FNAME_REL, count, curbuf->b_ffname);
|
||||
FNAME_MESS|FNAME_EXP|FNAME_REL,
|
||||
count, curbuf->b_ffname);
|
||||
}
|
||||
return file_name_at_cursor(FNAME_MESS|FNAME_HYP|FNAME_EXP|FNAME_REL, count,
|
||||
file_lnum);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4878,7 +4877,7 @@ file_name_in_line (
|
||||
)
|
||||
{
|
||||
char_u *ptr;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* search forward for what could be the start of a file name
|
||||
@@ -4897,7 +4896,7 @@ file_name_in_line (
|
||||
* Go one char back to ":" before "//" even when ':' is not in 'isfname'.
|
||||
*/
|
||||
while (ptr > line) {
|
||||
if (has_mbyte && (len = (*mb_head_off)(line, ptr - 1)) > 0)
|
||||
if (has_mbyte && (len = (size_t)((*mb_head_off)(line, ptr - 1))) > 0)
|
||||
ptr -= len + 1;
|
||||
else if (vim_isfilec(ptr[-1])
|
||||
|| ((options & FNAME_HYP) && path_is_url(ptr - 1)))
|
||||
@@ -4914,7 +4913,7 @@ file_name_in_line (
|
||||
while (vim_isfilec(ptr[len])
|
||||
|| ((options & FNAME_HYP) && path_is_url(ptr + len)))
|
||||
if (has_mbyte)
|
||||
len += (*mb_ptr2len)(ptr + len);
|
||||
len += (size_t)(*mb_ptr2len)(ptr + len);
|
||||
else
|
||||
++len;
|
||||
|
||||
|
Reference in New Issue
Block a user