lint: cleanup after parent commits

This commit is contained in:
ZviRackover
2018-08-16 05:09:21 +03:00
parent 30392b6356
commit d110c6d790
12 changed files with 84 additions and 86 deletions

View File

@@ -1557,10 +1557,10 @@ void display_dollar(colnr_T col)
save_col = curwin->w_cursor.col; save_col = curwin->w_cursor.col;
curwin->w_cursor.col = col; curwin->w_cursor.col = col;
/* If on the last byte of a multi-byte move to the first byte. */ // If on the last byte of a multi-byte move to the first byte.
char_u *p = get_cursor_line_ptr(); char_u *p = get_cursor_line_ptr();
curwin->w_cursor.col -= utf_head_off(p, p + col); curwin->w_cursor.col -= utf_head_off(p, p + col);
curs_columns(FALSE); /* recompute w_wrow and w_wcol */ curs_columns(false); // Recompute w_wrow and w_wcol
if (curwin->w_wcol < curwin->w_width) { if (curwin->w_wcol < curwin->w_width) {
edit_putchar('$', FALSE); edit_putchar('$', FALSE);
dollar_vcol = curwin->w_virtcol; dollar_vcol = curwin->w_virtcol;
@@ -3445,10 +3445,10 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
} }
if (compl_orig_text != NULL) { if (compl_orig_text != NULL) {
p = compl_orig_text; p = compl_orig_text;
for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) for (len = 0; p[len] != NUL && p[len] == ptr[len]; len++) {}
; if (len > 0) {
if (len > 0)
len -= utf_head_off(p, p + len); len -= utf_head_off(p, p + len);
}
for (p += len; *p != NUL; MB_PTR_ADV(p)) { for (p += len; *p != NUL; MB_PTR_ADV(p)) {
AppendCharToRedobuff(K_BS); AppendCharToRedobuff(K_BS);
} }
@@ -4584,15 +4584,15 @@ static int ins_complete(int c, bool enable_pum)
compl_col += curs_col; compl_col += curs_col;
compl_length = 0; compl_length = 0;
} else { } else {
/* Search the point of change class of multibyte character // Search the point of change class of multibyte character
* or not a word single byte character backward. */ // or not a word single byte character backward.
startcol -= utf_head_off(line, line + startcol); startcol -= utf_head_off(line, line + startcol);
int base_class = mb_get_class(line + startcol); int base_class = mb_get_class(line + startcol);
while (--startcol >= 0) { while (--startcol >= 0) {
int head_off = utf_head_off(line, line + startcol); int head_off = utf_head_off(line, line + startcol);
if (base_class != mb_get_class(line + startcol if (base_class != mb_get_class(line + startcol - head_off)) {
- head_off))
break; break;
}
startcol -= head_off; startcol -= head_off;
} }
compl_col += ++startcol; compl_col += ++startcol;

View File

@@ -1431,7 +1431,7 @@ static int command_line_handle_key(CommandLineState *s)
return command_line_not_changed(s); return command_line_not_changed(s);
} }
do { do {
--ccline.cmdpos; ccline.cmdpos--;
// Move to first byte of possibly multibyte char. // Move to first byte of possibly multibyte char.
ccline.cmdpos -= utf_head_off(ccline.cmdbuff, ccline.cmdpos -= utf_head_off(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos); ccline.cmdbuff + ccline.cmdpos);
@@ -3145,18 +3145,15 @@ void put_on_cmdline(char_u *str, int len, int redraw)
i = 0; i = 0;
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
while (ccline.cmdpos > 0 && utf_iscomposing(c)) { while (ccline.cmdpos > 0 && utf_iscomposing(c)) {
i = utf_head_off(ccline.cmdbuff, i = utf_head_off(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos - 1) + 1;
ccline.cmdbuff + ccline.cmdpos - 1) + 1;
ccline.cmdpos -= i; ccline.cmdpos -= i;
len += i; len += i;
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
} }
if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) { if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) {
/* Check the previous character for Arabic combining pair. */ // Check the previous character for Arabic combining pair.
i = utf_head_off(ccline.cmdbuff, i = utf_head_off(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos - 1) + 1;
ccline.cmdbuff + ccline.cmdpos - 1) + 1; if (arabic_combine(utf_ptr2char(ccline.cmdbuff + ccline.cmdpos - i), c)) {
if (arabic_combine(utf_ptr2char(ccline.cmdbuff
+ ccline.cmdpos - i), c)) {
ccline.cmdpos -= i; ccline.cmdpos -= i;
len += i; len += i;
} else } else

View File

@@ -2130,12 +2130,13 @@ static int vgetorpeek(int advance)
col = curwin->w_cursor.col - 1; col = curwin->w_cursor.col - 1;
} }
if (col > 0 && curwin->w_wcol > 0) { if (col > 0 && curwin->w_wcol > 0) {
/* Correct when the cursor is on the right halve // Correct when the cursor is on the right halve
* of a double-wide character. */ // of a double-wide character.
ptr = get_cursor_line_ptr(); ptr = get_cursor_line_ptr();
col -= utf_head_off(ptr, ptr + col); col -= utf_head_off(ptr, ptr + col);
if ((*mb_ptr2cells)(ptr + col) > 1) if (utf_ptr2cells(ptr + col) > 1) {
--curwin->w_wcol; curwin->w_wcol--;
}
} }
} }
setcursor(); setcursor();

