mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: follow style guide
- reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
This commit is contained in:
parent
48bcc7b971
commit
28f4f3c484
@ -254,9 +254,8 @@ void alist_slash_adjust(void)
|
||||
static char *do_one_arg(char *str)
|
||||
{
|
||||
char *p;
|
||||
bool inbacktick;
|
||||
|
||||
inbacktick = false;
|
||||
bool inbacktick = false;
|
||||
for (p = str; *str; str++) {
|
||||
// When the backslash is used for escaping the special meaning of a
|
||||
// character we need to keep it until wildcard expansion.
|
||||
@ -834,10 +833,8 @@ char *get_arglist_name(expand_T *xp FUNC_ATTR_UNUSED, int idx)
|
||||
/// Get the file name for an argument list entry.
|
||||
char *alist_name(aentry_T *aep)
|
||||
{
|
||||
buf_T *bp;
|
||||
|
||||
// Use the name from the associated buffer if it exists.
|
||||
bp = buflist_findnr(aep->ae_fnum);
|
||||
buf_T *bp = buflist_findnr(aep->ae_fnum);
|
||||
if (bp == NULL || bp->b_fname == NULL) {
|
||||
return aep->ae_fname;
|
||||
}
|
||||
|
@ -134,13 +134,12 @@ int get_highest_fnum(void)
|
||||
static int read_buffer(int read_stdin, exarg_T *eap, int flags)
|
||||
{
|
||||
int retval = OK;
|
||||
linenr_T line_count;
|
||||
bool silent = shortmess(SHM_FILEINFO);
|
||||
|
||||
// Read from the buffer which the text is already filled in and append at
|
||||
// the end. This makes it possible to retry when 'fileformat' or
|
||||
// 'fileencoding' was guessed wrong.
|
||||
line_count = curbuf->b_ml.ml_line_count;
|
||||
linenr_T line_count = curbuf->b_ml.ml_line_count;
|
||||
retval = readfile(read_stdin ? NULL : curbuf->b_ffname,
|
||||
read_stdin ? NULL : curbuf->b_fname,
|
||||
line_count, 0, (linenr_T)MAXLNUM, eap,
|
||||
@ -1039,9 +1038,8 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
|
||||
{
|
||||
int do_current = 0; // delete current buffer?
|
||||
int deleted = 0; // number of buffers deleted
|
||||
char *errormsg = NULL; // return value
|
||||
char *errormsg = NULL; // return value
|
||||
int bnr; // buffer number
|
||||
char *p;
|
||||
|
||||
if (addr_count == 0) {
|
||||
(void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit);
|
||||
@ -1078,7 +1076,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
|
||||
break;
|
||||
}
|
||||
if (!ascii_isdigit(*arg)) {
|
||||
p = skiptowhite_esc(arg);
|
||||
char *p = skiptowhite_esc(arg);
|
||||
bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, false, false);
|
||||
if (bnr < 0) { // failed
|
||||
break;
|
||||
@ -1125,7 +1123,6 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
|
||||
/// Used when it is wiped out and it's the last buffer.
|
||||
static int empty_curbuf(int close_others, int forceit, int action)
|
||||
{
|
||||
int retval;
|
||||
buf_T *buf = curbuf;
|
||||
|
||||
if (action == DOBUF_UNLOAD) {
|
||||
@ -1158,8 +1155,7 @@ static int empty_curbuf(int close_others, int forceit, int action)
|
||||
}
|
||||
|
||||
setpcmark();
|
||||
retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
|
||||
forceit ? ECMD_FORCEIT : 0, curwin);
|
||||
int retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, forceit ? ECMD_FORCEIT : 0, curwin);
|
||||
|
||||
// do_ecmd() may create a new buffer, then we have to delete
|
||||
// the old one. But do_ecmd() may have done that already, check
|
||||
@ -2044,12 +2040,11 @@ void free_buf_options(buf_T *buf, int free_p_ff)
|
||||
/// Return FAIL for failure, OK for success.
|
||||
int buflist_getfile(int n, linenr_T lnum, int options, int forceit)
|
||||
{
|
||||
buf_T *buf;
|
||||
win_T *wp = NULL;
|
||||
fmark_T *fm = NULL;
|
||||
colnr_T col;
|
||||
|
||||
buf = buflist_findnr(n);
|
||||
buf_T *buf = buflist_findnr(n);
|
||||
if (buf == NULL) {
|
||||
if ((options & GETF_ALT) && n == 0) {
|
||||
emsg(_(e_noalt));
|
||||
@ -2121,9 +2116,7 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit)
|
||||
/// Go to the last known line number for the current buffer.
|
||||
void buflist_getfpos(void)
|
||||
{
|
||||
pos_T *fpos;
|
||||
|
||||
fpos = &buflist_findfmark(curbuf)->mark;
|
||||
pos_T *fpos = &buflist_findfmark(curbuf)->mark;
|
||||
|
||||
curwin->w_cursor.lnum = fpos->lnum;
|
||||
check_cursor_lnum(curwin);
|
||||
@ -2143,18 +2136,17 @@ void buflist_getfpos(void)
|
||||
/// @return buffer or NULL if not found
|
||||
buf_T *buflist_findname_exp(char *fname)
|
||||
{
|
||||
char *ffname;
|
||||
buf_T *buf = NULL;
|
||||
|
||||
// First make the name into a full path name
|
||||
ffname = FullName_save(fname,
|
||||
char *ffname = FullName_save(fname,
|
||||
#ifdef UNIX
|
||||
// force expansion, get rid of symbolic links
|
||||
true
|
||||
// force expansion, get rid of symbolic links
|
||||
true
|
||||
#else
|
||||
false
|
||||
false
|
||||
#endif
|
||||
); // NOLINT(whitespace/parens)
|
||||
); // NOLINT(whitespace/parens)
|
||||
if (ffname != NULL) {
|
||||
buf = buflist_findname(ffname);
|
||||
xfree(ffname);
|
||||
@ -2204,12 +2196,6 @@ int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted,
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
int match = -1;
|
||||
int find_listed;
|
||||
char *pat;
|
||||
char *patend;
|
||||
int attempt;
|
||||
char *p;
|
||||
int toggledollar;
|
||||
|
||||
if (pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#')) {
|
||||
if (*pattern == '%') {
|
||||
@ -2230,23 +2216,24 @@ int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted,
|
||||
// Repeat this for finding an unlisted buffer if there was no matching
|
||||
// listed buffer.
|
||||
|
||||
pat = file_pat_to_reg_pat(pattern, pattern_end, NULL, false);
|
||||
char *pat = file_pat_to_reg_pat(pattern, pattern_end, NULL, false);
|
||||
if (pat == NULL) {
|
||||
return -1;
|
||||
}
|
||||
patend = pat + strlen(pat) - 1;
|
||||
toggledollar = (patend > pat && *patend == '$');
|
||||
char *patend = pat + strlen(pat) - 1;
|
||||
int toggledollar = (patend > pat && *patend == '$');
|
||||
|
||||
// First try finding a listed buffer. If not found and "unlisted"
|
||||
// is true, try finding an unlisted buffer.
|
||||
find_listed = true;
|
||||
|
||||
int find_listed = true;
|
||||
while (true) {
|
||||
for (attempt = 0; attempt <= 3; attempt++) {
|
||||
for (int attempt = 0; attempt <= 3; attempt++) {
|
||||
// may add '^' and '$'
|
||||
if (toggledollar) {
|
||||
*patend = (attempt < 2) ? NUL : '$'; // add/remove '$'
|
||||
}
|
||||
p = pat;
|
||||
char *p = pat;
|
||||
if (*p == '^' && !(attempt & 1)) { // add/remove '^'
|
||||
p++;
|
||||
}
|
||||
@ -2336,7 +2323,6 @@ int ExpandBufnames(char *pat, int *num_file, char ***file, int options)
|
||||
int count = 0;
|
||||
int round;
|
||||
char *p;
|
||||
int attempt;
|
||||
bufmatch_T *matches = NULL;
|
||||
|
||||
*num_file = 0; // return values in case of FAIL
|
||||
@ -2364,7 +2350,7 @@ int ExpandBufnames(char *pat, int *num_file, char ***file, int options)
|
||||
fuzmatch_str_T *fuzmatch = NULL;
|
||||
// attempt == 0: try match with '\<', match at start of word
|
||||
// attempt == 1: try match without '\<', match anywhere
|
||||
for (attempt = 0; attempt <= (fuzzy ? 0 : 1); attempt++) {
|
||||
for (int attempt = 0; attempt <= (fuzzy ? 0 : 1); attempt++) {
|
||||
regmatch_T regmatch;
|
||||
if (!fuzzy) {
|
||||
if (attempt > 0 && patc == pat) {
|
||||
@ -2520,7 +2506,6 @@ static char *buflist_match(regmatch_T *rmp, buf_T *buf, bool ignore_case)
|
||||
static char *fname_match(regmatch_T *rmp, char *name, bool ignore_case)
|
||||
{
|
||||
char *match = NULL;
|
||||
char *p;
|
||||
|
||||
// extra check for valid arguments
|
||||
if (name == NULL || rmp->regprog == NULL) {
|
||||
@ -2533,7 +2518,7 @@ static char *fname_match(regmatch_T *rmp, char *name, bool ignore_case)
|
||||
match = name;
|
||||
} else if (rmp->regprog != NULL) {
|
||||
// Replace $(HOME) with '~' and try matching again.
|
||||
p = home_replace_save(NULL, name);
|
||||
char *p = home_replace_save(NULL, name);
|
||||
if (vim_regexec(rmp, p, 0)) {
|
||||
match = name;
|
||||
}
|
||||
@ -3151,10 +3136,8 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
|
||||
char *name;
|
||||
int n;
|
||||
char *p;
|
||||
char *buffer;
|
||||
size_t len;
|
||||
|
||||
buffer = xmalloc(IOSIZE);
|
||||
char *buffer = xmalloc(IOSIZE);
|
||||
|
||||
if (fullname > 1) { // 2 CTRL-G: include buffer number
|
||||
vim_snprintf(buffer, IOSIZE, "buf %d: ", curbuf->b_fnum);
|
||||
@ -3217,7 +3200,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
|
||||
(int64_t)curbuf->b_ml.ml_line_count,
|
||||
n);
|
||||
validate_virtcol();
|
||||
len = strlen(buffer);
|
||||
size_t len = strlen(buffer);
|
||||
col_print(buffer + len, IOSIZE - len,
|
||||
(int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1);
|
||||
}
|
||||
@ -3266,7 +3249,6 @@ void maketitle(void)
|
||||
char *icon_str = NULL;
|
||||
int maxlen = 0;
|
||||
int len;
|
||||
int mustset;
|
||||
char buf[IOSIZE];
|
||||
|
||||
if (!redrawing()) {
|
||||
@ -3389,7 +3371,7 @@ void maketitle(void)
|
||||
#undef SPACE_FOR_ARGNR
|
||||
}
|
||||
}
|
||||
mustset = value_change(title_str, &lasttitle);
|
||||
int mustset = value_change(title_str, &lasttitle);
|
||||
|
||||
if (p_icon) {
|
||||
icon_str = buf;
|
||||
@ -3807,12 +3789,10 @@ static int chk_modeline(linenr_T lnum, int flags)
|
||||
char *s;
|
||||
char *e;
|
||||
char *linecopy; // local copy of any modeline found
|
||||
int prev;
|
||||
intmax_t vers;
|
||||
int end;
|
||||
int retval = OK;
|
||||
|
||||
prev = -1;
|
||||
int prev = -1;
|
||||
for (s = ml_get(lnum); *s != NUL; s++) {
|
||||
if (prev == -1 || ascii_isspace(prev)) {
|
||||
if ((prev != -1 && strncmp(s, "ex:", (size_t)3) == 0)
|
||||
@ -3858,7 +3838,7 @@ static int chk_modeline(linenr_T lnum, int flags)
|
||||
// prepare for emsg()
|
||||
estack_push(ETYPE_MODELINE, "modelines", lnum);
|
||||
|
||||
end = false;
|
||||
bool end = false;
|
||||
while (end == false) {
|
||||
s = skipwhite(s);
|
||||
if (*s == NUL) {
|
||||
|
@ -1696,14 +1696,13 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
||||
// concatenate leader and p_extra, if there is a leader
|
||||
if (lead_len > 0) {
|
||||
if (flags & OPENLINE_COM_LIST && second_line_indent > 0) {
|
||||
int i;
|
||||
int padding = second_line_indent
|
||||
- (newindent + (int)strlen(leader));
|
||||
|
||||
// Here whitespace is inserted after the comment char.
|
||||
// Below, set_indent(newindent, SIN_INSERT) will insert the
|
||||
// whitespace needed before the comment char.
|
||||
for (i = 0; i < padding; i++) {
|
||||
for (int i = 0; i < padding; i++) {
|
||||
STRCAT(leader, " ");
|
||||
less_cols--;
|
||||
newcol++;
|
||||
@ -1987,9 +1986,7 @@ int get_leader_len(char *line, char **flags, bool backward, bool include_space)
|
||||
int got_com = false;
|
||||
char part_buf[COM_MAX_LEN]; // buffer for one option part
|
||||
char *string; // pointer to comment string
|
||||
char *list;
|
||||
int middle_match_len = 0;
|
||||
char *prev_list;
|
||||
char *saved_flags = NULL;
|
||||
|
||||
int result = 0;
|
||||
@ -2002,13 +1999,13 @@ int get_leader_len(char *line, char **flags, bool backward, bool include_space)
|
||||
while (line[i] != NUL) {
|
||||
// scan through the 'comments' option for a match
|
||||
int found_one = false;
|
||||
for (list = curbuf->b_p_com; *list;) {
|
||||
for (char *list = curbuf->b_p_com; *list;) {
|
||||
// Get one option part into part_buf[]. Advance "list" to next
|
||||
// one. Put "string" at start of string.
|
||||
if (!got_com && flags != NULL) {
|
||||
*flags = list; // remember where flags started
|
||||
}
|
||||
prev_list = list;
|
||||
char *prev_list = list;
|
||||
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
||||
string = vim_strchr(part_buf, ':');
|
||||
if (string == NULL) { // missing ':', ignore this part
|
||||
@ -2204,7 +2201,6 @@ int get_last_leader_offset(char *line, char **flags)
|
||||
|
||||
if (found_one) {
|
||||
char part_buf2[COM_MAX_LEN]; // buffer for one option part
|
||||
int len1, len2, off;
|
||||
|
||||
result = i;
|
||||
// If this comment nests, continue searching.
|
||||
@ -2222,7 +2218,7 @@ int get_last_leader_offset(char *line, char **flags)
|
||||
while (ascii_iswhite(*com_leader)) {
|
||||
com_leader++;
|
||||
}
|
||||
len1 = (int)strlen(com_leader);
|
||||
int len1 = (int)strlen(com_leader);
|
||||
|
||||
for (list = curbuf->b_p_com; *list;) {
|
||||
char *flags_save = list;
|
||||
@ -2236,14 +2232,14 @@ int get_last_leader_offset(char *line, char **flags)
|
||||
while (ascii_iswhite(*string)) {
|
||||
string++;
|
||||
}
|
||||
len2 = (int)strlen(string);
|
||||
int len2 = (int)strlen(string);
|
||||
if (len2 == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now we have to verify whether string ends with a substring
|
||||
// beginning the com_leader.
|
||||
for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;) {
|
||||
for (int off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;) {
|
||||
off--;
|
||||
if (!strncmp(string + off, com_leader, (size_t)(len2 - off))) {
|
||||
if (i - off < lower_check_bound) {
|
||||
|
@ -88,10 +88,6 @@ int init_chartab(void)
|
||||
int buf_init_chartab(buf_T *buf, int global)
|
||||
{
|
||||
int c;
|
||||
int c2;
|
||||
int i;
|
||||
bool tilde;
|
||||
bool do_isalpha;
|
||||
|
||||
if (global) {
|
||||
// Set the default size for printable characters:
|
||||
@ -130,7 +126,7 @@ int buf_init_chartab(buf_T *buf, int global)
|
||||
// Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'
|
||||
// options Each option is a list of characters, character numbers or
|
||||
// ranges, separated by commas, e.g.: "200-210,x,#-178,-"
|
||||
for (i = global ? 0 : 3; i <= 3; i++) {
|
||||
for (int i = global ? 0 : 3; i <= 3; i++) {
|
||||
const char *p;
|
||||
if (i == 0) {
|
||||
// first round: 'isident'
|
||||
@ -147,8 +143,8 @@ int buf_init_chartab(buf_T *buf, int global)
|
||||
}
|
||||
|
||||
while (*p) {
|
||||
tilde = false;
|
||||
do_isalpha = false;
|
||||
bool tilde = false;
|
||||
bool do_isalpha = false;
|
||||
|
||||
if ((*p == '^') && (p[1] != NUL)) {
|
||||
tilde = true;
|
||||
@ -160,7 +156,7 @@ int buf_init_chartab(buf_T *buf, int global)
|
||||
} else {
|
||||
c = mb_ptr2char_adv(&p);
|
||||
}
|
||||
c2 = -1;
|
||||
int c2 = -1;
|
||||
|
||||
if ((*p == '-') && (p[1] != NUL)) {
|
||||
p++;
|
||||
@ -431,7 +427,6 @@ char *str_foldcase(char *str, int orglen, char *buf, int buflen)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
garray_T ga;
|
||||
int i;
|
||||
int len = orglen;
|
||||
|
||||
#define GA_CHAR(i) ((char *)ga.ga_data)[i]
|
||||
@ -461,7 +456,7 @@ char *str_foldcase(char *str, int orglen, char *buf, int buflen)
|
||||
}
|
||||
|
||||
// Make each character lower case.
|
||||
i = 0;
|
||||
int i = 0;
|
||||
while (STR_CHAR(i) != NUL) {
|
||||
int c = utf_ptr2char(STR_PTR(i));
|
||||
int olen = utf_ptr2len(STR_PTR(i));
|
||||
|
@ -225,7 +225,6 @@ static void ExpandEscape(expand_T *xp, char *str, int numfiles, char **files, in
|
||||
int nextwild(expand_T *xp, int type, int options, bool escape)
|
||||
{
|
||||
CmdlineInfo *const ccline = get_cmdline_info();
|
||||
int i;
|
||||
char *p2;
|
||||
|
||||
if (xp->xp_numfiles == -1) {
|
||||
@ -249,7 +248,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
||||
ui_flush();
|
||||
}
|
||||
|
||||
i = (int)(xp->xp_pattern - ccline->cmdbuff);
|
||||
int i = (int)(xp->xp_pattern - ccline->cmdbuff);
|
||||
assert(ccline->cmdpos >= i);
|
||||
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
||||
|
||||
@ -444,11 +443,8 @@ static int wildmenu_match_len(expand_T *xp, char *s)
|
||||
/// @param matches list of matches
|
||||
static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int match, int showtail)
|
||||
{
|
||||
int row;
|
||||
char *buf;
|
||||
int len;
|
||||
int clen; // length in screen cells
|
||||
int fillchar;
|
||||
int attr;
|
||||
int i;
|
||||
bool highlight = true;
|
||||
@ -463,7 +459,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
||||
return;
|
||||
}
|
||||
|
||||
buf = xmalloc((size_t)Columns * MB_MAXBYTES + 1);
|
||||
char *buf = xmalloc((size_t)Columns * MB_MAXBYTES + 1);
|
||||
|
||||
if (match == -1) { // don't show match but original text
|
||||
match = 0;
|
||||
@ -511,7 +507,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
||||
}
|
||||
}
|
||||
|
||||
fillchar = fillchar_status(&attr, curwin);
|
||||
int fillchar = fillchar_status(&attr, curwin);
|
||||
|
||||
if (first_match == 0) {
|
||||
*buf = NUL;
|
||||
@ -570,7 +566,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
||||
|
||||
buf[len] = NUL;
|
||||
|
||||
row = cmdline_row - 1;
|
||||
int row = cmdline_row - 1;
|
||||
if (row >= 0) {
|
||||
if (wild_menu_showing == 0 || wild_menu_showing == WM_LIST) {
|
||||
if (msg_scrolled > 0) {
|
||||
@ -1032,7 +1028,7 @@ int showmatches(expand_T *xp, int wildmenu)
|
||||
CmdlineInfo *const ccline = get_cmdline_info();
|
||||
int numMatches;
|
||||
char **matches;
|
||||
int i, j;
|
||||
int j;
|
||||
int maxlen;
|
||||
int lines;
|
||||
int columns;
|
||||
@ -1041,8 +1037,8 @@ int showmatches(expand_T *xp, int wildmenu)
|
||||
|
||||
if (xp->xp_numfiles == -1) {
|
||||
set_expand_context(xp);
|
||||
i = expand_cmdline(xp, ccline->cmdbuff, ccline->cmdpos,
|
||||
&numMatches, &matches);
|
||||
int i = expand_cmdline(xp, ccline->cmdbuff, ccline->cmdpos,
|
||||
&numMatches, &matches);
|
||||
showtail = expand_showtail(xp);
|
||||
if (i != EXPAND_OK) {
|
||||
return i;
|
||||
@ -1080,7 +1076,7 @@ int showmatches(expand_T *xp, int wildmenu)
|
||||
} else {
|
||||
// find the length of the longest file name
|
||||
maxlen = 0;
|
||||
for (i = 0; i < numMatches; i++) {
|
||||
for (int i = 0; i < numMatches; i++) {
|
||||
if (!showtail && (xp->xp_context == EXPAND_FILES
|
||||
|| xp->xp_context == EXPAND_SHELLCMD
|
||||
|| xp->xp_context == EXPAND_BUFFERS)) {
|
||||
@ -1116,7 +1112,7 @@ int showmatches(expand_T *xp, int wildmenu)
|
||||
}
|
||||
|
||||
// list the files line by line
|
||||
for (i = 0; i < lines; i++) {
|
||||
for (int i = 0; i < lines; i++) {
|
||||
showmatches_oneline(xp, matches, numMatches, lines, i, maxlen, showtail, attr);
|
||||
if (got_int) {
|
||||
got_int = false;
|
||||
@ -1140,11 +1136,10 @@ int showmatches(expand_T *xp, int wildmenu)
|
||||
/// Return the tail of file name path "s", ignoring a trailing "/".
|
||||
static char *showmatches_gettail(char *s, bool eager)
|
||||
{
|
||||
char *p;
|
||||
char *t = s;
|
||||
bool had_sep = false;
|
||||
|
||||
for (p = s; *p != NUL;) {
|
||||
for (char *p = s; *p != NUL;) {
|
||||
if (vim_ispathsep(*p)
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
&& !rem_backslash(p)
|
||||
@ -1169,9 +1164,6 @@ static char *showmatches_gettail(char *s, bool eager)
|
||||
/// returned.
|
||||
static bool expand_showtail(expand_T *xp)
|
||||
{
|
||||
char *s;
|
||||
char *end;
|
||||
|
||||
// When not completing file names a "/" may mean something different.
|
||||
if (xp->xp_context != EXPAND_FILES
|
||||
&& xp->xp_context != EXPAND_SHELLCMD
|
||||
@ -1179,12 +1171,12 @@ static bool expand_showtail(expand_T *xp)
|
||||
return false;
|
||||
}
|
||||
|
||||
end = path_tail(xp->xp_pattern);
|
||||
char *end = path_tail(xp->xp_pattern);
|
||||
if (end == xp->xp_pattern) { // there is no path separator
|
||||
return false;
|
||||
}
|
||||
|
||||
for (s = xp->xp_pattern; s < end; s++) {
|
||||
for (char *s = xp->xp_pattern; s < end; s++) {
|
||||
// Skip escaped wildcards. Only when the backslash is not a path
|
||||
// separator, on DOS the '*' "path\*\file" must not be skipped.
|
||||
if (rem_backslash(s)) {
|
||||
@ -1209,9 +1201,6 @@ char *addstar(char *fname, size_t len, int context)
|
||||
{
|
||||
char *retval;
|
||||
size_t i, j;
|
||||
size_t new_len;
|
||||
char *tail;
|
||||
int ends_in_star;
|
||||
|
||||
if (context != EXPAND_FILES
|
||||
&& context != EXPAND_FILES_IN_PATH
|
||||
@ -1236,7 +1225,7 @@ char *addstar(char *fname, size_t len, int context)
|
||||
|| context == EXPAND_LUA) {
|
||||
retval = xstrnsave(fname, len);
|
||||
} else {
|
||||
new_len = len + 2; // +2 for '^' at start, NUL at end
|
||||
size_t new_len = len + 2; // +2 for '^' at start, NUL at end
|
||||
for (i = 0; i < len; i++) {
|
||||
if (fname[i] == '*' || fname[i] == '~') {
|
||||
new_len++; // '*' needs to be replaced by ".*"
|
||||
@ -1304,8 +1293,8 @@ char *addstar(char *fname, size_t len, int context)
|
||||
// $ could be anywhere in the tail.
|
||||
// ` could be anywhere in the file name.
|
||||
// When the name ends in '$' don't add a star, remove the '$'.
|
||||
tail = path_tail(retval);
|
||||
ends_in_star = (len > 0 && retval[len - 1] == '*');
|
||||
char *tail = path_tail(retval);
|
||||
int ends_in_star = (len > 0 && retval[len - 1] == '*');
|
||||
#ifndef BACKSLASH_IN_FILENAME
|
||||
for (ssize_t k = (ssize_t)len - 2; k >= 0; k--) {
|
||||
if (retval[k] != '\\') {
|
||||
@ -2981,18 +2970,16 @@ static void expand_shellcmd_onedir(char *buf, char *s, size_t l, char *pat, char
|
||||
static void expand_shellcmd(char *filepat, char ***matches, int *numMatches, int flagsarg)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *pat;
|
||||
int i;
|
||||
char *path = NULL;
|
||||
garray_T ga;
|
||||
char *buf = xmalloc(MAXPATHL);
|
||||
char *s, *e;
|
||||
char *e;
|
||||
int flags = flagsarg;
|
||||
bool did_curdir = false;
|
||||
|
||||
// for ":set path=" and ":set tags=" halve backslashes for escaped space
|
||||
pat = xstrdup(filepat);
|
||||
for (i = 0; pat[i]; i++) {
|
||||
char *pat = xstrdup(filepat);
|
||||
for (int i = 0; pat[i]; i++) {
|
||||
if (pat[i] == '\\' && pat[i + 1] == ' ') {
|
||||
STRMOVE(pat + i, pat + i + 1);
|
||||
}
|
||||
@ -3022,7 +3009,7 @@ static void expand_shellcmd(char *filepat, char ***matches, int *numMatches, int
|
||||
ga_init(&ga, (int)sizeof(char *), 10);
|
||||
hashtab_T found_ht;
|
||||
hash_init(&found_ht);
|
||||
for (s = path;; s = e) {
|
||||
for (char *s = path;; s = e) {
|
||||
e = vim_strchr(s, ENV_SEPCHAR);
|
||||
if (e == NULL) {
|
||||
e = s + strlen(s);
|
||||
@ -3071,7 +3058,6 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
|
||||
CmdlineInfo *const ccline = get_cmdline_info();
|
||||
char keep = 0;
|
||||
typval_T args[4];
|
||||
char *pat = NULL;
|
||||
const sctx_T save_current_sctx = current_sctx;
|
||||
|
||||
if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0' || xp->xp_line == NULL) {
|
||||
@ -3083,7 +3069,7 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
|
||||
ccline->cmdbuff[ccline->cmdlen] = 0;
|
||||
}
|
||||
|
||||
pat = xstrnsave(xp->xp_pattern, xp->xp_pattern_len);
|
||||
char *pat = xstrnsave(xp->xp_pattern, xp->xp_pattern_len);
|
||||
args[0].v_type = VAR_STRING;
|
||||
args[1].v_type = VAR_STRING;
|
||||
args[2].v_type = VAR_NUMBER;
|
||||
|
@ -519,14 +519,12 @@ static int del_history_idx(int histype, int idx)
|
||||
/// "histadd()" function
|
||||
void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
HistoryType histype;
|
||||
|
||||
rettv->vval.v_number = false;
|
||||
if (check_secure()) {
|
||||
return;
|
||||
}
|
||||
const char *str = tv_get_string_chk(&argvars[0]); // NULL on type error
|
||||
histype = str != NULL ? get_histtype(str, strlen(str), false) : HIST_INVALID;
|
||||
HistoryType histype = str != NULL ? get_histtype(str, strlen(str), false) : HIST_INVALID;
|
||||
if (histype == HIST_INVALID) {
|
||||
return;
|
||||
}
|
||||
@ -605,7 +603,6 @@ void ex_history(exarg_T *eap)
|
||||
int histype2 = HIST_CMD;
|
||||
int hisidx1 = 1;
|
||||
int hisidx2 = -1;
|
||||
int i;
|
||||
char *end;
|
||||
char *arg = eap->arg;
|
||||
|
||||
@ -661,7 +658,7 @@ void ex_history(exarg_T *eap)
|
||||
k = (-k > hislen) ? 0 : hist[(hislen + k + idx + 1) % hislen].hisnum;
|
||||
}
|
||||
if (idx >= 0 && j <= k) {
|
||||
for (i = idx + 1; !got_int; i++) {
|
||||
for (int i = idx + 1; !got_int; i++) {
|
||||
if (i == hislen) {
|
||||
i = 0;
|
||||
}
|
||||
|
@ -112,10 +112,9 @@ const char *parse_shape_opt(int what)
|
||||
int len;
|
||||
int i;
|
||||
int found_ve = false; // found "ve" flag
|
||||
int round;
|
||||
|
||||
// First round: check for errors; second round: do it for real.
|
||||
for (round = 1; round <= 2; round++) {
|
||||
for (int round = 1; round <= 2; round++) {
|
||||
if (round == 2 || *p_guicursor == NUL) {
|
||||
// Set all entries to default (block, blinkon0, default color).
|
||||
// This is the default for anything that is not set.
|
||||
|
@ -505,7 +505,6 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp)
|
||||
static int dbg_parsearg(char *arg, garray_T *gap)
|
||||
{
|
||||
char *p = arg;
|
||||
char *q;
|
||||
bool here = false;
|
||||
|
||||
ga_grow(gap, 1);
|
||||
@ -561,7 +560,7 @@ static int dbg_parsearg(char *arg, garray_T *gap)
|
||||
// Expand the file name in the same way as do_source(). This means
|
||||
// doing it twice, so that $DIR/file gets expanded when $DIR is
|
||||
// "~/dir".
|
||||
q = expand_env_save(p);
|
||||
char *q = expand_env_save(p);
|
||||
if (q == NULL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
@ -340,8 +340,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T
|
||||
|
||||
dnext->df_lnum[idx] = line1;
|
||||
dnext->df_count[idx] = inserted;
|
||||
int i;
|
||||
for (i = 0; i < DB_COUNT; i++) {
|
||||
for (int i = 0; i < DB_COUNT; i++) {
|
||||
if ((tp->tp_diffbuf[i] != NULL) && (i != idx)) {
|
||||
if (dprev == NULL) {
|
||||
dnext->df_lnum[i] = line1;
|
||||
@ -472,8 +471,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T
|
||||
// check if this block touches the previous one, may merge them.
|
||||
if ((dprev != NULL) && !dp->is_linematched
|
||||
&& (dprev->df_lnum[idx] + dprev->df_count[idx] == dp->df_lnum[idx])) {
|
||||
int i;
|
||||
for (i = 0; i < DB_COUNT; i++) {
|
||||
for (int i = 0; i < DB_COUNT; i++) {
|
||||
if (tp->tp_diffbuf[i] != NULL) {
|
||||
dprev->df_count[i] += dp->df_count[i];
|
||||
}
|
||||
|
@ -2074,8 +2074,6 @@ char *keymap_init(void)
|
||||
/// @param eap
|
||||
void ex_loadkeymap(exarg_T *eap)
|
||||
{
|
||||
char *s;
|
||||
|
||||
#define KMAP_LLEN 200 // max length of "to" and "from" together
|
||||
char buf[KMAP_LLEN + 11];
|
||||
char *save_cpo = p_cpo;
|
||||
@ -2106,7 +2104,7 @@ void ex_loadkeymap(exarg_T *eap)
|
||||
|
||||
if ((*p != '"') && (*p != NUL)) {
|
||||
kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga);
|
||||
s = skiptowhite(p);
|
||||
char *s = skiptowhite(p);
|
||||
kp->from = xmemdupz(p, (size_t)(s - p));
|
||||
p = skipwhite(s);
|
||||
s = skiptowhite(p);
|
||||
|
@ -401,8 +401,6 @@ static void handle_foldcolumn(win_T *wp, winlinevars_T *wlv)
|
||||
size_t fill_foldcolumn(char *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum, int *n_closing)
|
||||
{
|
||||
int i = 0;
|
||||
int level;
|
||||
int first_level;
|
||||
int fdc = compute_foldcolumn(wp, 0); // available cell width
|
||||
size_t char_counter = 0;
|
||||
int symbol = 0;
|
||||
@ -411,11 +409,11 @@ size_t fill_foldcolumn(char *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum, i
|
||||
// Init to all spaces.
|
||||
memset(p, ' ', MB_MAXCHAR * (size_t)fdc + 1);
|
||||
|
||||
level = foldinfo.fi_level;
|
||||
int level = foldinfo.fi_level;
|
||||
|
||||
// If the column is too narrow, we start at the lowest level that
|
||||
// fits and use numbers to indicate the depth.
|
||||
first_level = level - fdc - closed + 1;
|
||||
int first_level = level - fdc - closed + 1;
|
||||
if (first_level < 1) {
|
||||
first_level = 1;
|
||||
}
|
||||
|
135
src/nvim/edit.c
135
src/nvim/edit.c
@ -1387,7 +1387,6 @@ void ins_redraw(bool ready)
|
||||
// Handle a CTRL-V or CTRL-Q typed in Insert mode.
|
||||
static void ins_ctrl_v(void)
|
||||
{
|
||||
int c;
|
||||
bool did_putchar = false;
|
||||
|
||||
// may need to redraw when no more chars available now
|
||||
@ -1402,7 +1401,7 @@ static void ins_ctrl_v(void)
|
||||
add_to_showcmd_c(Ctrl_V);
|
||||
|
||||
// Do not include modifiers into the key for CTRL-SHIFT-V.
|
||||
c = get_literal(mod_mask & MOD_MASK_SHIFT);
|
||||
int c = get_literal(mod_mask & MOD_MASK_SHIFT);
|
||||
if (did_putchar) {
|
||||
// when the line fits in 'columns' the '^' is at the start of the next
|
||||
// line and will not removed by the redraw
|
||||
@ -1491,10 +1490,9 @@ char *prompt_text(void)
|
||||
static void init_prompt(int cmdchar_todo)
|
||||
{
|
||||
char *prompt = prompt_text();
|
||||
char *text;
|
||||
|
||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||
text = get_cursor_line_ptr();
|
||||
char *text = get_cursor_line_ptr();
|
||||
if (strncmp(text, prompt, strlen(prompt)) != 0) {
|
||||
// prompt is missing, insert it or append a line with it
|
||||
if (*text == NUL) {
|
||||
@ -1558,13 +1556,12 @@ void edit_unputchar(void)
|
||||
void display_dollar(colnr_T col_arg)
|
||||
{
|
||||
colnr_T col = col_arg < 0 ? 0 : col_arg;
|
||||
colnr_T save_col;
|
||||
|
||||
if (!redrawing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
save_col = curwin->w_cursor.col;
|
||||
colnr_T save_col = curwin->w_cursor.col;
|
||||
curwin->w_cursor.col = col;
|
||||
|
||||
// If on the last byte of a multi-byte move to the first byte.
|
||||
@ -1599,14 +1596,7 @@ void undisplay_dollar(void)
|
||||
/// @param call_changed_bytes call changed_bytes()
|
||||
void change_indent(int type, int amount, int round, int replaced, int call_changed_bytes)
|
||||
{
|
||||
int vcol;
|
||||
int last_vcol;
|
||||
int insstart_less; // reduction for Insstart.col
|
||||
int new_cursor_col;
|
||||
char *ptr;
|
||||
int save_p_list;
|
||||
int start_col;
|
||||
colnr_T vc;
|
||||
colnr_T orig_col = 0; // init for GCC
|
||||
char *orig_line = NULL; // init for GCC
|
||||
|
||||
@ -1617,18 +1607,18 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
|
||||
}
|
||||
|
||||
// for the following tricks we don't want list mode
|
||||
save_p_list = curwin->w_p_list;
|
||||
int save_p_list = curwin->w_p_list;
|
||||
curwin->w_p_list = false;
|
||||
vc = getvcol_nolist(&curwin->w_cursor);
|
||||
vcol = vc;
|
||||
colnr_T vc = getvcol_nolist(&curwin->w_cursor);
|
||||
int vcol = vc;
|
||||
|
||||
// For Replace mode we need to fix the replace stack later, which is only
|
||||
// possible when the cursor is in the indent. Remember the number of
|
||||
// characters before the cursor if it's possible.
|
||||
start_col = curwin->w_cursor.col;
|
||||
int start_col = curwin->w_cursor.col;
|
||||
|
||||
// determine offset from first non-blank
|
||||
new_cursor_col = curwin->w_cursor.col;
|
||||
int new_cursor_col = curwin->w_cursor.col;
|
||||
beginline(BL_WHITE);
|
||||
new_cursor_col -= curwin->w_cursor.col;
|
||||
|
||||
@ -1681,8 +1671,8 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
|
||||
curwin->w_virtcol = (colnr_T)((vcol < 0) ? 0 : vcol);
|
||||
|
||||
// Advance the cursor until we reach the right screen column.
|
||||
last_vcol = 0;
|
||||
ptr = get_cursor_line_ptr();
|
||||
int last_vcol = 0;
|
||||
char *ptr = get_cursor_line_ptr();
|
||||
chartabsize_T cts;
|
||||
init_chartabsize_arg(&cts, curwin, 0, 0, ptr, ptr);
|
||||
while (cts.cts_vcol <= (int)curwin->w_virtcol) {
|
||||
@ -1872,9 +1862,7 @@ static bool del_char_after_col(int limit_col)
|
||||
/// @param no_simplify do not include modifiers into the key
|
||||
int get_literal(bool no_simplify)
|
||||
{
|
||||
int cc;
|
||||
int nc;
|
||||
int i;
|
||||
bool hex = false;
|
||||
bool octal = false;
|
||||
int unicode = 0;
|
||||
@ -1884,8 +1872,8 @@ int get_literal(bool no_simplify)
|
||||
}
|
||||
|
||||
no_mapping++; // don't map the next key hits
|
||||
cc = 0;
|
||||
i = 0;
|
||||
int cc = 0;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
nc = plain_vgetc();
|
||||
if (!no_simplify) {
|
||||
@ -2313,15 +2301,13 @@ int stop_arrow(void)
|
||||
/// @param nomove <c-\><c-o>, don't move cursor
|
||||
static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
stop_redo_ins();
|
||||
replace_flush(); // abandon replace stack
|
||||
|
||||
// Save the inserted text for later redo with ^@ and CTRL-A.
|
||||
// Don't do it when "restart_edit" was set and nothing was inserted,
|
||||
// otherwise CTRL-O w and then <Left> will clear "last_insert".
|
||||
ptr = get_inserted();
|
||||
char *ptr = get_inserted();
|
||||
int added = ptr == NULL ? 0 : (int)strlen(ptr) - new_insert_skip;
|
||||
if (did_restart_edit == 0 || added > 0) {
|
||||
xfree(last_insert);
|
||||
@ -2432,11 +2418,9 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
|
||||
// Used for the replace command.
|
||||
void set_last_insert(int c)
|
||||
{
|
||||
char *s;
|
||||
|
||||
xfree(last_insert);
|
||||
last_insert = xmalloc(MB_MAXBYTES * 3 + 5);
|
||||
s = last_insert;
|
||||
char *s = last_insert;
|
||||
// Use the CTRL-V only when entering a special char
|
||||
if (c < ' ' || c == DEL) {
|
||||
*s++ = Ctrl_V;
|
||||
@ -2489,7 +2473,6 @@ void beginline(int flags)
|
||||
int oneright(void)
|
||||
{
|
||||
char *ptr;
|
||||
int l;
|
||||
|
||||
if (virtual_active()) {
|
||||
pos_T prevpos = curwin->w_cursor;
|
||||
@ -2509,7 +2492,7 @@ int oneright(void)
|
||||
return FAIL; // already at the very end
|
||||
}
|
||||
|
||||
l = utfc_ptr2len(ptr);
|
||||
int l = utfc_ptr2len(ptr);
|
||||
|
||||
// move "l" bytes right, but don't end up on the NUL, unless 'virtualedit'
|
||||
// contains "onemore".
|
||||
@ -2526,7 +2509,6 @@ int oneright(void)
|
||||
int oneleft(void)
|
||||
{
|
||||
if (virtual_active()) {
|
||||
int width;
|
||||
int v = getviscol();
|
||||
|
||||
if (v == 0) {
|
||||
@ -2534,7 +2516,7 @@ int oneleft(void)
|
||||
}
|
||||
|
||||
// We might get stuck on 'showbreak', skip over it.
|
||||
width = 1;
|
||||
int width = 1;
|
||||
while (true) {
|
||||
coladvance(v - width);
|
||||
// getviscol() is slow, skip it when 'showbreak' is empty,
|
||||
@ -2692,11 +2674,9 @@ int cursor_down(int n, int upd_topline)
|
||||
int stuff_inserted(int c, int count, int no_esc)
|
||||
{
|
||||
char *esc_ptr;
|
||||
char *ptr;
|
||||
char *last_ptr;
|
||||
char last = NUL;
|
||||
|
||||
ptr = get_last_insert();
|
||||
char *ptr = get_last_insert();
|
||||
if (ptr == NULL) {
|
||||
emsg(_(e_noinstext));
|
||||
return FAIL;
|
||||
@ -2714,7 +2694,7 @@ int stuff_inserted(int c, int count, int no_esc)
|
||||
// when the last char is either "0" or "^" it will be quoted if no ESC
|
||||
// comes after it OR if it will inserted more than once and "ptr"
|
||||
// starts with ^D. -- Acevedo
|
||||
last_ptr = (esc_ptr ? esc_ptr : ptr + strlen(ptr)) - 1;
|
||||
char *last_ptr = (esc_ptr ? esc_ptr : ptr + strlen(ptr)) - 1;
|
||||
if (last_ptr >= ptr && (*last_ptr == '0' || *last_ptr == '^')
|
||||
&& (no_esc || (*ptr == Ctrl_D && count > 1))) {
|
||||
last = *last_ptr;
|
||||
@ -2758,14 +2738,11 @@ char *get_last_insert(void)
|
||||
// Returns pointer to allocated memory (must be freed) or NULL.
|
||||
char *get_last_insert_save(void)
|
||||
{
|
||||
char *s;
|
||||
int len;
|
||||
|
||||
if (last_insert == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
s = xstrdup(last_insert + last_insert_skip);
|
||||
len = (int)strlen(s);
|
||||
char *s = xstrdup(last_insert + last_insert_skip);
|
||||
int len = (int)strlen(s);
|
||||
if (len > 0 && s[len - 1] == ESC) { // remove trailing ESC
|
||||
s[len - 1] = NUL;
|
||||
}
|
||||
@ -2843,9 +2820,8 @@ void replace_push(int c)
|
||||
int replace_push_mb(char *p)
|
||||
{
|
||||
int l = utfc_ptr2len(p);
|
||||
int j;
|
||||
|
||||
for (j = l - 1; j >= 0; j--) {
|
||||
for (int j = l - 1; j >= 0; j--) {
|
||||
replace_push(p[j]);
|
||||
}
|
||||
return l;
|
||||
@ -2896,11 +2872,10 @@ static void mb_replace_pop_ins(int cc)
|
||||
{
|
||||
int n;
|
||||
uint8_t buf[MB_MAXBYTES + 1];
|
||||
int i;
|
||||
|
||||
if ((n = MB_BYTE2LEN(cc)) > 1) {
|
||||
buf[0] = (uint8_t)cc;
|
||||
for (i = 1; i < n; i++) {
|
||||
for (int i = 1; i < n; i++) {
|
||||
buf[i] = (uint8_t)replace_pop();
|
||||
}
|
||||
ins_bytes_len((char *)buf, (size_t)n);
|
||||
@ -2922,14 +2897,14 @@ static void mb_replace_pop_ins(int cc)
|
||||
|
||||
buf[0] = (uint8_t)c;
|
||||
assert(n > 1);
|
||||
for (i = 1; i < n; i++) {
|
||||
for (int i = 1; i < n; i++) {
|
||||
buf[i] = (uint8_t)replace_pop();
|
||||
}
|
||||
if (utf_iscomposing(utf_ptr2char((char *)buf))) {
|
||||
ins_bytes_len((char *)buf, (size_t)n);
|
||||
} else {
|
||||
// Not a composing char, put it back.
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
replace_push(buf[i]);
|
||||
}
|
||||
break;
|
||||
@ -2955,11 +2930,10 @@ static void replace_flush(void)
|
||||
// using composing characters, use del_char_after_col() instead of del_char().
|
||||
static void replace_do_bs(int limit_col)
|
||||
{
|
||||
int cc;
|
||||
colnr_T start_vcol;
|
||||
const int l_State = State;
|
||||
|
||||
cc = replace_pop();
|
||||
int cc = replace_pop();
|
||||
if (cc > 0) {
|
||||
int orig_len = 0;
|
||||
int orig_vcols = 0;
|
||||
@ -3235,7 +3209,6 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
static void ins_reg(void)
|
||||
{
|
||||
bool need_redraw = false;
|
||||
int regname;
|
||||
int literally = 0;
|
||||
int vis_active = VIsual_active;
|
||||
|
||||
@ -3253,7 +3226,7 @@ static void ins_reg(void)
|
||||
// deleted when ESC is hit.
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
regname = plain_vgetc();
|
||||
int regname = plain_vgetc();
|
||||
LANGMAP_ADJUST(regname, true);
|
||||
if (regname == Ctrl_R || regname == Ctrl_O || regname == Ctrl_P) {
|
||||
// Get a third key for literal register insertion
|
||||
@ -3324,8 +3297,6 @@ static void ins_reg(void)
|
||||
// CTRL-G commands in Insert mode.
|
||||
static void ins_ctrl_g(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
// Right after CTRL-X the cursor will be after the ruler.
|
||||
setcursor();
|
||||
|
||||
@ -3333,7 +3304,7 @@ static void ins_ctrl_g(void)
|
||||
// deleted when ESC is hit.
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
c = plain_vgetc();
|
||||
int c = plain_vgetc();
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
switch (c) {
|
||||
@ -3709,9 +3680,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
{
|
||||
int cc;
|
||||
int temp = 0; // init for GCC
|
||||
colnr_T save_col;
|
||||
bool did_backspace = false;
|
||||
int in_indent;
|
||||
int cpc[MAX_MCO]; // composing characters
|
||||
bool call_fix_indent = false;
|
||||
|
||||
@ -3736,7 +3705,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
if (stop_arrow() == FAIL) {
|
||||
return false;
|
||||
}
|
||||
in_indent = inindent(0);
|
||||
int in_indent = inindent(0);
|
||||
if (in_indent) {
|
||||
can_cindent = false;
|
||||
}
|
||||
@ -3822,7 +3791,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
State = MODE_NORMAL;
|
||||
// restore characters (blanks) deleted after cursor
|
||||
while (cc > 0) {
|
||||
save_col = curwin->w_cursor.col;
|
||||
colnr_T save_col = curwin->w_cursor.col;
|
||||
mb_replace_pop_ins(cc);
|
||||
curwin->w_cursor.col = save_col;
|
||||
cc = replace_pop();
|
||||
@ -3843,7 +3812,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
if (mode == BACKSPACE_LINE
|
||||
&& (curbuf->b_p_ai || cindent_on())
|
||||
&& !revins_on) {
|
||||
save_col = curwin->w_cursor.col;
|
||||
colnr_T save_col = curwin->w_cursor.col;
|
||||
beginline(BL_WHITE);
|
||||
if (curwin->w_cursor.col < save_col) {
|
||||
mincol = curwin->w_cursor.col;
|
||||
@ -3864,14 +3833,13 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
&& (!*inserted_space_p || arrow_used)))))) {
|
||||
colnr_T vcol;
|
||||
colnr_T want_vcol;
|
||||
colnr_T start_vcol;
|
||||
|
||||
*inserted_space_p = false;
|
||||
// Compute the virtual column where we want to be. Since
|
||||
// 'showbreak' may get in the way, need to get the last column of
|
||||
// the previous character.
|
||||
getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
|
||||
start_vcol = vcol;
|
||||
colnr_T start_vcol = vcol;
|
||||
dec_cursor();
|
||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);
|
||||
inc_cursor();
|
||||
@ -4017,14 +3985,13 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
||||
|
||||
static void ins_left(void)
|
||||
{
|
||||
pos_T tpos;
|
||||
const bool end_change = dont_sync_undo == kFalse; // end undoable change
|
||||
|
||||
if ((fdo_flags & FDO_HOR) && KeyTyped) {
|
||||
foldOpenCursor();
|
||||
}
|
||||
undisplay_dollar();
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (oneleft() == OK) {
|
||||
start_arrow_with_change(&tpos, end_change);
|
||||
if (!end_change) {
|
||||
@ -4050,13 +4017,11 @@ static void ins_left(void)
|
||||
|
||||
static void ins_home(int c)
|
||||
{
|
||||
pos_T tpos;
|
||||
|
||||
if ((fdo_flags & FDO_HOR) && KeyTyped) {
|
||||
foldOpenCursor();
|
||||
}
|
||||
undisplay_dollar();
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (c == K_C_HOME) {
|
||||
curwin->w_cursor.lnum = 1;
|
||||
}
|
||||
@ -4068,13 +4033,11 @@ static void ins_home(int c)
|
||||
|
||||
static void ins_end(int c)
|
||||
{
|
||||
pos_T tpos;
|
||||
|
||||
if ((fdo_flags & FDO_HOR) && KeyTyped) {
|
||||
foldOpenCursor();
|
||||
}
|
||||
undisplay_dollar();
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (c == K_C_END) {
|
||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||
}
|
||||
@ -4166,12 +4129,11 @@ static void ins_s_right(void)
|
||||
/// @param startcol when true move to Insstart.col
|
||||
static void ins_up(bool startcol)
|
||||
{
|
||||
pos_T tpos;
|
||||
linenr_T old_topline = curwin->w_topline;
|
||||
int old_topfill = curwin->w_topfill;
|
||||
|
||||
undisplay_dollar();
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (cursor_up(1, true) == OK) {
|
||||
if (startcol) {
|
||||
coladvance(getvcol_nolist(&Insstart));
|
||||
@ -4189,8 +4151,6 @@ static void ins_up(bool startcol)
|
||||
|
||||
static void ins_pageup(void)
|
||||
{
|
||||
pos_T tpos;
|
||||
|
||||
undisplay_dollar();
|
||||
|
||||
if (mod_mask & MOD_MASK_CTRL) {
|
||||
@ -4202,7 +4162,7 @@ static void ins_pageup(void)
|
||||
return;
|
||||
}
|
||||
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (onepage(BACKWARD, 1) == OK) {
|
||||
start_arrow(&tpos);
|
||||
can_cindent = true;
|
||||
@ -4214,12 +4174,11 @@ static void ins_pageup(void)
|
||||
/// @param startcol when true move to Insstart.col
|
||||
static void ins_down(bool startcol)
|
||||
{
|
||||
pos_T tpos;
|
||||
linenr_T old_topline = curwin->w_topline;
|
||||
int old_topfill = curwin->w_topfill;
|
||||
|
||||
undisplay_dollar();
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (cursor_down(1, true) == OK) {
|
||||
if (startcol) {
|
||||
coladvance(getvcol_nolist(&Insstart));
|
||||
@ -4237,8 +4196,6 @@ static void ins_down(bool startcol)
|
||||
|
||||
static void ins_pagedown(void)
|
||||
{
|
||||
pos_T tpos;
|
||||
|
||||
undisplay_dollar();
|
||||
|
||||
if (mod_mask & MOD_MASK_CTRL) {
|
||||
@ -4250,7 +4207,7 @@ static void ins_pagedown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
tpos = curwin->w_cursor;
|
||||
pos_T tpos = curwin->w_cursor;
|
||||
if (onepage(FORWARD, 1) == OK) {
|
||||
start_arrow(&tpos);
|
||||
can_cindent = true;
|
||||
@ -4528,7 +4485,6 @@ bool ins_eol(int c)
|
||||
// done.
|
||||
static int ins_digraph(void)
|
||||
{
|
||||
int c;
|
||||
bool did_putchar = false;
|
||||
|
||||
pc_status = PC_STATUS_UNSET;
|
||||
@ -4545,7 +4501,7 @@ static int ins_digraph(void)
|
||||
// mode message to be deleted when ESC is hit
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
c = plain_vgetc();
|
||||
int c = plain_vgetc();
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
if (did_putchar) {
|
||||
@ -4597,9 +4553,7 @@ static int ins_digraph(void)
|
||||
// Returns the char to be inserted, or NUL if none found.
|
||||
int ins_copychar(linenr_T lnum)
|
||||
{
|
||||
int c;
|
||||
char *ptr, *prev_ptr;
|
||||
char *line;
|
||||
char *ptr;
|
||||
|
||||
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) {
|
||||
vim_beep(BO_COPY);
|
||||
@ -4608,8 +4562,8 @@ int ins_copychar(linenr_T lnum)
|
||||
|
||||
// try to advance to the cursor column
|
||||
validate_virtcol();
|
||||
line = ml_get(lnum);
|
||||
prev_ptr = line;
|
||||
char *line = ml_get(lnum);
|
||||
char *prev_ptr = line;
|
||||
|
||||
chartabsize_T cts;
|
||||
init_chartabsize_arg(&cts, curwin, lnum, 0, line, line);
|
||||
@ -4625,7 +4579,7 @@ int ins_copychar(linenr_T lnum)
|
||||
}
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
c = utf_ptr2char(ptr);
|
||||
int c = utf_ptr2char(ptr);
|
||||
if (c == NUL) {
|
||||
vim_beep(BO_COPY);
|
||||
}
|
||||
@ -4811,9 +4765,8 @@ void set_can_cindent(bool val)
|
||||
int ins_apply_autocmds(event_T event)
|
||||
{
|
||||
varnumber_T tick = buf_get_changedtick(curbuf);
|
||||
int r;
|
||||
|
||||
r = apply_autocmds(event, NULL, NULL, false, curbuf);
|
||||
int r = apply_autocmds(event, NULL, NULL, false, curbuf);
|
||||
|
||||
// If u_savesub() was called then we are not prepared to start
|
||||
// a new line. Call u_save() with no contents to fix that.
|
||||
|
@ -1867,14 +1867,13 @@ notify:
|
||||
void *eval_for_line(const char *arg, bool *errp, exarg_T *eap, evalarg_T *const evalarg)
|
||||
{
|
||||
forinfo_T *fi = xcalloc(1, sizeof(forinfo_T));
|
||||
const char *expr;
|
||||
typval_T tv;
|
||||
list_T *l;
|
||||
const bool skip = !(evalarg->eval_flags & EVAL_EVALUATE);
|
||||
|
||||
*errp = true; // Default: there is an error.
|
||||
|
||||
expr = skip_var_list(arg, &fi->fi_varcount, &fi->fi_semicolon);
|
||||
const char *expr = skip_var_list(arg, &fi->fi_varcount, &fi->fi_semicolon);
|
||||
if (expr == NULL) {
|
||||
return fi;
|
||||
}
|
||||
@ -2005,13 +2004,12 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
bool got_eq = false;
|
||||
char *p;
|
||||
|
||||
if (cmdidx == CMD_let || cmdidx == CMD_const) {
|
||||
xp->xp_context = EXPAND_USER_VARS;
|
||||
if (strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#") == NULL) {
|
||||
// ":let var1 var2 ...": find last space.
|
||||
for (p = arg + strlen(arg); p >= arg;) {
|
||||
for (char *p = arg + strlen(arg); p >= arg;) {
|
||||
xp->xp_pattern = p;
|
||||
MB_PTR_BACK(arg, p);
|
||||
if (ascii_iswhite(*p)) {
|
||||
@ -2343,14 +2341,12 @@ void clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
|
||||
/// @return OK or FAIL.
|
||||
int eval0(char *arg, typval_T *rettv, exarg_T *eap, evalarg_T *const evalarg)
|
||||
{
|
||||
int ret;
|
||||
char *p;
|
||||
const int did_emsg_before = did_emsg;
|
||||
const int called_emsg_before = called_emsg;
|
||||
bool end_error = false;
|
||||
|
||||
p = skipwhite(arg);
|
||||
ret = eval1(&p, rettv, evalarg);
|
||||
char *p = skipwhite(arg);
|
||||
int ret = eval1(&p, rettv, evalarg);
|
||||
|
||||
if (ret != FAIL) {
|
||||
end_error = !ends_excmd(*p);
|
||||
@ -7239,10 +7235,9 @@ void set_vim_var_tv(const VimVarIndex idx, typval_T *const tv)
|
||||
void set_argv_var(char **argv, int argc)
|
||||
{
|
||||
list_T *l = tv_list_alloc(argc);
|
||||
int i;
|
||||
|
||||
tv_list_set_lock(l, VAR_FIXED);
|
||||
for (i = 0; i < argc; i++) {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
tv_list_append_string(l, (const char *const)argv[i], -1);
|
||||
TV_LIST_ITEM_TV(tv_list_last(l))->v_lock = VAR_FIXED;
|
||||
}
|
||||
|
@ -238,12 +238,8 @@ void do_ascii(exarg_T *eap)
|
||||
/// ":left", ":center" and ":right": align text.
|
||||
void ex_align(exarg_T *eap)
|
||||
{
|
||||
pos_T save_curpos;
|
||||
int len;
|
||||
int indent = 0;
|
||||
int new_indent;
|
||||
int has_tab;
|
||||
int width;
|
||||
|
||||
if (curwin->w_p_rl) {
|
||||
// switch left and right aligning
|
||||
@ -254,8 +250,8 @@ void ex_align(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
|
||||
width = atoi(eap->arg);
|
||||
save_curpos = curwin->w_cursor;
|
||||
int width = atoi(eap->arg);
|
||||
pos_T save_curpos = curwin->w_cursor;
|
||||
if (eap->cmdidx == CMD_left) { // width is used for new indent
|
||||
if (width >= 0) {
|
||||
indent = width;
|
||||
@ -284,8 +280,8 @@ void ex_align(exarg_T *eap)
|
||||
if (eap->cmdidx == CMD_left) { // left align
|
||||
new_indent = indent;
|
||||
} else {
|
||||
has_tab = false; // avoid uninit warnings
|
||||
len = linelen(eap->cmdidx == CMD_right ? &has_tab : NULL) - get_indent();
|
||||
int has_tab = false; // avoid uninit warnings
|
||||
int len = linelen(eap->cmdidx == CMD_right ? &has_tab : NULL) - get_indent();
|
||||
|
||||
if (len <= 0) { // skip blank lines
|
||||
continue;
|
||||
@ -328,26 +324,23 @@ void ex_align(exarg_T *eap)
|
||||
/// @return the length of the current line, excluding trailing white space.
|
||||
static int linelen(int *has_tab)
|
||||
{
|
||||
char *line;
|
||||
char *first;
|
||||
char *last;
|
||||
int len;
|
||||
|
||||
// Get the line. If it's empty bail out early (could be the empty string
|
||||
// for an unloaded buffer).
|
||||
line = get_cursor_line_ptr();
|
||||
char *line = get_cursor_line_ptr();
|
||||
if (*line == NUL) {
|
||||
return 0;
|
||||
}
|
||||
// find the first non-blank character
|
||||
first = skipwhite(line);
|
||||
char *first = skipwhite(line);
|
||||
|
||||
// find the character after the last non-blank character
|
||||
for (last = first + strlen(first);
|
||||
last > first && ascii_iswhite(last[-1]); last--) {}
|
||||
char save = *last;
|
||||
*last = NUL;
|
||||
len = linetabsize_str(line); // Get line length.
|
||||
int len = linetabsize_str(line); // Get line length.
|
||||
if (has_tab != NULL) { // Check for embedded TAB.
|
||||
*has_tab = vim_strchr(first, TAB) != NULL;
|
||||
}
|
||||
@ -451,19 +444,11 @@ static int sort_compare(const void *s1, const void *s2)
|
||||
void ex_sort(exarg_T *eap)
|
||||
{
|
||||
regmatch_T regmatch;
|
||||
int len;
|
||||
linenr_T lnum;
|
||||
int maxlen = 0;
|
||||
size_t count = (size_t)(eap->line2 - eap->line1) + 1;
|
||||
size_t i;
|
||||
char *p;
|
||||
char *s;
|
||||
char *s2;
|
||||
char c; // temporary character storage
|
||||
bool unique = false;
|
||||
linenr_T deleted;
|
||||
colnr_T start_col;
|
||||
colnr_T end_col;
|
||||
int sort_what = 0;
|
||||
|
||||
// Sorting one line is really quick!
|
||||
@ -483,7 +468,7 @@ void ex_sort(exarg_T *eap)
|
||||
size_t format_found = 0;
|
||||
bool change_occurred = false; // Buffer contents changed.
|
||||
|
||||
for (p = eap->arg; *p != NUL; p++) {
|
||||
for (char *p = eap->arg; *p != NUL; p++) {
|
||||
if (ascii_iswhite(*p)) {
|
||||
// Skip
|
||||
} else if (*p == 'i') {
|
||||
@ -516,7 +501,7 @@ void ex_sort(exarg_T *eap)
|
||||
eap->nextcmd = check_nextcmd(p);
|
||||
break;
|
||||
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
|
||||
s = skip_regexp_err(p + 1, *p, true);
|
||||
char *s = skip_regexp_err(p + 1, *p, true);
|
||||
if (s == NULL) {
|
||||
goto sortend;
|
||||
}
|
||||
@ -559,14 +544,14 @@ void ex_sort(exarg_T *eap)
|
||||
// matching and number conversion only has to be done once per line.
|
||||
// Also get the longest line length for allocating "sortbuf".
|
||||
for (lnum = eap->line1; lnum <= eap->line2; lnum++) {
|
||||
s = ml_get(lnum);
|
||||
len = (int)strlen(s);
|
||||
char *s = ml_get(lnum);
|
||||
int len = (int)strlen(s);
|
||||
if (maxlen < len) {
|
||||
maxlen = len;
|
||||
}
|
||||
|
||||
start_col = 0;
|
||||
end_col = len;
|
||||
colnr_T start_col = 0;
|
||||
colnr_T end_col = len;
|
||||
if (regmatch.regprog != NULL && vim_regexec(®match, s, 0)) {
|
||||
if (sort_rx) {
|
||||
start_col = (colnr_T)(regmatch.startp[0] - s);
|
||||
@ -581,11 +566,11 @@ void ex_sort(exarg_T *eap)
|
||||
if (sort_nr || sort_flt) {
|
||||
// Make sure vim_str2nr() doesn't read any digits past the end
|
||||
// of the match, by temporarily terminating the string there
|
||||
s2 = s + end_col;
|
||||
c = *s2;
|
||||
char *s2 = s + end_col;
|
||||
char c = *s2; // temporary character storage
|
||||
*s2 = NUL;
|
||||
// Sorting on number: Store the number itself.
|
||||
p = s + start_col;
|
||||
char *p = s + start_col;
|
||||
if (sort_nr) {
|
||||
if (sort_what & STR2NR_HEX) {
|
||||
s = skiptohex(p);
|
||||
@ -660,7 +645,7 @@ void ex_sort(exarg_T *eap)
|
||||
change_occurred = true;
|
||||
}
|
||||
|
||||
s = ml_get(get_lnum);
|
||||
char *s = ml_get(get_lnum);
|
||||
size_t bytelen = strlen(s) + 1; // include EOL in bytelen
|
||||
old_count += (bcount_t)bytelen;
|
||||
if (!unique || i == 0 || string_compare(s, sortbuf1) != 0) {
|
||||
@ -688,7 +673,7 @@ void ex_sort(exarg_T *eap)
|
||||
}
|
||||
|
||||
// Adjust marks for deleted (or added) lines and prepare for displaying.
|
||||
deleted = (linenr_T)count - (lnum - eap->line2);
|
||||
linenr_T deleted = (linenr_T)count - (lnum - eap->line2);
|
||||
if (deleted > 0) {
|
||||
mark_adjust(eap->line2 - deleted, eap->line2, MAXLNUM, -deleted, kExtmarkNOOP);
|
||||
msgmore(-deleted);
|
||||
@ -954,14 +939,9 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
||||
linenr_T line2 = eap->line2; // end of range
|
||||
char *newcmd = NULL; // the new command
|
||||
bool free_newcmd = false; // need to free() newcmd
|
||||
char *t;
|
||||
char *p;
|
||||
char *trailarg;
|
||||
int scroll_save = msg_scroll;
|
||||
|
||||
//
|
||||
// Disallow shell commands in secure mode
|
||||
//
|
||||
if (check_secure()) {
|
||||
return;
|
||||
}
|
||||
@ -977,7 +957,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
||||
bool ins_prevcmd = forceit;
|
||||
|
||||
// Skip leading white space to avoid a strange error with some shells.
|
||||
trailarg = skipwhite(arg);
|
||||
char *trailarg = skipwhite(arg);
|
||||
do {
|
||||
size_t len = strlen(trailarg) + 1;
|
||||
if (newcmd != NULL) {
|
||||
@ -990,7 +970,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
||||
}
|
||||
len += strlen(prevcmd);
|
||||
}
|
||||
t = xmalloc(len);
|
||||
char *t = xmalloc(len);
|
||||
*t = NUL;
|
||||
if (newcmd != NULL) {
|
||||
STRCAT(t, newcmd);
|
||||
@ -998,7 +978,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
||||
if (ins_prevcmd) {
|
||||
STRCAT(t, prevcmd);
|
||||
}
|
||||
p = t + strlen(t);
|
||||
char *p = t + strlen(t);
|
||||
STRCAT(t, trailarg);
|
||||
xfree(newcmd);
|
||||
newcmd = t;
|
||||
@ -1099,10 +1079,6 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
|
||||
{
|
||||
char *itmp = NULL;
|
||||
char *otmp = NULL;
|
||||
linenr_T linecount;
|
||||
linenr_T read_linecount;
|
||||
pos_T cursor_save;
|
||||
char *cmd_buf;
|
||||
buf_T *old_curbuf = curbuf;
|
||||
int shell_flags = 0;
|
||||
const pos_T orig_start = curbuf->b_op_start;
|
||||
@ -1118,8 +1094,8 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
|
||||
// regions of the buffer for foldUpdate(), linecount, etc.
|
||||
cmdmod.cmod_flags &= ~CMOD_LOCKMARKS;
|
||||
|
||||
cursor_save = curwin->w_cursor;
|
||||
linecount = line2 - line1 + 1;
|
||||
pos_T cursor_save = curwin->w_cursor;
|
||||
linenr_T linecount = line2 - line1 + 1;
|
||||
curwin->w_cursor.lnum = line1;
|
||||
curwin->w_cursor.col = 0;
|
||||
changed_line_abv_curs();
|
||||
@ -1184,7 +1160,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
|
||||
}
|
||||
|
||||
// Create the shell command in allocated memory.
|
||||
cmd_buf = make_filter_cmd(cmd, itmp, otmp);
|
||||
char *cmd_buf = make_filter_cmd(cmd, itmp, otmp);
|
||||
ui_cursor_goto(Rows - 1, 0);
|
||||
|
||||
if (do_out) {
|
||||
@ -1194,7 +1170,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
|
||||
}
|
||||
redraw_curbuf_later(UPD_VALID);
|
||||
}
|
||||
read_linecount = curbuf->b_ml.ml_line_count;
|
||||
linenr_T read_linecount = curbuf->b_ml.ml_line_count;
|
||||
|
||||
// Pass on the kShellOptDoOut flag when the output is being redirected.
|
||||
call_shell(cmd_buf, (ShellOpts)(kShellOptFilter | shell_flags), NULL);
|
||||
@ -1534,10 +1510,7 @@ void print_line(linenr_T lnum, int use_number, int list)
|
||||
|
||||
int rename_buffer(char *new_fname)
|
||||
{
|
||||
char *fname, *sfname, *xfname;
|
||||
buf_T *buf;
|
||||
|
||||
buf = curbuf;
|
||||
buf_T *buf = curbuf;
|
||||
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf);
|
||||
// buffer changed, don't change name now
|
||||
if (buf != curbuf) {
|
||||
@ -1551,9 +1524,9 @@ int rename_buffer(char *new_fname)
|
||||
// name, which will become the alternate file name.
|
||||
// But don't set the alternate file name if the buffer didn't have a
|
||||
// name.
|
||||
fname = curbuf->b_ffname;
|
||||
sfname = curbuf->b_sfname;
|
||||
xfname = curbuf->b_fname;
|
||||
char *fname = curbuf->b_ffname;
|
||||
char *sfname = curbuf->b_sfname;
|
||||
char *xfname = curbuf->b_fname;
|
||||
curbuf->b_ffname = NULL;
|
||||
curbuf->b_sfname = NULL;
|
||||
if (setfname(curbuf, new_fname, NULL, true) == FAIL) {
|
||||
@ -1647,7 +1620,6 @@ int do_write(exarg_T *eap)
|
||||
{
|
||||
int other;
|
||||
char *fname = NULL; // init to shut up gcc
|
||||
char *ffname;
|
||||
int retval = FAIL;
|
||||
char *free_fname = NULL;
|
||||
buf_T *alt_buf = NULL;
|
||||
@ -1657,7 +1629,7 @@ int do_write(exarg_T *eap)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
ffname = eap->arg;
|
||||
char *ffname = eap->arg;
|
||||
if (*ffname == NUL) {
|
||||
if (eap->cmdidx == CMD_saveas) {
|
||||
emsg(_(e_argreq));
|
||||
@ -2931,12 +2903,9 @@ void ex_change(exarg_T *eap)
|
||||
|
||||
void ex_z(exarg_T *eap)
|
||||
{
|
||||
char *x;
|
||||
int64_t bigness;
|
||||
char *kind;
|
||||
int minus = 0;
|
||||
linenr_T start, end, curs, i;
|
||||
int j;
|
||||
linenr_T lnum = eap->line2;
|
||||
|
||||
// Vi compatible: ":z!" uses display height, without a count uses
|
||||
@ -2952,8 +2921,8 @@ void ex_z(exarg_T *eap)
|
||||
bigness = 1;
|
||||
}
|
||||
|
||||
x = eap->arg;
|
||||
kind = x;
|
||||
char *x = eap->arg;
|
||||
char *kind = x;
|
||||
if (*kind == '-' || *kind == '+' || *kind == '='
|
||||
|| *kind == '^' || *kind == '.') {
|
||||
x++;
|
||||
@ -3041,7 +3010,7 @@ void ex_z(exarg_T *eap)
|
||||
if (minus && i == lnum) {
|
||||
msg_putchar('\n');
|
||||
|
||||
for (j = 1; j < Columns; j++) {
|
||||
for (int j = 1; j < Columns; j++) {
|
||||
msg_putchar('-');
|
||||
}
|
||||
}
|
||||
@ -3051,7 +3020,7 @@ void ex_z(exarg_T *eap)
|
||||
if (minus && i == lnum) {
|
||||
msg_putchar('\n');
|
||||
|
||||
for (j = 1; j < Columns; j++) {
|
||||
for (int j = 1; j < Columns; j++) {
|
||||
msg_putchar('-');
|
||||
}
|
||||
}
|
||||
@ -4386,7 +4355,6 @@ void ex_global(exarg_T *eap)
|
||||
char *pat;
|
||||
regmmatch_T regmatch;
|
||||
int match;
|
||||
int which_pat;
|
||||
|
||||
// When nesting the command works on one line. This allows for
|
||||
// ":g/found/v/notfound/command".
|
||||
@ -4403,7 +4371,7 @@ void ex_global(exarg_T *eap)
|
||||
type = (uint8_t)(*eap->cmd);
|
||||
}
|
||||
cmd = eap->arg;
|
||||
which_pat = RE_LAST; // default: use last used regexp
|
||||
int which_pat = RE_LAST; // default: use last used regexp
|
||||
|
||||
// undocumented vi feature:
|
||||
// "\/" and "\?": use previous search pattern.
|
||||
|
@ -101,7 +101,6 @@ void ex_perldo(exarg_T *eap)
|
||||
/// @return FAIL for failure, OK otherwise
|
||||
int autowrite(buf_T *buf, int forceit)
|
||||
{
|
||||
int r;
|
||||
bufref_T bufref;
|
||||
|
||||
if (!(p_aw || p_awa) || !p_write
|
||||
@ -111,7 +110,7 @@ int autowrite(buf_T *buf, int forceit)
|
||||
return FAIL;
|
||||
}
|
||||
set_bufref(&bufref, buf);
|
||||
r = buf_write_all(buf, forceit);
|
||||
int r = buf_write_all(buf, forceit);
|
||||
|
||||
// Writing may succeed but the buffer still changed, e.g., when there is a
|
||||
// conversion error. We do want to return FAIL then.
|
||||
@ -273,9 +272,7 @@ bool can_abandon(buf_T *buf, int forceit)
|
||||
/// Add a buffer number to "bufnrs", unless it's already there.
|
||||
static void add_bufnum(int *bufnrs, int *bufnump, int nr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < *bufnump; i++) {
|
||||
for (int i = 0; i < *bufnump; i++) {
|
||||
if (bufnrs[i] == nr) {
|
||||
return;
|
||||
}
|
||||
@ -296,11 +293,9 @@ static void add_bufnum(int *bufnrs, int *bufnump, int nr)
|
||||
bool check_changed_any(bool hidden, bool unload)
|
||||
{
|
||||
bool ret = false;
|
||||
int save;
|
||||
int i;
|
||||
int bufnum = 0;
|
||||
size_t bufcount = 0;
|
||||
int *bufnrs;
|
||||
|
||||
// Make a list of all buffers, with the most important ones first.
|
||||
FOR_ALL_BUFFERS(buf) {
|
||||
@ -311,7 +306,7 @@ bool check_changed_any(bool hidden, bool unload)
|
||||
return false;
|
||||
}
|
||||
|
||||
bufnrs = xmalloc(sizeof(*bufnrs) * bufcount);
|
||||
int *bufnrs = xmalloc(sizeof(*bufnrs) * bufcount);
|
||||
|
||||
// curbuf
|
||||
bufnrs[bufnum++] = curbuf->b_fnum;
|
||||
@ -379,7 +374,7 @@ bool check_changed_any(bool hidden, bool unload)
|
||||
? semsg(_("E947: Job still running in buffer \"%s\""), buf->b_fname)
|
||||
: semsg(_("E162: No write since last change for buffer \"%s\""),
|
||||
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) {
|
||||
save = no_wait_return;
|
||||
int save = no_wait_return;
|
||||
no_wait_return = false;
|
||||
wait_return(false);
|
||||
no_wait_return = save;
|
||||
@ -429,12 +424,11 @@ int check_fname(void)
|
||||
/// @return FAIL for failure, OK otherwise
|
||||
int buf_write_all(buf_T *buf, int forceit)
|
||||
{
|
||||
int retval;
|
||||
buf_T *old_curbuf = curbuf;
|
||||
|
||||
retval = (buf_write(buf, buf->b_ffname, buf->b_fname,
|
||||
1, buf->b_ml.ml_line_count, NULL,
|
||||
false, forceit, true, false));
|
||||
int retval = (buf_write(buf, buf->b_ffname, buf->b_fname,
|
||||
1, buf->b_ml.ml_line_count, NULL,
|
||||
false, forceit, true, false));
|
||||
if (curbuf != old_curbuf) {
|
||||
msg_source(HL_ATTR(HLF_W));
|
||||
msg(_("Warning: Entered other buffer unexpectedly (check autocommands)"), 0);
|
||||
@ -684,9 +678,7 @@ void ex_listdo(exarg_T *eap)
|
||||
/// ":compiler[!] {name}"
|
||||
void ex_compiler(exarg_T *eap)
|
||||
{
|
||||
char *buf;
|
||||
char *old_cur_comp = NULL;
|
||||
char *p;
|
||||
|
||||
if (*eap->arg == NUL) {
|
||||
// List all compiler scripts.
|
||||
@ -696,7 +688,7 @@ void ex_compiler(exarg_T *eap)
|
||||
}
|
||||
|
||||
size_t bufsize = strlen(eap->arg) + 14;
|
||||
buf = xmalloc(bufsize);
|
||||
char *buf = xmalloc(bufsize);
|
||||
|
||||
if (eap->forceit) {
|
||||
// ":compiler! {name}" sets global options
|
||||
@ -726,7 +718,7 @@ void ex_compiler(exarg_T *eap)
|
||||
do_cmdline_cmd(":delcommand CompilerSet");
|
||||
|
||||
// Set "b:current_compiler" from "current_compiler".
|
||||
p = get_var_value("g:current_compiler");
|
||||
char *p = get_var_value("g:current_compiler");
|
||||
if (p != NULL) {
|
||||
set_internal_string_var("b:current_compiler", p);
|
||||
}
|
||||
@ -809,7 +801,6 @@ static void script_host_do_range(char *name, exarg_T *eap)
|
||||
void ex_drop(exarg_T *eap)
|
||||
{
|
||||
bool split = false;
|
||||
buf_T *buf;
|
||||
|
||||
// Check if the first argument is already being edited in a window. If
|
||||
// so, jump to that window.
|
||||
@ -837,7 +828,7 @@ void ex_drop(exarg_T *eap)
|
||||
// ":drop file ...": Edit the first argument. Jump to an existing
|
||||
// window if possible, edit in current window if the current buffer
|
||||
// can be abandoned, otherwise open a new window.
|
||||
buf = buflist_findnr(ARGLIST[0].ae_fnum);
|
||||
buf_T *buf = buflist_findnr(ARGLIST[0].ae_fnum);
|
||||
|
||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||
if (wp->w_buffer == buf) {
|
||||
|
@ -333,16 +333,12 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
|
||||
linenr_T *breakpoint = NULL; // ptr to breakpoint field in cookie
|
||||
int *dbg_tick = NULL; // ptr to dbg_tick field in cookie
|
||||
struct dbg_stuff debug_saved; // saved things for debug mode
|
||||
int initial_trylevel;
|
||||
msglist_T **saved_msg_list = NULL;
|
||||
msglist_T *private_msg_list;
|
||||
|
||||
// "fgetline" and "cookie" passed to do_one_cmd()
|
||||
char *(*cmd_getline)(int, void *, int, bool);
|
||||
void *cmd_cookie;
|
||||
struct loop_cookie cmd_loop_cookie;
|
||||
void *real_cookie;
|
||||
int getline_is_func;
|
||||
static int call_depth = 0; // recursiveness
|
||||
|
||||
// For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
|
||||
@ -351,7 +347,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
|
||||
// combine the messages stored by an earlier invocation of do_one_cmd()
|
||||
// with the command name of the later one. This would happen when
|
||||
// BufWritePost autocommands are executed after a write error.
|
||||
saved_msg_list = msg_list;
|
||||
msglist_T **saved_msg_list = msg_list;
|
||||
msg_list = &private_msg_list;
|
||||
private_msg_list = NULL;
|
||||
|
||||
@ -371,10 +367,10 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
|
||||
|
||||
ga_init(&lines_ga, (int)sizeof(wcmd_T), 10);
|
||||
|
||||
real_cookie = getline_cookie(fgetline, cookie);
|
||||
void *real_cookie = getline_cookie(fgetline, cookie);
|
||||
|
||||
// Inside a function use a higher nesting level.
|
||||
getline_is_func = getline_equal(fgetline, cookie, get_func_line);
|
||||
bool getline_is_func = getline_equal(fgetline, cookie, get_func_line);
|
||||
if (getline_is_func && ex_nesting_level == func_level(real_cookie)) {
|
||||
ex_nesting_level++;
|
||||
}
|
||||
@ -406,7 +402,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
|
||||
CLEAR_FIELD(debug_saved);
|
||||
}
|
||||
|
||||
initial_trylevel = trylevel;
|
||||
int initial_trylevel = trylevel;
|
||||
|
||||
// "did_throw" will be set to true when an exception is being thrown.
|
||||
did_throw = false;
|
||||
@ -5328,8 +5324,6 @@ static void ex_edit(exarg_T *eap)
|
||||
/// @param old_curwin curwin before doing a split or NULL
|
||||
void do_exedit(exarg_T *eap, win_T *old_curwin)
|
||||
{
|
||||
int n;
|
||||
|
||||
// ":vi" command ends Ex mode.
|
||||
if (exmode_active && (eap->cmdidx == CMD_visual
|
||||
|| eap->cmdidx == CMD_view)) {
|
||||
@ -5380,7 +5374,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
|
||||
if (*eap->arg != NUL && text_or_buf_locked()) {
|
||||
return;
|
||||
}
|
||||
n = readonlymode;
|
||||
int n = readonlymode;
|
||||
if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) {
|
||||
readonlymode = true;
|
||||
} else if (eap->cmdidx == CMD_enew) {
|
||||
@ -5428,7 +5422,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
|
||||
if (eap->do_ecmd_cmd != NULL) {
|
||||
do_cmdline_cmd(eap->do_ecmd_cmd);
|
||||
}
|
||||
n = curwin->w_arg_idx_invalid;
|
||||
int n = curwin->w_arg_idx_invalid;
|
||||
check_arg_idx(curwin);
|
||||
if (n != curwin->w_arg_idx_invalid) {
|
||||
maketitle();
|
||||
@ -6498,8 +6492,7 @@ static void ex_normal(exarg_T *eap)
|
||||
|
||||
// Count the number of characters to be escaped.
|
||||
int l;
|
||||
char *p;
|
||||
for (p = eap->arg; *p != NUL; p++) {
|
||||
for (char *p = eap->arg; *p != NUL; p++) {
|
||||
for (l = utfc_ptr2len(p) - 1; l > 0; l--) {
|
||||
if (*++p == (char)K_SPECIAL) { // trailbyte K_SPECIAL
|
||||
len += 2;
|
||||
@ -6509,7 +6502,7 @@ static void ex_normal(exarg_T *eap)
|
||||
if (len > 0) {
|
||||
arg = xmalloc(strlen(eap->arg) + (size_t)len + 1);
|
||||
len = 0;
|
||||
for (p = eap->arg; *p != NUL; p++) {
|
||||
for (char *p = eap->arg; *p != NUL; p++) {
|
||||
arg[len++] = *p;
|
||||
for (l = utfc_ptr2len(p) - 1; l > 0; l--) {
|
||||
arg[len++] = *++p;
|
||||
|
@ -156,7 +156,6 @@ bool cause_errthrow(const char *mesg, bool multiline, bool severe, bool *ignore)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
msglist_T *elem;
|
||||
msglist_T **plist;
|
||||
|
||||
// Do nothing when displaying the interrupt message or reporting an
|
||||
// uncaught exception (which has already been discarded then) at the top
|
||||
@ -237,7 +236,7 @@ bool cause_errthrow(const char *mesg, bool multiline, bool severe, bool *ignore)
|
||||
// returned. - Throw only the first of several errors in a row, except
|
||||
// a severe error is following.
|
||||
if (msg_list != NULL) {
|
||||
plist = msg_list;
|
||||
msglist_T **plist = msg_list;
|
||||
while (*plist != NULL) {
|
||||
plist = &(*plist)->next;
|
||||
}
|
||||
@ -249,10 +248,8 @@ bool cause_errthrow(const char *mesg, bool multiline, bool severe, bool *ignore)
|
||||
elem->throw_msg = NULL;
|
||||
*plist = elem;
|
||||
if (plist == msg_list || severe) {
|
||||
char *tmsg;
|
||||
|
||||
// Skip the extra "Vim " prefix for message "E458".
|
||||
tmsg = elem->msg;
|
||||
char *tmsg = elem->msg;
|
||||
if (strncmp(tmsg, "Vim E", 5) == 0
|
||||
&& ascii_isdigit(tmsg[5])
|
||||
&& ascii_isdigit(tmsg[6])
|
||||
@ -277,10 +274,9 @@ bool cause_errthrow(const char *mesg, bool multiline, bool severe, bool *ignore)
|
||||
/// Free a "msg_list" and the messages it contains.
|
||||
static void free_msglist(msglist_T *l)
|
||||
{
|
||||
msglist_T *next;
|
||||
msglist_T *messages = l;
|
||||
while (messages != NULL) {
|
||||
next = messages->next;
|
||||
msglist_T *next = messages->next;
|
||||
xfree(messages->msg);
|
||||
xfree(messages->sfile);
|
||||
xfree(messages);
|
||||
@ -376,13 +372,12 @@ int do_intthrow(cstack_T *cstack)
|
||||
/// Get an exception message that is to be stored in current_exception->value.
|
||||
char *get_exception_string(void *value, except_type_T type, char *cmdname, int *should_free)
|
||||
{
|
||||
char *ret, *mesg;
|
||||
char *ret;
|
||||
|
||||
if (type == ET_ERROR) {
|
||||
char *p;
|
||||
char *val;
|
||||
*should_free = true;
|
||||
mesg = ((msglist_T *)value)->throw_msg;
|
||||
char *mesg = ((msglist_T *)value)->throw_msg;
|
||||
if (cmdname != NULL && *cmdname != NUL) {
|
||||
size_t cmdlen = strlen(cmdname);
|
||||
ret = xstrnsave("Vim(", 4 + cmdlen + 2 + strlen(mesg));
|
||||
@ -397,7 +392,7 @@ char *get_exception_string(void *value, except_type_T type, char *cmdname, int *
|
||||
// msg_add_fname may have been used to prefix the message with a file
|
||||
// name in quotes. In the exception value, put the file name in
|
||||
// parentheses and move it to the end.
|
||||
for (p = mesg;; p++) {
|
||||
for (char *p = mesg;; p++) {
|
||||
if (*p == NUL
|
||||
|| (*p == 'E'
|
||||
&& ascii_isdigit(p[1])
|
||||
|
@ -249,14 +249,9 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
int *skiplen, int *patlen)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *cmd;
|
||||
char *p;
|
||||
bool delim_optional = false;
|
||||
int delim;
|
||||
char *end;
|
||||
const char *dummy;
|
||||
pos_T save_cursor;
|
||||
bool use_last_pat;
|
||||
bool retval = false;
|
||||
magic_T magic = 0;
|
||||
|
||||
@ -290,7 +285,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
cmdmod_T dummy_cmdmod;
|
||||
parse_command_modifiers(&ea, &dummy, &dummy_cmdmod, true);
|
||||
|
||||
cmd = skip_range(ea.cmd, NULL);
|
||||
char *cmd = skip_range(ea.cmd, NULL);
|
||||
if (vim_strchr("sgvl", (uint8_t)(*cmd)) == NULL) {
|
||||
goto theend;
|
||||
}
|
||||
@ -341,11 +336,11 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
}
|
||||
|
||||
p = skipwhite(p);
|
||||
delim = (delim_optional && vim_isIDc((uint8_t)(*p))) ? ' ' : *p++;
|
||||
int delim = (delim_optional && vim_isIDc((uint8_t)(*p))) ? ' ' : *p++;
|
||||
*search_delim = delim;
|
||||
end = skip_regexp_ex(p, delim, magic_isset(), NULL, NULL, &magic);
|
||||
char *end = skip_regexp_ex(p, delim, magic_isset(), NULL, NULL, &magic);
|
||||
|
||||
use_last_pat = end == p && *end == delim;
|
||||
bool use_last_pat = end == p && *end == delim;
|
||||
if (end == p && !use_last_pat) {
|
||||
goto theend;
|
||||
}
|
||||
@ -366,7 +361,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
*patlen = (int)(end - p);
|
||||
|
||||
// parse the address range
|
||||
save_cursor = curwin->w_cursor;
|
||||
pos_T save_cursor = curwin->w_cursor;
|
||||
curwin->w_cursor = s->search_start;
|
||||
parse_cmd_address(&ea, &dummy, true);
|
||||
if (ea.addr_count > 0) {
|
||||
@ -395,10 +390,7 @@ theend:
|
||||
static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state_T *s)
|
||||
{
|
||||
pos_T end_pos;
|
||||
proftime_T tm;
|
||||
int skiplen, patlen;
|
||||
char next_char;
|
||||
bool use_last_pat;
|
||||
int search_delim;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
@ -435,9 +427,9 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state
|
||||
int found; // do_search() result
|
||||
|
||||
// Use the previous pattern for ":s//".
|
||||
next_char = ccline.cmdbuff[skiplen + patlen];
|
||||
use_last_pat = patlen == 0 && skiplen > 0
|
||||
&& ccline.cmdbuff[skiplen - 1] == next_char;
|
||||
char next_char = ccline.cmdbuff[skiplen + patlen];
|
||||
bool use_last_pat = patlen == 0 && skiplen > 0
|
||||
&& ccline.cmdbuff[skiplen - 1] == next_char;
|
||||
|
||||
// If there is no pattern, don't do anything.
|
||||
if (patlen == 0 && !use_last_pat) {
|
||||
@ -450,7 +442,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state
|
||||
ui_flush();
|
||||
emsg_off++; // So it doesn't beep if bad expr
|
||||
// Set the time limit to half a second.
|
||||
tm = profile_setlimit(500);
|
||||
proftime_T tm = profile_setlimit(500);
|
||||
if (!p_hls) {
|
||||
search_flags += SEARCH_KEEP;
|
||||
}
|
||||
@ -1408,7 +1400,6 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
|
||||
pos_T t;
|
||||
char *pat;
|
||||
int search_flags = SEARCH_NOOF;
|
||||
char save;
|
||||
|
||||
if (search_delim == ccline.cmdbuff[skiplen]) {
|
||||
pat = last_search_pattern();
|
||||
@ -1437,7 +1428,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
|
||||
search_flags += SEARCH_KEEP;
|
||||
}
|
||||
emsg_off++;
|
||||
save = pat[patlen];
|
||||
char save = pat[patlen];
|
||||
pat[patlen] = NUL;
|
||||
int found = searchit(curwin, curbuf, &t, NULL,
|
||||
next_match ? FORWARD : BACKWARD,
|
||||
@ -3971,11 +3962,9 @@ void escape_fname(char **pp)
|
||||
/// If 'orig_pat' starts with "~/", replace the home directory with "~".
|
||||
void tilde_replace(char *orig_pat, int num_files, char **files)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (orig_pat[0] == '~' && vim_ispathsep(orig_pat[1])) {
|
||||
for (int i = 0; i < num_files; i++) {
|
||||
p = home_replace_save(NULL, files[i]);
|
||||
char *p = home_replace_save(NULL, files[i]);
|
||||
xfree(files[i]);
|
||||
files[i] = p;
|
||||
}
|
||||
|
@ -60,11 +60,9 @@ static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces)
|
||||
|
||||
static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
|
||||
{
|
||||
win_T *wp;
|
||||
|
||||
if (restore_size && (ssop_flags & SSOP_WINSIZE)) {
|
||||
int n = 0;
|
||||
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
if (!ses_do_win(wp)) {
|
||||
continue;
|
||||
}
|
||||
@ -104,7 +102,6 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
|
||||
/// @return FAIL when writing the commands to "fd" fails.
|
||||
static int ses_win_rec(FILE *fd, frame_T *fr)
|
||||
{
|
||||
frame_T *frc;
|
||||
int count = 0;
|
||||
|
||||
if (fr->fr_layout == FR_LEAF) {
|
||||
@ -113,7 +110,7 @@ static int ses_win_rec(FILE *fd, frame_T *fr)
|
||||
|
||||
// Find first frame that's not skipped and then create a window for
|
||||
// each following one (first frame is already there).
|
||||
frc = ses_skipframe(fr->fr_child);
|
||||
frame_T *frc = ses_skipframe(fr->fr_child);
|
||||
if (frc != NULL) {
|
||||
while ((frc = ses_skipframe(frc->fr_next)) != NULL) {
|
||||
// Make window as big as possible so that we have lots of room
|
||||
@ -315,14 +312,12 @@ static int ses_put_fname(FILE *fd, char *name, unsigned *flagp)
|
||||
/// @param current_arg_idx current argument index of the window, use -1 if unknown
|
||||
static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int current_arg_idx)
|
||||
{
|
||||
win_T *save_curwin;
|
||||
int f;
|
||||
int do_cursor;
|
||||
int did_next = false;
|
||||
|
||||
// Always restore cursor position for ":mksession". For ":mkview" only
|
||||
// when 'viewoptions' contains "cursor".
|
||||
do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR);
|
||||
int do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR);
|
||||
|
||||
// Local argument list.
|
||||
if (wp->w_alist == &global_alist) {
|
||||
@ -428,7 +423,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
|
||||
// used and 'sessionoptions' doesn't include "nvim/options".
|
||||
// Some folding options are always stored when "folds" is included,
|
||||
// otherwise the folds would not be restored correctly.
|
||||
save_curwin = curwin;
|
||||
win_T *save_curwin = curwin;
|
||||
curwin = wp;
|
||||
curbuf = curwin->w_buffer;
|
||||
if (*flagp & (SSOP_OPTIONS | SSOP_LOCALOPTIONS)) {
|
||||
@ -534,8 +529,6 @@ static int makeopens(FILE *fd, char *dirnow)
|
||||
{
|
||||
int only_save_windows = true;
|
||||
int restore_size = true;
|
||||
win_T *wp;
|
||||
char *sname;
|
||||
win_T *edited_win = NULL;
|
||||
win_T *tab_firstwin;
|
||||
frame_T *tab_topframe;
|
||||
@ -565,7 +558,7 @@ static int makeopens(FILE *fd, char *dirnow)
|
||||
if (ssop_flags & SSOP_SESDIR) {
|
||||
PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')");
|
||||
} else if (ssop_flags & SSOP_CURDIR) {
|
||||
sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow);
|
||||
char *sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow);
|
||||
char *fname_esc = ses_escape_fname(sname, &ssop_flags);
|
||||
if (fprintf(fd, "cd %s\n", fname_esc) < 0) {
|
||||
xfree(fname_esc);
|
||||
@ -691,7 +684,7 @@ static int makeopens(FILE *fd, char *dirnow)
|
||||
// Before creating the window layout, try loading one file. If this
|
||||
// is aborted we don't end up with a number of useless windows.
|
||||
// This may have side effects! (e.g., compressed or network file).
|
||||
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
if (ses_do_win(wp)
|
||||
&& wp->w_buffer->b_ffname != NULL
|
||||
&& !bt_help(wp->w_buffer)
|
||||
@ -732,7 +725,7 @@ static int makeopens(FILE *fd, char *dirnow)
|
||||
// Check if window sizes can be restored (no windows omitted).
|
||||
// Remember the window number of the current window after restoring.
|
||||
int nr = 0;
|
||||
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
if (ses_do_win(wp)) {
|
||||
nr++;
|
||||
} else {
|
||||
@ -781,7 +774,7 @@ static int makeopens(FILE *fd, char *dirnow)
|
||||
}
|
||||
|
||||
// Restore the view of the window (options, file, cursor, etc.).
|
||||
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
for (win_T *wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
|
||||
if (!ses_do_win(wp)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ static const char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buf
|
||||
|
||||
void filemess(buf_T *buf, char *name, char *s, int attr)
|
||||
{
|
||||
int msg_scroll_save;
|
||||
int prev_msg_col = msg_col;
|
||||
|
||||
if (msg_silent != 0) {
|
||||
@ -102,7 +101,7 @@ void filemess(buf_T *buf, char *name, char *s, int attr)
|
||||
// For the first message may have to start a new line.
|
||||
// For further ones overwrite the previous one, reset msg_scroll before
|
||||
// calling filemess().
|
||||
msg_scroll_save = msg_scroll;
|
||||
int msg_scroll_save = msg_scroll;
|
||||
if (shortmess(SHM_OVERALL) && !msg_listdo_overwrite && !exiting && p_verbose == 0) {
|
||||
msg_scroll = false;
|
||||
}
|
||||
@ -1323,7 +1322,6 @@ retry:
|
||||
// Reading UTF-8: Check if the bytes are valid UTF-8.
|
||||
for (p = (uint8_t *)ptr;; p++) {
|
||||
int todo = (int)(((uint8_t *)ptr + size) - p);
|
||||
int l;
|
||||
|
||||
if (todo <= 0) {
|
||||
break;
|
||||
@ -1333,7 +1331,7 @@ retry:
|
||||
// an incomplete character at the end though, the next
|
||||
// read() will get the next bytes, we'll check it
|
||||
// then.
|
||||
l = utf_ptr2len_len((char *)p, todo);
|
||||
int l = utf_ptr2len_len((char *)p, todo);
|
||||
if (l > todo && !incomplete_tail) {
|
||||
// Avoid retrying with a different encoding when
|
||||
// a truncated file is more likely, or attempting
|
||||
@ -1905,11 +1903,8 @@ bool is_dev_fd_file(char *fname)
|
||||
/// @param endp end of more bytes read
|
||||
static linenr_T readfile_linenr(linenr_T linecnt, char *p, const char *endp)
|
||||
{
|
||||
char *s;
|
||||
linenr_T lnum;
|
||||
|
||||
lnum = curbuf->b_ml.ml_line_count - linecnt + 1;
|
||||
for (s = p; s < endp; s++) {
|
||||
linenr_T lnum = curbuf->b_ml.ml_line_count - linecnt + 1;
|
||||
for (char *s = p; s < endp; s++) {
|
||||
if (*s == '\n') {
|
||||
lnum++;
|
||||
}
|
||||
@ -1977,7 +1972,6 @@ void set_forced_fenc(exarg_T *eap)
|
||||
static char *next_fenc(char **pp, bool *alloced)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
char *p;
|
||||
char *r;
|
||||
|
||||
*alloced = false;
|
||||
@ -1985,7 +1979,7 @@ static char *next_fenc(char **pp, bool *alloced)
|
||||
*pp = NULL;
|
||||
return "";
|
||||
}
|
||||
p = vim_strchr(*pp, ',');
|
||||
char *p = vim_strchr(*pp, ',');
|
||||
if (p == NULL) {
|
||||
r = enc_canonize(*pp);
|
||||
*pp += strlen(*pp);
|
||||
@ -2012,10 +2006,9 @@ static char *next_fenc(char **pp, bool *alloced)
|
||||
/// Returns NULL if the conversion failed ("*fdp" is not set) .
|
||||
static char *readfile_charconvert(char *fname, char *fenc, int *fdp)
|
||||
{
|
||||
char *tmpname;
|
||||
char *errmsg = NULL;
|
||||
|
||||
tmpname = vim_tempname();
|
||||
char *tmpname = vim_tempname();
|
||||
if (tmpname == NULL) {
|
||||
errmsg = _("Can't find temp file for conversion");
|
||||
} else {
|
||||
@ -3246,12 +3239,10 @@ void write_lnum_adjust(linenr_T offset)
|
||||
/// unless when it looks like a URL.
|
||||
void forward_slash(char *fname)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (path_with_url(fname)) {
|
||||
return;
|
||||
}
|
||||
for (p = fname; *p != NUL; p++) {
|
||||
for (char *p = fname; *p != NUL; p++) {
|
||||
if (*p == '\\') {
|
||||
*p = '/';
|
||||
}
|
||||
|
@ -1952,7 +1952,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
int mp_match_len = 0;
|
||||
int max_mlen = 0;
|
||||
int tb_c1;
|
||||
int mlen;
|
||||
int keylen = *keylenp;
|
||||
int local_State = get_real_state();
|
||||
bool is_plug_map = false;
|
||||
@ -1986,6 +1985,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
&& State != MODE_ASKMORE
|
||||
&& State != MODE_CONFIRM
|
||||
&& !at_ins_compl_key()) {
|
||||
int mlen;
|
||||
int nolmaplen;
|
||||
if (tb_c1 == K_SPECIAL) {
|
||||
nolmaplen = 2;
|
||||
|
@ -549,8 +549,6 @@ void grid_line_flush_if_valid_row(void)
|
||||
void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int end_col, int c1,
|
||||
int c2, int attr)
|
||||
{
|
||||
schar_T sc;
|
||||
|
||||
int row_off = 0, col_off = 0;
|
||||
grid_adjust(&grid, &row_off, &col_off);
|
||||
start_row += row_off;
|
||||
@ -594,7 +592,7 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int
|
||||
}
|
||||
|
||||
int col = start_col;
|
||||
sc = schar_from_char(c1);
|
||||
schar_T sc = schar_from_char(c1);
|
||||
for (col = start_col; col < end_col; col++) {
|
||||
size_t off = lineoff + (size_t)col;
|
||||
if (grid->chars[off] != sc || grid->attrs[off] != attr || rdb_flags & RDB_NODELTA) {
|
||||
|
@ -55,8 +55,6 @@ void ex_help(exarg_T *eap)
|
||||
char **matches;
|
||||
int empty_fnum = 0;
|
||||
int alt_fnum = 0;
|
||||
buf_T *buf;
|
||||
int len;
|
||||
const bool old_KeyTyped = KeyTyped;
|
||||
|
||||
if (eap != NULL) {
|
||||
@ -105,7 +103,7 @@ void ex_help(exarg_T *eap)
|
||||
if (n != FAIL && lang != NULL) {
|
||||
// Find first item with the requested language.
|
||||
for (i = 0; i < num_matches; i++) {
|
||||
len = (int)strlen(matches[i]);
|
||||
int len = (int)strlen(matches[i]);
|
||||
if (len > 3 && matches[i][len - 3] == '@'
|
||||
&& STRICMP(matches[i] + len - 2, lang) == 0) {
|
||||
break;
|
||||
@ -196,7 +194,7 @@ void ex_help(exarg_T *eap)
|
||||
// may have jumped to another window, check that the buffer is not in a
|
||||
// window.
|
||||
if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum) {
|
||||
buf = buflist_findnr(empty_fnum);
|
||||
buf_T *buf = buflist_findnr(empty_fnum);
|
||||
if (buf != NULL && buf->b_nwindows == 0) {
|
||||
wipe_buffer(buf, true);
|
||||
}
|
||||
@ -647,9 +645,6 @@ void prepare_help_buffer(void)
|
||||
/// highlighting is not used.
|
||||
void fix_help_buffer(void)
|
||||
{
|
||||
linenr_T lnum;
|
||||
char *line;
|
||||
|
||||
// Set filetype to "help".
|
||||
if (strcmp(curbuf->b_p_ft, "help") != 0) {
|
||||
curbuf->b_ro_locked++;
|
||||
@ -659,8 +654,8 @@ void fix_help_buffer(void)
|
||||
|
||||
if (!syntax_present(curwin)) {
|
||||
bool in_example = false;
|
||||
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
|
||||
line = ml_get_buf(curbuf, lnum);
|
||||
for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
|
||||
char *line = ml_get_buf(curbuf, lnum);
|
||||
const size_t len = strlen(line);
|
||||
if (in_example && len > 0 && !ascii_iswhite(line[0])) {
|
||||
// End of example: non-white or '<' in first column.
|
||||
@ -695,8 +690,8 @@ void fix_help_buffer(void)
|
||||
&& ASCII_ISALPHA(fname[6])
|
||||
&& TOLOWER_ASC(fname[7]) == 'x'
|
||||
&& fname[8] == NUL)) {
|
||||
for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) {
|
||||
line = ml_get_buf(curbuf, lnum);
|
||||
for (linenr_T lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) {
|
||||
char *line = ml_get_buf(curbuf, lnum);
|
||||
if (strstr(line, "*local-additions*") == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -910,7 +910,6 @@ static bool ins_compl_equal(compl_T *match, char *str, size_t len)
|
||||
static void ins_compl_longest_match(compl_T *match)
|
||||
{
|
||||
char *p, *s;
|
||||
int c1, c2;
|
||||
int had_match;
|
||||
|
||||
if (compl_leader == NULL) {
|
||||
@ -936,8 +935,8 @@ static void ins_compl_longest_match(compl_T *match)
|
||||
p = compl_leader;
|
||||
s = match->cp_str;
|
||||
while (*p != NUL) {
|
||||
c1 = utf_ptr2char(p);
|
||||
c2 = utf_ptr2char(s);
|
||||
int c1 = utf_ptr2char(p);
|
||||
int c2 = utf_ptr2char(s);
|
||||
|
||||
if ((match->cp_flags & CP_ICASE)
|
||||
? (mb_tolower(c1) != mb_tolower(c2))
|
||||
@ -1442,11 +1441,10 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r
|
||||
{
|
||||
char *ptr;
|
||||
int i;
|
||||
FILE *fp;
|
||||
int add_r;
|
||||
|
||||
for (i = 0; i < count && !got_int && !compl_interrupted; i++) {
|
||||
fp = os_fopen(files[i], "r"); // open dictionary file
|
||||
FILE *fp = os_fopen(files[i], "r"); // open dictionary file
|
||||
if (flags != DICT_EXACT && !shortmess(SHM_COMPLETIONSCAN)) {
|
||||
msg_hist_off = true; // reset in msg_trunc()
|
||||
vim_snprintf(IObuff, IOSIZE,
|
||||
@ -2181,7 +2179,6 @@ bool ins_compl_prep(int c)
|
||||
static void ins_compl_fixRedoBufForLeader(char *ptr_arg)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
char *ptr = ptr_arg;
|
||||
|
||||
if (ptr == NULL) {
|
||||
@ -2192,7 +2189,7 @@ static void ins_compl_fixRedoBufForLeader(char *ptr_arg)
|
||||
}
|
||||
}
|
||||
if (compl_orig_text != NULL) {
|
||||
p = compl_orig_text;
|
||||
char *p = compl_orig_text;
|
||||
for (len = 0; p[len] != NUL && p[len] == ptr[len]; len++) {}
|
||||
if (len > 0) {
|
||||
len -= utf_head_off(p, p + len);
|
||||
@ -3853,15 +3850,13 @@ static bool ins_compl_pum_key(int c)
|
||||
/// Returns 1 for most keys, height of the popup menu for page-up/down keys.
|
||||
static int ins_compl_key2count(int c)
|
||||
{
|
||||
int h;
|
||||
|
||||
if (c == K_EVENT || c == K_COMMAND || c == K_LUA) {
|
||||
int offset = pum_want.item - pum_selected_item;
|
||||
return abs(offset);
|
||||
}
|
||||
|
||||
if (ins_compl_pum_key(c) && c != K_UP && c != K_DOWN) {
|
||||
h = pum_get_height();
|
||||
int h = pum_get_height();
|
||||
if (h > 3) {
|
||||
h -= 2; // keep some context
|
||||
}
|
||||
|
@ -469,7 +469,6 @@ char *get_special_key_name(int c, int modifiers)
|
||||
|
||||
int i, idx;
|
||||
int table_idx;
|
||||
char *s;
|
||||
|
||||
string[0] = '<';
|
||||
idx = 1;
|
||||
@ -536,7 +535,7 @@ char *get_special_key_name(int c, int modifiers)
|
||||
} else if (vim_isprintc(c)) {
|
||||
string[idx++] = (char)(uint8_t)c;
|
||||
} else {
|
||||
s = transchar(c);
|
||||
char *s = transchar(c);
|
||||
while (*s) {
|
||||
string[idx++] = *s++;
|
||||
}
|
||||
@ -631,7 +630,6 @@ int find_special_key(const char **const srcp, const size_t src_len, int *const m
|
||||
const char *const end = *srcp + src_len - 1;
|
||||
const bool in_string = flags & FSK_IN_STRING;
|
||||
int modifiers;
|
||||
int bit;
|
||||
uvarnumber_T n;
|
||||
int l;
|
||||
|
||||
@ -686,7 +684,7 @@ int find_special_key(const char **const srcp, const size_t src_len, int *const m
|
||||
modifiers = 0x0;
|
||||
for (bp = src + 1; bp < last_dash; bp++) {
|
||||
if (*bp != '-') {
|
||||
bit = name_to_mod_mask((uint8_t)(*bp));
|
||||
int bit = name_to_mod_mask((uint8_t)(*bp));
|
||||
if (bit == 0x0) {
|
||||
break; // Illegal modifier name
|
||||
}
|
||||
|
@ -1749,7 +1749,6 @@ static void create_windows(mparm_T *parmp)
|
||||
static void edit_buffers(mparm_T *parmp, char *cwd)
|
||||
{
|
||||
int arg_idx; // index in argument list
|
||||
int i;
|
||||
bool advance = true;
|
||||
win_T *win;
|
||||
char *p_shm_save = NULL;
|
||||
@ -1765,7 +1764,7 @@ static void edit_buffers(mparm_T *parmp, char *cwd)
|
||||
}
|
||||
|
||||
arg_idx = 1;
|
||||
for (i = 1; i < parmp->window_count; i++) {
|
||||
for (int i = 1; i < parmp->window_count; i++) {
|
||||
if (cwd != NULL) {
|
||||
os_chdir(cwd);
|
||||
}
|
||||
@ -1869,7 +1868,6 @@ static void exe_pre_commands(mparm_T *parmp)
|
||||
{
|
||||
char **cmds = parmp->pre_commands;
|
||||
int cnt = parmp->n_pre_commands;
|
||||
int i;
|
||||
|
||||
if (cnt <= 0) {
|
||||
return;
|
||||
@ -1878,7 +1876,7 @@ static void exe_pre_commands(mparm_T *parmp)
|
||||
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++) {
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
do_cmdline_cmd(cmds[i]);
|
||||
}
|
||||
estack_pop();
|
||||
@ -1889,8 +1887,6 @@ static void exe_pre_commands(mparm_T *parmp)
|
||||
// Execute "+", "-c" and "-S" arguments.
|
||||
static void exe_commands(mparm_T *parmp)
|
||||
{
|
||||
int i;
|
||||
|
||||
// We start commands on line 0, make "vim +/pat file" match a
|
||||
// pattern on line 1. But don't move the cursor when an autocommand
|
||||
// with g`" was used.
|
||||
@ -1901,7 +1897,7 @@ static void exe_commands(mparm_T *parmp)
|
||||
estack_push(ETYPE_ARGS, "command line", 0);
|
||||
current_sctx.sc_sid = SID_CARG;
|
||||
current_sctx.sc_seq = 0;
|
||||
for (i = 0; i < parmp->n_commands; i++) {
|
||||
for (int i = 0; i < parmp->n_commands; i++) {
|
||||
do_cmdline_cmd(parmp->commands[i]);
|
||||
if (parmp->cmds_tofree[i]) {
|
||||
xfree(parmp->commands[i]);
|
||||
|
@ -354,11 +354,10 @@ void init_search_hl(win_T *wp, match_T *search_hl)
|
||||
static int next_search_hl_pos(match_T *shl, linenr_T lnum, matchitem_T *match, colnr_T mincol)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int i;
|
||||
int found = -1;
|
||||
|
||||
shl->lnum = 0;
|
||||
for (i = match->mit_pos_cur; i < match->mit_pos_count; i++) {
|
||||
for (int i = match->mit_pos_cur; i < match->mit_pos_count; i++) {
|
||||
llpos_T *pos = &match->mit_pos_array[i];
|
||||
|
||||
if (pos->lnum == 0) {
|
||||
@ -902,7 +901,6 @@ void f_clearmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
void f_getmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
matchitem_T *cur;
|
||||
int i;
|
||||
win_T *win = get_optional_window(argvars, 0);
|
||||
|
||||
tv_list_alloc_ret(rettv, kListLenMayKnow);
|
||||
@ -915,7 +913,7 @@ void f_getmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
dict_T *dict = tv_dict_alloc();
|
||||
if (cur->mit_match.regprog == NULL) {
|
||||
// match added with matchaddpos()
|
||||
for (i = 0; i < cur->mit_pos_count; i++) {
|
||||
for (int i = 0; i < cur->mit_pos_count; i++) {
|
||||
llpos_T *llpos;
|
||||
char buf[30]; // use 30 to avoid compiler warning
|
||||
|
||||
|
@ -693,9 +693,7 @@ static int utf_safe_read_char_adv(const char **s, size_t *n)
|
||||
// Note: composing characters are skipped!
|
||||
int mb_ptr2char_adv(const char **const pp)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = utf_ptr2char(*pp);
|
||||
int c = utf_ptr2char(*pp);
|
||||
*pp += utfc_ptr2len(*pp);
|
||||
return c;
|
||||
}
|
||||
@ -704,9 +702,7 @@ int mb_ptr2char_adv(const char **const pp)
|
||||
// Note: composing characters are returned as separate characters.
|
||||
int mb_cptr2char_adv(const char **pp)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = utf_ptr2char(*pp);
|
||||
int c = utf_ptr2char(*pp);
|
||||
*pp += utf_ptr2len(*pp);
|
||||
return c;
|
||||
}
|
||||
@ -716,9 +712,7 @@ int mb_cptr2char_adv(const char **pp)
|
||||
/// behaves like a composing character.
|
||||
bool utf_composinglike(const char *p1, const char *p2)
|
||||
{
|
||||
int c2;
|
||||
|
||||
c2 = utf_ptr2char(p2);
|
||||
int c2 = utf_ptr2char(p2);
|
||||
if (utf_iscomposing(c2)) {
|
||||
return true;
|
||||
}
|
||||
@ -842,10 +836,9 @@ int utf_byte2len(int b)
|
||||
// Never returns zero.
|
||||
int utf_ptr2len_len(const char *p, int size)
|
||||
{
|
||||
int len;
|
||||
int m;
|
||||
|
||||
len = utf8len_tab[(uint8_t)(*p)];
|
||||
int len = utf8len_tab[(uint8_t)(*p)];
|
||||
if (len == 1) {
|
||||
return 1; // NUL, ascii or illegal lead byte
|
||||
}
|
||||
@ -905,9 +898,6 @@ int utfc_ptr2len(const char *const p)
|
||||
/// Returns 1 for an illegal char or an incomplete byte sequence.
|
||||
int utfc_ptr2len_len(const char *p, int size)
|
||||
{
|
||||
int len;
|
||||
int prevlen;
|
||||
|
||||
if (size < 1 || *p == NUL) {
|
||||
return 0;
|
||||
}
|
||||
@ -916,7 +906,7 @@ int utfc_ptr2len_len(const char *p, int size)
|
||||
}
|
||||
|
||||
// Skip over first UTF-8 char, stopping at a NUL byte.
|
||||
len = utf_ptr2len_len(p, size);
|
||||
int len = utf_ptr2len_len(p, size);
|
||||
|
||||
// Check for illegal byte and incomplete byte sequence.
|
||||
if ((len == 1 && (uint8_t)p[0] >= 0x80) || len > size) {
|
||||
@ -925,17 +915,15 @@ int utfc_ptr2len_len(const char *p, int size)
|
||||
|
||||
// Check for composing characters. We can handle only the first six, but
|
||||
// skip all of them (otherwise the cursor would get stuck).
|
||||
prevlen = 0;
|
||||
int prevlen = 0;
|
||||
while (len < size) {
|
||||
int len_next_char;
|
||||
|
||||
if ((uint8_t)p[len] < 0x80) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Next character length should not go beyond size to ensure that
|
||||
// utf_composinglike(...) does not read beyond size.
|
||||
len_next_char = utf_ptr2len_len(p + len, size - len);
|
||||
int len_next_char = utf_ptr2len_len(p + len, size - len);
|
||||
if (len_next_char > size - len) {
|
||||
break;
|
||||
}
|
||||
@ -1836,7 +1824,6 @@ int utf_cp_tail_off(const char *base, const char *p_in)
|
||||
int utf_cp_head_off(const char *base, const char *p)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (*p == NUL) {
|
||||
return 0;
|
||||
@ -1850,7 +1837,7 @@ int utf_cp_head_off(const char *base, const char *p)
|
||||
}
|
||||
|
||||
// Find the last character that is 10xx.xxxx
|
||||
for (j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {}
|
||||
for (int j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {}
|
||||
|
||||
// Check for illegal sequence.
|
||||
if (utf8len_tab[(uint8_t)p[i]] == 1) {
|
||||
@ -2118,7 +2105,6 @@ char *enc_skip(char *p)
|
||||
char *enc_canonize(char *enc)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
char *p, *s;
|
||||
if (strcmp(enc, "default") == 0) {
|
||||
// Use the default encoding as found by set_init_1().
|
||||
return xstrdup(fenc_default);
|
||||
@ -2127,8 +2113,8 @@ char *enc_canonize(char *enc)
|
||||
// copy "enc" to allocated memory, with room for two '-'
|
||||
char *r = xmalloc(strlen(enc) + 3);
|
||||
// Make it all lower case and replace '_' with '-'.
|
||||
p = r;
|
||||
for (s = enc; *s != NUL; s++) {
|
||||
char *p = r;
|
||||
for (char *s = enc; *s != NUL; s++) {
|
||||
if (*s == '_') {
|
||||
*p++ = '-';
|
||||
} else {
|
||||
@ -2260,17 +2246,14 @@ enc_locale_copy_enc:
|
||||
// (should return iconv_t, but that causes problems with prototypes).
|
||||
void *my_iconv_open(char *to, char *from)
|
||||
{
|
||||
iconv_t fd;
|
||||
#define ICONV_TESTLEN 400
|
||||
char tobuf[ICONV_TESTLEN];
|
||||
char *p;
|
||||
size_t tolen;
|
||||
static WorkingStatus iconv_working = kUnknown;
|
||||
|
||||
if (iconv_working == kBroken) {
|
||||
return (void *)-1; // detected a broken iconv() previously
|
||||
}
|
||||
fd = iconv_open(enc_skip(to), enc_skip(from));
|
||||
iconv_t fd = iconv_open(enc_skip(to), enc_skip(from));
|
||||
|
||||
if (fd != (iconv_t)-1 && iconv_working == kUnknown) {
|
||||
// Do a dummy iconv() call to check if it actually works. There is a
|
||||
@ -2278,8 +2261,8 @@ void *my_iconv_open(char *to, char *from)
|
||||
// because it's wide-spread. The symptoms are that after outputting
|
||||
// the initial shift state the "to" pointer is NULL and conversion
|
||||
// stops for no apparent reason after about 8160 characters.
|
||||
p = tobuf;
|
||||
tolen = ICONV_TESTLEN;
|
||||
char *p = tobuf;
|
||||
size_t tolen = ICONV_TESTLEN;
|
||||
(void)iconv(fd, NULL, NULL, &p, &tolen);
|
||||
if (p == NULL) {
|
||||
iconv_working = kBroken;
|
||||
@ -2301,24 +2284,19 @@ void *my_iconv_open(char *to, char *from)
|
||||
static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t slen,
|
||||
size_t *unconvlenp, size_t *resultlenp)
|
||||
{
|
||||
const char *from;
|
||||
size_t fromlen;
|
||||
char *to;
|
||||
size_t tolen;
|
||||
size_t len = 0;
|
||||
size_t done = 0;
|
||||
char *result = NULL;
|
||||
char *p;
|
||||
int l;
|
||||
|
||||
from = str;
|
||||
fromlen = slen;
|
||||
const char *from = str;
|
||||
size_t fromlen = slen;
|
||||
while (true) {
|
||||
if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) {
|
||||
// Allocate enough room for most conversions. When re-allocating
|
||||
// increase the buffer size.
|
||||
len = len + fromlen * 2 + 40;
|
||||
p = xmalloc(len);
|
||||
char *p = xmalloc(len);
|
||||
if (done > 0) {
|
||||
memmove(p, result, done);
|
||||
}
|
||||
@ -2327,7 +2305,7 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl
|
||||
}
|
||||
|
||||
to = result + done;
|
||||
tolen = len - done - 2;
|
||||
size_t tolen = len - done - 2;
|
||||
// Avoid a warning for systems with a wrong iconv() prototype by
|
||||
// casting the second argument to void *.
|
||||
if (iconv(vcp->vc_fd, (void *)&from, &fromlen, &to, &tolen) != SIZE_MAX) {
|
||||
@ -2357,7 +2335,7 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl
|
||||
if (utf_ptr2cells(from) > 1) {
|
||||
*to++ = '?';
|
||||
}
|
||||
l = utfc_ptr2len_len(from, (int)fromlen);
|
||||
int l = utfc_ptr2len_len(from, (int)fromlen);
|
||||
from += l;
|
||||
fromlen -= (size_t)l;
|
||||
} else if (ICONV_ERRNO != ICONV_E2BIG) {
|
||||
@ -2421,8 +2399,6 @@ int convert_setup(vimconv_T *vcp, char *from, char *to)
|
||||
int convert_setup_ext(vimconv_T *vcp, char *from, bool from_unicode_is_utf8, char *to,
|
||||
bool to_unicode_is_utf8)
|
||||
{
|
||||
int from_prop;
|
||||
int to_prop;
|
||||
int from_is_utf8;
|
||||
int to_is_utf8;
|
||||
|
||||
@ -2438,8 +2414,8 @@ int convert_setup_ext(vimconv_T *vcp, char *from, bool from_unicode_is_utf8, cha
|
||||
return OK;
|
||||
}
|
||||
|
||||
from_prop = enc_canon_props(from);
|
||||
to_prop = enc_canon_props(to);
|
||||
int from_prop = enc_canon_props(from);
|
||||
int to_prop = enc_canon_props(to);
|
||||
if (from_unicode_is_utf8) {
|
||||
from_is_utf8 = from_prop & ENC_UNICODE;
|
||||
} else {
|
||||
|
@ -800,8 +800,6 @@ static int show_menus(char *const path_name, int modes)
|
||||
/// Recursively show the mappings associated with the menus under the given one
|
||||
static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (menu != NULL && (menu->modes & modes) == 0x0) {
|
||||
return;
|
||||
}
|
||||
@ -811,7 +809,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
||||
if (got_int) { // "q" hit for "--more--"
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < depth; i++) {
|
||||
for (int i = 0; i < depth; i++) {
|
||||
msg_puts(" ");
|
||||
}
|
||||
if (menu->priority) {
|
||||
@ -829,7 +827,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
||||
if (got_int) { // "q" hit for "--more--"
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < depth + 2; i++) {
|
||||
for (int i = 0; i < depth + 2; i++) {
|
||||
msg_puts(" ");
|
||||
}
|
||||
msg_puts(menu_mode_chars[bit]);
|
||||
|
@ -2680,7 +2680,6 @@ static int do_more_prompt(int typed_char)
|
||||
bool to_redraw = false;
|
||||
msgchunk_T *mp_last = NULL;
|
||||
msgchunk_T *mp;
|
||||
int i;
|
||||
|
||||
// If headless mode is enabled and no input is required, this variable
|
||||
// will be true. However If server mode is enabled, the message "--more--"
|
||||
@ -2698,7 +2697,7 @@ static int do_more_prompt(int typed_char)
|
||||
if (typed_char == 'G') {
|
||||
// "g<": Find first line on the last page.
|
||||
mp_last = msg_sb_start(last_msgchunk);
|
||||
for (i = 0; i < Rows - 2 && mp_last != NULL
|
||||
for (int i = 0; i < Rows - 2 && mp_last != NULL
|
||||
&& mp_last->sb_prev != NULL; i++) {
|
||||
mp_last = msg_sb_start(mp_last->sb_prev);
|
||||
}
|
||||
@ -2816,13 +2815,13 @@ static int do_more_prompt(int typed_char)
|
||||
}
|
||||
|
||||
// go to start of line at top of the screen
|
||||
for (i = 0; i < Rows - 2 && mp != NULL && mp->sb_prev != NULL; i++) {
|
||||
for (int i = 0; i < Rows - 2 && mp != NULL && mp->sb_prev != NULL; i++) {
|
||||
mp = msg_sb_start(mp->sb_prev);
|
||||
}
|
||||
|
||||
if (mp != NULL && (mp->sb_prev != NULL || to_redraw)) {
|
||||
// Find line to be displayed at top
|
||||
for (i = 0; i > toscroll; i--) {
|
||||
for (int i = 0; i > toscroll; i--) {
|
||||
if (mp == NULL || mp->sb_prev == NULL) {
|
||||
break;
|
||||
}
|
||||
@ -2846,7 +2845,7 @@ static int do_more_prompt(int typed_char)
|
||||
// event fragmentization, not unnecessary scroll events).
|
||||
grid_fill(&msg_grid_adj, 0, Rows, 0, Columns, ' ', ' ',
|
||||
HL_ATTR(HLF_MSG));
|
||||
for (i = 0; mp != NULL && i < Rows - 1; i++) {
|
||||
for (int i = 0; mp != NULL && i < Rows - 1; i++) {
|
||||
mp = disp_sb_line(i, mp);
|
||||
msg_scrolled++;
|
||||
}
|
||||
|
@ -2541,9 +2541,7 @@ int op_change(oparg_T *oap)
|
||||
#if defined(EXITFREE)
|
||||
void clear_registers(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_REGISTERS; i++) {
|
||||
for (int i = 0; i < NUM_REGISTERS; i++) {
|
||||
free_register(&y_regs[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1234,12 +1234,12 @@ static size_t word_length(const char *str)
|
||||
/// before we finish writing.
|
||||
static void read_input(DynamicBuffer *buf)
|
||||
{
|
||||
size_t written = 0, l = 0, len = 0;
|
||||
size_t written = 0, len = 0;
|
||||
linenr_T lnum = curbuf->b_op_start.lnum;
|
||||
char *lp = ml_get(lnum);
|
||||
|
||||
while (true) {
|
||||
l = strlen(lp + written);
|
||||
size_t l = strlen(lp + written);
|
||||
if (l == 0) {
|
||||
len = 0;
|
||||
} else if (lp[written] == NL) {
|
||||
|
@ -1554,14 +1554,13 @@ void simplify_filename(char *filename)
|
||||
|
||||
if (components > 0) { // strip one preceding component
|
||||
bool do_strip = false;
|
||||
char saved_char;
|
||||
|
||||
// Don't strip for an erroneous file name.
|
||||
if (!stripping_disabled) {
|
||||
// If the preceding component does not exist in the file
|
||||
// system, we strip it. On Unix, we don't accept a symbolic
|
||||
// link that refers to a non-existent file.
|
||||
saved_char = p[-1];
|
||||
char saved_char = p[-1];
|
||||
p[-1] = NUL;
|
||||
FileInfo file_info;
|
||||
if (!os_fileinfo_link(filename, &file_info)) {
|
||||
@ -2186,12 +2185,7 @@ int expand_wildcards_eval(char **pat, int *num_file, char ***file, int flags)
|
||||
/// NULL or points to "".
|
||||
int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int flags)
|
||||
{
|
||||
int retval;
|
||||
int i, j;
|
||||
char *p;
|
||||
int non_suf_match; // number without matching suffix
|
||||
|
||||
retval = gen_expand_wildcards(num_pat, pat, num_files, files, flags);
|
||||
int retval = gen_expand_wildcards(num_pat, pat, num_files, files, flags);
|
||||
|
||||
// When keeping all matches, return here
|
||||
if ((flags & EW_KEEPALL) || retval == FAIL) {
|
||||
@ -2200,18 +2194,16 @@ int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int
|
||||
|
||||
// Remove names that match 'wildignore'.
|
||||
if (*p_wig) {
|
||||
char *ffname;
|
||||
|
||||
// check all files in (*files)[]
|
||||
assert(*num_files == 0 || *files != NULL);
|
||||
for (i = 0; i < *num_files; i++) {
|
||||
ffname = FullName_save((*files)[i], false);
|
||||
for (int i = 0; i < *num_files; i++) {
|
||||
char *ffname = FullName_save((*files)[i], false);
|
||||
assert((*files)[i] != NULL);
|
||||
assert(ffname != NULL);
|
||||
if (match_file_list(p_wig, (*files)[i], ffname)) {
|
||||
// remove this matching file from the list
|
||||
xfree((*files)[i]);
|
||||
for (j = i; j + 1 < *num_files; j++) {
|
||||
for (int j = i; j + 1 < *num_files; j++) {
|
||||
(*files)[j] = (*files)[j + 1];
|
||||
}
|
||||
(*num_files)--;
|
||||
@ -2225,12 +2217,12 @@ int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int
|
||||
// Skip when interrupted, the result probably won't be used.
|
||||
assert(*num_files == 0 || *files != NULL);
|
||||
if (*num_files > 1 && !got_int) {
|
||||
non_suf_match = 0;
|
||||
for (i = 0; i < *num_files; i++) {
|
||||
int non_suf_match = 0; // number without matching suffix
|
||||
for (int i = 0; i < *num_files; i++) {
|
||||
if (!match_suffix((*files)[i])) {
|
||||
// Move the name without matching suffix to the front of the list.
|
||||
p = (*files)[i];
|
||||
for (j = i; j > non_suf_match; j--) {
|
||||
char *p = (*files)[i];
|
||||
for (int j = i; j > non_suf_match; j--) {
|
||||
(*files)[j] = (*files)[j - 1];
|
||||
}
|
||||
(*files)[non_suf_match++] = p;
|
||||
|
@ -420,7 +420,6 @@ void pum_redraw(void)
|
||||
int row = 0;
|
||||
int attr_scroll = win_hl_attr(curwin, HLF_PSB);
|
||||
int attr_thumb = win_hl_attr(curwin, HLF_PST);
|
||||
int i;
|
||||
char *s;
|
||||
char *p = NULL;
|
||||
int width;
|
||||
@ -499,7 +498,7 @@ void pum_redraw(void)
|
||||
/ (pum_size - pum_height);
|
||||
}
|
||||
|
||||
for (i = 0; i < pum_height; i++) {
|
||||
for (int i = 0; i < pum_height; i++) {
|
||||
int idx = i + pum_first;
|
||||
const int *const attrs = (idx == pum_selected) ? attrsSel : attrsNorm;
|
||||
int attr = attrs[0]; // start with "word" highlight
|
||||
|
@ -434,12 +434,11 @@ static void prof_func_line(FILE *fd, int count, const proftime_T *total, const p
|
||||
/// @param prefer_self when equal print only self time
|
||||
static void prof_sort_list(FILE *fd, ufunc_T **sorttab, int st_len, char *title, bool prefer_self)
|
||||
{
|
||||
int i;
|
||||
ufunc_T *fp;
|
||||
|
||||
fprintf(fd, "FUNCTIONS SORTED ON %s TIME\n", title);
|
||||
fprintf(fd, "count total (s) self (s) function\n");
|
||||
for (i = 0; i < 20 && i < st_len; i++) {
|
||||
for (int i = 0; i < 20 && i < st_len; i++) {
|
||||
fp = sorttab[i];
|
||||
prof_func_line(fd, fp->uf_tm_count, &fp->uf_tm_total, &fp->uf_tm_self,
|
||||
prefer_self);
|
||||
|
@ -2583,10 +2583,8 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
}
|
||||
|
||||
if (line != NULL && sp->conv.vc_type != CONV_NONE) {
|
||||
char *s;
|
||||
|
||||
// Convert the encoding of the script line.
|
||||
s = string_convert(&sp->conv, line, NULL);
|
||||
char *s = string_convert(&sp->conv, line, NULL);
|
||||
if (s != NULL) {
|
||||
xfree(line);
|
||||
line = s;
|
||||
|
@ -3395,7 +3395,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
affentry_T *ae;
|
||||
char newword[MAXWLEN];
|
||||
int retval = OK;
|
||||
int i, j;
|
||||
int j;
|
||||
char *p;
|
||||
int use_flags;
|
||||
char *use_pfxlist;
|
||||
@ -3452,7 +3452,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
p = word;
|
||||
if (ae->ae_chop != NULL) {
|
||||
// Skip chop string.
|
||||
i = mb_charlen(ae->ae_chop);
|
||||
int i = mb_charlen(ae->ae_chop);
|
||||
for (; i > 0; i--) {
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
@ -3464,7 +3464,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
if (ae->ae_chop != NULL) {
|
||||
// Remove chop string.
|
||||
p = newword + strlen(newword);
|
||||
i = mb_charlen(ae->ae_chop);
|
||||
int i = mb_charlen(ae->ae_chop);
|
||||
for (; i > 0; i--) {
|
||||
MB_PTR_BACK(newword, p);
|
||||
}
|
||||
@ -3514,7 +3514,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
|
||||
// Combine the prefix IDs. Avoid adding the
|
||||
// same ID twice.
|
||||
for (i = 0; i < pfxlen; i++) {
|
||||
for (int i = 0; i < pfxlen; i++) {
|
||||
for (j = 0; j < use_pfxlen; j++) {
|
||||
if (pfxlist[i] == use_pfxlist[j]) {
|
||||
break;
|
||||
@ -3536,7 +3536,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
// Combine the list of compound flags.
|
||||
// Concatenate them to the prefix IDs list.
|
||||
// Avoid adding the same ID twice.
|
||||
for (i = pfxlen; pfxlist[i] != NUL; i++) {
|
||||
for (int i = pfxlen; pfxlist[i] != NUL; i++) {
|
||||
for (j = use_pfxlen; use_pfxlist[j] != NUL; j++) {
|
||||
if (pfxlist[i] == use_pfxlist[j]) {
|
||||
break;
|
||||
@ -5072,16 +5072,15 @@ static int sug_maketable(spellinfo_T *spin)
|
||||
/// @param gap place to store line of numbers
|
||||
static int sug_filltable(spellinfo_T *spin, wordnode_T *node, int startwordnr, garray_T *gap)
|
||||
{
|
||||
wordnode_T *p, *np;
|
||||
int wordnr = startwordnr;
|
||||
int nr;
|
||||
int prev_nr;
|
||||
|
||||
for (p = node; p != NULL; p = p->wn_sibling) {
|
||||
for (wordnode_T *p = node; p != NULL; p = p->wn_sibling) {
|
||||
if (p->wn_byte == NUL) {
|
||||
gap->ga_len = 0;
|
||||
prev_nr = 0;
|
||||
for (np = p; np != NULL && np->wn_byte == NUL; np = np->wn_sibling) {
|
||||
for (wordnode_T *np = p; np != NULL && np->wn_byte == NUL; np = np->wn_sibling) {
|
||||
ga_grow(gap, 10);
|
||||
|
||||
nr = (np->wn_flags << 16) + (np->wn_region & 0xffff);
|
||||
@ -5810,7 +5809,6 @@ static int write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv)
|
||||
// Use map string "map" for languages "lp".
|
||||
static void set_map_str(slang_T *lp, const char *map)
|
||||
{
|
||||
const char *p;
|
||||
int headc = 0;
|
||||
|
||||
if (*map == NUL) {
|
||||
@ -5828,7 +5826,7 @@ static void set_map_str(slang_T *lp, const char *map)
|
||||
// The similar characters are stored separated with slashes:
|
||||
// "aaa/bbb/ccc/". Fill sl_map_array[c] with the character before c and
|
||||
// before the same slash. For characters above 255 sl_map_hash is used.
|
||||
for (p = map; *p != NUL;) {
|
||||
for (const char *p = map; *p != NUL;) {
|
||||
int c = mb_cptr2char_adv(&p);
|
||||
if (c == '/') {
|
||||
headc = 0;
|
||||
|
@ -485,10 +485,8 @@ void sort_strings(char **files, int count)
|
||||
bool has_non_ascii(const char *s)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (s != NULL) {
|
||||
for (p = s; *p != NUL; p++) {
|
||||
for (const char *p = s; *p != NUL; p++) {
|
||||
if ((uint8_t)(*p) >= 128) {
|
||||
return true;
|
||||
}
|
||||
@ -1964,7 +1962,6 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
|
||||
assert(str_arg_l < sizeof(tmp));
|
||||
|
||||
if (remove_trailing_zeroes) {
|
||||
int i;
|
||||
char *tp;
|
||||
|
||||
// using %g or %G: remove superfluous zeroes
|
||||
@ -1979,7 +1976,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
|
||||
STRMOVE(tp + 1, tp + 2);
|
||||
str_arg_l--;
|
||||
}
|
||||
i = (tp[1] == '-') ? 2 : 1;
|
||||
int i = (tp[1] == '-') ? 2 : 1;
|
||||
while (tp[i] == '0') {
|
||||
// change "1.0e07" to "1.0e7"
|
||||
STRMOVE(tp + i, tp + i + 1);
|
||||
|
@ -307,7 +307,6 @@ void syn_set_timeout(proftime_T *tm)
|
||||
// window.
|
||||
void syntax_start(win_T *wp, linenr_T lnum)
|
||||
{
|
||||
synstate_T *p;
|
||||
synstate_T *last_valid = NULL;
|
||||
synstate_T *last_min_valid = NULL;
|
||||
synstate_T *sp, *prev = NULL;
|
||||
@ -362,7 +361,7 @@ void syntax_start(win_T *wp, linenr_T lnum)
|
||||
// Only do this if lnum is not before and not to far beyond a saved state.
|
||||
if (INVALID_STATE(¤t_state) && syn_block->b_sst_array != NULL) {
|
||||
// Find last valid saved state before start_lnum.
|
||||
for (p = syn_block->b_sst_first; p != NULL; p = p->sst_next) {
|
||||
for (synstate_T *p = syn_block->b_sst_first; p != NULL; p = p->sst_next) {
|
||||
if (p->sst_lnum > lnum) {
|
||||
break;
|
||||
}
|
||||
@ -877,13 +876,11 @@ static void syn_update_ends(bool startofline)
|
||||
|
||||
static void syn_stack_free_block(synblock_T *block)
|
||||
{
|
||||
synstate_T *p;
|
||||
|
||||
if (block->b_sst_array == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (p = block->b_sst_first; p != NULL; p = p->sst_next) {
|
||||
for (synstate_T *p = block->b_sst_first; p != NULL; p = p->sst_next) {
|
||||
clear_syn_state(p);
|
||||
}
|
||||
XFREE_CLEAR(block->b_sst_array);
|
||||
@ -1037,7 +1034,7 @@ static void syn_stack_apply_changes_block(synblock_T *block, buf_T *buf)
|
||||
/// @return true if at least one entry was freed.
|
||||
static bool syn_stack_cleanup(void)
|
||||
{
|
||||
synstate_T *p, *prev;
|
||||
synstate_T *prev;
|
||||
disptick_T tick;
|
||||
int dist;
|
||||
bool retval = false;
|
||||
@ -1059,7 +1056,7 @@ static bool syn_stack_cleanup(void)
|
||||
tick = syn_block->b_sst_lasttick;
|
||||
bool above = false;
|
||||
prev = syn_block->b_sst_first;
|
||||
for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) {
|
||||
for (synstate_T *p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) {
|
||||
if (prev->sst_lnum + dist > p->sst_lnum) {
|
||||
if (p->sst_tick > syn_block->b_sst_lasttick) {
|
||||
if (!above || p->sst_tick < tick) {
|
||||
@ -1075,7 +1072,7 @@ static bool syn_stack_cleanup(void)
|
||||
// Go through the list to make the entries for the oldest tick at an
|
||||
// interval of several lines.
|
||||
prev = syn_block->b_sst_first;
|
||||
for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) {
|
||||
for (synstate_T *p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) {
|
||||
if (p->sst_tick == tick && prev->sst_lnum + dist > p->sst_lnum) {
|
||||
// Move this entry from used list to free list
|
||||
prev->sst_next = p->sst_next;
|
||||
@ -1101,10 +1098,8 @@ static void syn_stack_free_entry(synblock_T *block, synstate_T *p)
|
||||
// Returns NULL when there is no entry or the first entry is after "lnum".
|
||||
static synstate_T *syn_stack_find_entry(linenr_T lnum)
|
||||
{
|
||||
synstate_T *p, *prev;
|
||||
|
||||
prev = NULL;
|
||||
for (p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next) {
|
||||
synstate_T *prev = NULL;
|
||||
for (synstate_T *p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next) {
|
||||
if (p->sst_lnum == lnum) {
|
||||
return p;
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
||||
int wantcol; // column at textwidth border
|
||||
int foundcol; // column for start of spaces
|
||||
int end_foundcol = 0; // column for start of word
|
||||
colnr_T len;
|
||||
colnr_T virtcol;
|
||||
int orig_col = 0;
|
||||
char *saved_text = NULL;
|
||||
@ -437,7 +436,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
||||
// Check if cursor is not past the NUL off the line, cindent
|
||||
// may have added or removed indent.
|
||||
curwin->w_cursor.col += startcol;
|
||||
len = (colnr_T)strlen(get_cursor_line_ptr());
|
||||
colnr_T len = (colnr_T)strlen(get_cursor_line_ptr());
|
||||
if (curwin->w_cursor.col > len) {
|
||||
curwin->w_cursor.col = len;
|
||||
}
|
||||
@ -518,7 +517,6 @@ static bool same_leader(linenr_T lnum, int leader1_len, char *leader1_flags, int
|
||||
char *leader2_flags)
|
||||
{
|
||||
int idx1 = 0, idx2 = 0;
|
||||
char *p;
|
||||
char *line1;
|
||||
char *line2;
|
||||
|
||||
@ -532,7 +530,7 @@ static bool same_leader(linenr_T lnum, int leader1_len, char *leader1_flags, int
|
||||
// If first leader has 's' flag, the lines can only be joined if there is
|
||||
// some text after it and the second line has the 'm' flag.
|
||||
if (leader1_flags != NULL) {
|
||||
for (p = leader1_flags; *p && *p != ':'; p++) {
|
||||
for (char *p = leader1_flags; *p && *p != ':'; p++) {
|
||||
if (*p == COM_FIRST) {
|
||||
return leader2_len == 0;
|
||||
}
|
||||
@ -629,9 +627,7 @@ static bool paragraph_start(linenr_T lnum)
|
||||
/// @param prev_line may start in previous line
|
||||
void auto_format(bool trailblank, bool prev_line)
|
||||
{
|
||||
colnr_T len;
|
||||
char *linep, *plinep;
|
||||
int cc;
|
||||
char *linep;
|
||||
|
||||
if (!has_format_option(FO_AUTO)) {
|
||||
return;
|
||||
@ -651,7 +647,7 @@ void auto_format(bool trailblank, bool prev_line)
|
||||
int wasatend = (pos.col == (colnr_T)strlen(old));
|
||||
if (*old != NUL && !trailblank && wasatend) {
|
||||
dec_cursor();
|
||||
cc = gchar_cursor();
|
||||
int cc = gchar_cursor();
|
||||
if (!WHITECHAR(cc) && curwin->w_cursor.col > 0
|
||||
&& has_format_option(FO_ONE_LETTER)) {
|
||||
dec_cursor();
|
||||
@ -702,9 +698,9 @@ void auto_format(bool trailblank, bool prev_line)
|
||||
// formatted.
|
||||
if (!wasatend && has_format_option(FO_WHITE_PAR)) {
|
||||
linep = get_cursor_line_ptr();
|
||||
len = (colnr_T)strlen(linep);
|
||||
colnr_T len = (colnr_T)strlen(linep);
|
||||
if (curwin->w_cursor.col == len) {
|
||||
plinep = xstrnsave(linep, (size_t)len + 2);
|
||||
char *plinep = xstrnsave(linep, (size_t)len + 2);
|
||||
plinep[len] = ' ';
|
||||
plinep[len + 1] = NUL;
|
||||
ml_replace(curwin->w_cursor.lnum, plinep, false);
|
||||
|
@ -61,10 +61,8 @@ void ugrid_scroll(UGrid *grid, int top, int bot, int left, int right, int count)
|
||||
step = -1;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
// Copy cell data
|
||||
for (i = start; i != stop; i += step) {
|
||||
for (int i = start; i != stop; i += step) {
|
||||
UCell *target_row = grid->cells[i] + left;
|
||||
UCell *source_row = grid->cells[i + count] + left;
|
||||
assert(right >= left && left >= 0);
|
||||
|
@ -2837,7 +2837,6 @@ void intro_message(int colon)
|
||||
|
||||
static void do_intro_line(int row, char *mesg, int attr)
|
||||
{
|
||||
char *p;
|
||||
int l;
|
||||
|
||||
// Center the message horizontally.
|
||||
@ -2851,7 +2850,7 @@ static void do_intro_line(int row, char *mesg, int attr)
|
||||
|
||||
grid_line_start(&default_grid, row);
|
||||
// Split up in parts to highlight <> items differently.
|
||||
for (p = mesg; *p != NUL; p += l) {
|
||||
for (char *p = mesg; *p != NUL; p += l) {
|
||||
for (l = 0;
|
||||
p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>'));
|
||||
l++) {
|
||||
|
Loading…
Reference in New Issue
Block a user