View File

@@ -118,7 +118,8 @@
// Advance multi-byte pointer, do not skip over composing chars. // Advance multi-byte pointer, do not skip over composing chars.
# define MB_CPTR_ADV(p) (p += utf_ptr2len(p)) # define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
// Backup multi-byte pointer. Only use with "p" > "s" ! // Backup multi-byte pointer. Only use with "p" > "s" !
# define MB_PTR_BACK(s, p) (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1) # define MB_PTR_BACK(s, p) \
(p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
// get length of multi-byte char, not including composing chars // get length of multi-byte char, not including composing chars
# define MB_CPTR2LEN(p) utf_ptr2len(p) # define MB_CPTR2LEN(p) utf_ptr2len(p)

View File

@@ -2859,8 +2859,9 @@ static void find_start_of_word(pos_T *pos)
while (pos->col > 0) { while (pos->col > 0) {
col = pos->col - 1; col = pos->col - 1;
col -= utf_head_off(line, line + col); col -= utf_head_off(line, line + col);
if (get_mouse_class(line + col) != cclass) if (get_mouse_class(line + col) != cclass) {
break; break;
}
pos->col = col; pos->col = col;
} }
} }
@@ -2877,7 +2878,7 @@ static void find_end_of_word(pos_T *pos)
line = ml_get(pos->lnum); line = ml_get(pos->lnum);
if (*p_sel == 'e' && pos->col > 0) { if (*p_sel == 'e' && pos->col > 0) {
--pos->col; pos->col--;
pos->col -= utf_head_off(line, line + pos->col); pos->col -= utf_head_off(line, line + pos->col);
} }
cclass = get_mouse_class(line + pos->col); cclass = get_mouse_class(line + pos->col);
@@ -3055,39 +3056,38 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol,
++col; ++col;
/* //
* 2. Back up to start of identifier/string. // 2. Back up to start of identifier/string.
*/ //
/* Remember class of character under cursor. */ // Remember class of character under cursor.
this_class = mb_get_class(ptr + col); this_class = mb_get_class(ptr + col);
while (col > 0 && this_class != 0) { while (col > 0 && this_class != 0) {
prevcol = col - 1 - utf_head_off(ptr, ptr + col - 1); prevcol = col - 1 - utf_head_off(ptr, ptr + col - 1);
prev_class = mb_get_class(ptr + prevcol); prev_class = mb_get_class(ptr + prevcol);
if (this_class != prev_class if (this_class != prev_class
&& (i == 0 && (i == 0 || prev_class == 0 || (find_type & FIND_IDENT))) {
|| prev_class == 0
|| (find_type & FIND_IDENT))
)
break; break;
}
col = prevcol; col = prevcol;
} }
/* If we don't want just any old string, or we've found an // If we don't want just any old string, or we've found an
* identifier, stop searching. */ // identifier, stop searching.
if (this_class > 2) if (this_class > 2) {
this_class = 2; this_class = 2;
if (!(find_type & FIND_STRING) || this_class == 2) }
if (!(find_type & FIND_STRING) || this_class == 2) {
break; break;
} }
}
if (ptr[col] == NUL || (i == 0 && this_class != 2)) { if (ptr[col] == NUL || (i == 0 && this_class != 2)) {
/* // Didn't find an identifier or string.
* didn't find an identifier or string if (find_type & FIND_STRING) {
*/
if (find_type & FIND_STRING)
EMSG(_("E348: No string under cursor")); EMSG(_("E348: No string under cursor"));
else } else {
EMSG(_(e_noident)); EMSG(_(e_noident));
}
return 0; return 0;
} }
ptr += col; ptr += col;

View File

@@ -2432,11 +2432,10 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
if (virtual_op) { if (virtual_op) {
getvcol(curwin, &oap->end, &cs, NULL, &ce); getvcol(curwin, &oap->end, &cs, NULL, &ce);
if (p[endcol] == NUL || (cs + oap->end.coladd < ce if (p[endcol] == NUL || (cs + oap->end.coladd < ce
/* Don't add space for double-wide // Don't add space for double-wide
* char; endcol will be on last byte // char; endcol will be on last byte
* of multi-byte char. */ // of multi-byte char.
&& utf_head_off(p, p + endcol) == 0 && utf_head_off(p, p + endcol) == 0)) {
)) {
if (oap->start.lnum == oap->end.lnum if (oap->start.lnum == oap->end.lnum
&& oap->start.col == oap->end.col) { && oap->start.col == oap->end.col) {
/* Special case: inside a single char */ /* Special case: inside a single char */

View File

@@ -3653,8 +3653,7 @@ static long regtry(bt_regprog_T *prog, colnr_T col)
static int reg_prev_class(void) static int reg_prev_class(void)
{ {
if (reginput > regline) { if (reginput > regline) {
return mb_get_class_tab(reginput - 1 - utf_head_off(regline, return mb_get_class_tab(reginput - 1 - utf_head_off(regline, reginput - 1),
reginput - 1),
rex.reg_buf->b_chartab); rex.reg_buf->b_chartab);
} }
return -1; return -1;

View File

@@ -4640,10 +4640,11 @@ static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T
if ((int)(reginput - regline) >= state->val) { if ((int)(reginput - regline) >= state->val) {
reginput -= state->val; reginput -= state->val;
reginput -= utf_head_off(regline, reginput); reginput -= utf_head_off(regline, reginput);
} else } else {
reginput = regline; reginput = regline;
} }
} }
}
#ifdef REGEXP_DEBUG #ifdef REGEXP_DEBUG
if (log_fd != stderr) if (log_fd != stderr)

View File

@@ -817,9 +817,9 @@ int searchit(
pos->lnum, FALSE)); pos->lnum, FALSE));
} }
} else { } else {
--pos->col; pos->col--;
if (pos->lnum <= buf->b_ml.ml_line_count) { if (pos->lnum <= buf->b_ml.ml_line_count) {
ptr = ml_get_buf(buf, pos->lnum, FALSE); ptr = ml_get_buf(buf, pos->lnum, false);
pos->col -= utf_head_off(ptr, ptr + pos->col); pos->col -= utf_head_off(ptr, ptr + pos->col);
} }
} }
@@ -1441,15 +1441,16 @@ int searchc(cmdarg_T *cap, int t_cmd)
} }
if (t_cmd) { if (t_cmd) {
/* backup to before the character (possibly double-byte) */ // Backup to before the character (possibly double-byte).
col -= dir; col -= dir;
if (dir < 0) if (dir < 0) {
/* Landed on the search char which is lastc_bytelen long */ // Landed on the search char which is lastc_bytelen long.
col += lastc_bytelen - 1; col += lastc_bytelen - 1;
else } else {
/* To previous char, which may be multi-byte. */ // To previous char, which may be multi-byte.
col -= utf_head_off(p, p + col); col -= utf_head_off(p, p + col);
} }
}
curwin->w_cursor.col = col; curwin->w_cursor.col = col;
return OK; return OK;
@@ -1469,21 +1470,21 @@ pos_T *findmatch(oparg_T *oap, int initc)
return findmatchlimit(oap, initc, 0, 0); return findmatchlimit(oap, initc, 0, 0);
} }
/* // Return true if the character before "linep[col]" equals "ch".
* Return TRUE if the character before "linep[col]" equals "ch". // Return false if "col" is zero.
* Return FALSE if "col" is zero. // Update "*prevcol" to the column of the previous character, unless "prevcol"
* Update "*prevcol" to the column of the previous character, unless "prevcol" // is NULL.
* is NULL. // Handles multibyte string correctly.
* Handles multibyte string correctly. static bool check_prevcol(char_u *linep, int col, int ch, int *prevcol)
*/
static int check_prevcol(char_u *linep, int col, int ch, int *prevcol)
{ {
--col; col--;
if (col > 0) if (col > 0) {
col -= utf_head_off(linep, linep + col); col -= utf_head_off(linep, linep + col);
if (prevcol) }
if (prevcol) {
*prevcol = col; *prevcol = col;
return (col >= 0 && linep[col] == ch) ? TRUE : FALSE; }
return (col >= 0 && linep[col] == ch) ? true : false;
} }
/* /*
@@ -1790,7 +1791,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
if (lisp && comment_col != MAXCOL) if (lisp && comment_col != MAXCOL)
pos.col = comment_col; pos.col = comment_col;
} else { } else {
--pos.col; pos.col--;
pos.col -= utf_head_off(linep, linep + pos.col); pos.col -= utf_head_off(linep, linep + pos.col);
} }
} else { /* forward search */ } else { /* forward search */
@@ -2381,8 +2382,7 @@ findpar (
// motion inclusive. // motion inclusive.
if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) {
curwin->w_cursor.col--; curwin->w_cursor.col--;
curwin->w_cursor.col -= curwin->w_cursor.col -= utf_head_off(line, line + curwin->w_cursor.col);
utf_head_off(line, line + curwin->w_cursor.col);
*pincl = true; *pincl = true;
} }
} else } else
@@ -3687,7 +3687,7 @@ find_prev_quote(
int n; int n;
while (col_start > 0) { while (col_start > 0) {
--col_start; col_start--;
col_start -= utf_head_off(line, line + col_start); col_start -= utf_head_off(line, line + col_start);
n = 0; n = 0;
if (escape != NULL) if (escape != NULL)

View File

@@ -688,8 +688,9 @@ static void find_word(matchinf_T *mip, int mode)
arridx = endidx[endidxcnt]; arridx = endidx[endidxcnt];
wlen = endlen[endidxcnt]; wlen = endlen[endidxcnt];
if (utf_head_off(ptr, ptr + wlen) > 0) if (utf_head_off(ptr, ptr + wlen) > 0) {
continue; // not at first byte of character continue; // not at first byte of character
}
if (spell_iswordp(ptr + wlen, mip->mi_win)) { if (spell_iswordp(ptr + wlen, mip->mi_win)) {
if (slang->sl_compprog == NULL && !slang->sl_nobreak) if (slang->sl_compprog == NULL && !slang->sl_nobreak)
continue; // next char is a word character continue; // next char is a word character

View File

@@ -1726,14 +1726,12 @@ static int syn_current_attr(
*/ */
if (do_keywords) { if (do_keywords) {
line = syn_getcurline(); line = syn_getcurline();
if (vim_iswordp_buf(line + current_col, syn_buf) const char_u *cur_pos = line + current_col;
&& (current_col == 0 if (vim_iswordp_buf(cur_pos, syn_buf)
|| !vim_iswordp_buf(line + current_col - 1 && (current_col == 0 || !vim_iswordp_buf(
- utf_head_off(line, line + current_col - 1) cur_pos - 1 - utf_head_off(line, cur_pos - 1), syn_buf))) {
, syn_buf))) { syn_id = check_keyword_id(line, (int)current_col, &endcol, &flags,
syn_id = check_keyword_id(line, (int)current_col, &next_list, cur_si, &cchar);
&endcol, &flags, &next_list, cur_si,
&cchar);
if (syn_id != 0) { if (syn_id != 0) {
push_current_state(KEYWORD_IDX); push_current_state(KEYWORD_IDX);
{ {

View File

@@ -5130,14 +5130,15 @@ file_name_in_line (
* Go one char back to ":" before "//" even when ':' is not in 'isfname'. * Go one char back to ":" before "//" even when ':' is not in 'isfname'.
*/ */
while (ptr > line) { while (ptr > line) {
if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) {
ptr -= len + 1; ptr -= len + 1;
else if (vim_isfilec(ptr[-1]) } else if (vim_isfilec(ptr[-1])
|| ((options & FNAME_HYP) && path_is_url((char *)ptr - 1))) || ((options & FNAME_HYP) && path_is_url((char *)ptr - 1))) {
--ptr; ptr--;
else } else {
break; break;
} }
}
/* /*
* Search forward for the last char of the file name. * Search forward for the last char of the file name.