lint: clean-up after parent commit

This commit is contained in:
ZviRackover 2018-06-30 13:29:09 +03:00
parent 10b6afd652
commit cd3b2e4b6b
10 changed files with 115 additions and 92 deletions

View File

@ -3220,10 +3220,11 @@ int build_stl_str_hl(
// Get the byte value now, in case we need it below. This is more
// efficient than making a copy of the line.
int byteval;
if (wp->w_cursor.col > (colnr_T)STRLEN(line_ptr))
if (wp->w_cursor.col > (colnr_T)STRLEN(line_ptr)) {
byteval = 0;
else
} else {
byteval = utf_ptr2char(line_ptr + wp->w_cursor.col);
}
int groupdepth = 0;

View File

@ -476,9 +476,10 @@ bool leftcol_changed(void)
int gchar_cursor(void)
{
if (has_mbyte)
if (has_mbyte) {
return utf_ptr2char(get_cursor_pos_ptr());
return (int)*get_cursor_pos_ptr();
}
return (int)(*get_cursor_pos_ptr());
}
/*
@ -507,4 +508,3 @@ char_u *get_cursor_pos_ptr(void)
return ml_get_buf(curbuf, curwin->w_cursor.lnum, false) +
curwin->w_cursor.col;
}

View File

@ -6198,12 +6198,10 @@ int oneright(void)
/* Adjust for multi-wide char (excluding TAB) */
ptr = get_cursor_pos_ptr();
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc(
utf_ptr2char(ptr)
))
? ptr2cells(ptr) : 1));
curwin->w_set_curswant = TRUE;
/* Return OK if the cursor moved, FAIL otherwise (at window edge). */
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc(utf_ptr2char(ptr))) ?
ptr2cells(ptr) : 1));
curwin->w_set_curswant = true;
// Return OK if the cursor moved, FAIL otherwise (at window edge).
return (prevpos.col != curwin->w_cursor.col
|| prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL;
}
@ -6258,10 +6256,10 @@ int oneleft(void)
/* Adjust for multi-wide char (not a TAB) */
ptr = get_cursor_pos_ptr();
if (*ptr != TAB && vim_isprintc(
utf_ptr2char(ptr)
) && ptr2cells(ptr) > 1)
if (*ptr != TAB && vim_isprintc(utf_ptr2char(ptr))
&& ptr2cells(ptr) > 1) {
curwin->w_cursor.coladd = 0;
}
}
curwin->w_set_curswant = TRUE;

View File

@ -3329,8 +3329,9 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) {
if (has_mbyte) {
len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1;
if (!vim_iswordc(utf_ptr2char(w - len)))
if (!vim_iswordc(utf_ptr2char(w - len))) {
break;
}
w -= len;
} else {
if (!vim_iswordc(w[-1]))

View File

@ -1767,8 +1767,9 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
int len;
if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1) {
if (!vim_isprintc(utf_ptr2char(p)))
if (!vim_isprintc(utf_ptr2char(p))) {
break;
}
p += len - 1;
} else if (*p == TAB)
*p = ' ';

View File

@ -2868,8 +2868,9 @@ do_dialog (
retval = 1;
for (i = 0; hotkeys[i]; ++i) {
if (has_mbyte) {
if (utf_ptr2char(hotkeys + i) == c)
if (utf_ptr2char(hotkeys + i) == c) {
break;
}
i += (*mb_ptr2len)(hotkeys + i) - 1;
} else if (hotkeys[i] == c)
break;

View File

@ -1749,11 +1749,12 @@ del_lines (
int gchar_pos(pos_T *pos)
{
char_u *ptr = ml_get_pos(pos);
char_u *ptr = ml_get_pos(pos);
if (has_mbyte)
if (has_mbyte) {
return utf_ptr2char(ptr);
return (int)*ptr;
}
return (int)(*ptr);
}
/*
@ -2840,4 +2841,3 @@ int goto_im(void)
{
return p_im && stuff_empty() && typebuf_typed();
}

View File

@ -6406,21 +6406,24 @@ static void langmap_set(void)
++p;
break;
}
if (p[0] == '\\' && p[1] != NUL)
++p;
if (p[0] == '\\' && p[1] != NUL) {
p++;
}
from = utf_ptr2char(p);
to = NUL;
if (p2 == NULL) {
MB_PTR_ADV(p);
if (p[0] != ',') {
if (p[0] == '\\')
++p;
if (p[0] == '\\') {
p++;
}
to = utf_ptr2char(p);
}
} else {
if (p2[0] != ',') {
if (p2[0] == '\\')
++p2;
if (p2[0] == '\\') {
p2++;
}
to = utf_ptr2char(p2);
}
}
@ -6857,10 +6860,10 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit)
if (switchit) {
*findc = *initc;
*initc = utf_ptr2char(ptr + mb_ptr2len(ptr) + 1);
*backwards = TRUE;
*backwards = true;
} else {
*findc = utf_ptr2char(ptr + mb_ptr2len(ptr) + 1);
*backwards = FALSE;
*backwards = false;
}
return;
}
@ -6870,10 +6873,10 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit)
if (switchit) {
*findc = *initc;
*initc = utf_ptr2char(prev);
*backwards = FALSE;
*backwards = false;
} else {
*findc = utf_ptr2char(prev);
*backwards = TRUE;
*backwards = true;
}
return;
}

View File

@ -775,10 +775,11 @@ static int get_equi_class(char_u **pp)
if (has_mbyte)
l = (*mb_ptr2len)(p + 2);
if (p[l + 2] == '=' && p[l + 3] == ']') {
if (has_mbyte)
if (has_mbyte) {
c = utf_ptr2char(p + 2);
else
} else {
c = p[2];
}
*pp += l + 4;
return c;
}
@ -1110,10 +1111,11 @@ static int get_coll_element(char_u **pp)
if (has_mbyte)
l = (*mb_ptr2len)(p + 2);
if (p[l + 2] == '.' && p[l + 3] == ']') {
if (has_mbyte)
if (has_mbyte) {
c = utf_ptr2char(p + 2);
else
} else {
c = p[2];
}
*pp += l + 4;
return c;
}
@ -1299,10 +1301,11 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
}
if (OP(scan) == EXACTLY) {
if (has_mbyte)
if (has_mbyte) {
r->regstart = utf_ptr2char(OPERAND(scan));
else
} else {
r->regstart = *OPERAND(scan);
}
} else if (OP(scan) == BOW
|| OP(scan) == EOW
|| OP(scan) == NOTHING
@ -1310,10 +1313,11 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
|| OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) {
char_u *regnext_scan = regnext(scan);
if (OP(regnext_scan) == EXACTLY) {
if (has_mbyte)
if (has_mbyte) {
r->regstart = utf_ptr2char(OPERAND(regnext_scan));
else
} else {
r->regstart = *OPERAND(regnext_scan);
}
}
}
@ -2906,17 +2910,19 @@ static int peekchr(void)
* Next character can never be (made) magic?
* Then backslashing it won't do anything.
*/
if (has_mbyte)
if (has_mbyte) {
curchr = utf_ptr2char(regparse + 1);
else
} else {
curchr = c;
}
}
break;
}
default:
if (has_mbyte)
if (has_mbyte) {
curchr = utf_ptr2char(regparse);
}
}
return curchr;
@ -3468,10 +3474,11 @@ static long bt_regexec_both(char_u *line,
if (prog->regmust != NULL) {
int c;
if (has_mbyte)
if (has_mbyte) {
c = utf_ptr2char(prog->regmust);
else
} else {
c = *prog->regmust;
}
s = line + col;
// This is used very often, esp. for ":global". Use two versions of
@ -3504,10 +3511,11 @@ static long bt_regexec_both(char_u *line,
if (prog->reganch) {
int c;
if (has_mbyte)
if (has_mbyte) {
c = utf_ptr2char(regline + col);
else
} else {
c = regline[col];
}
if (prog->regstart == NUL
|| prog->regstart == c
|| (rex.reg_ic
@ -3860,10 +3868,11 @@ regmatch (
} else {
if (WITH_NL(op))
op -= ADD_NL;
if (has_mbyte)
if (has_mbyte) {
c = utf_ptr2char(reginput);
else
} else {
c = *reginput;
}
switch (op) {
case BOL:
if (reginput != regline)
@ -6782,8 +6791,9 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
}
c = *src++;
}
} else if (has_mbyte)
} else if (has_mbyte) {
c = utf_ptr2char(src - 1);
}
/* Write to buffer, if copy is set. */
if (func_one != (fptr_T)NULL)
@ -6878,10 +6888,11 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
}
dst += 2;
} else {
if (has_mbyte)
if (has_mbyte) {
c = utf_ptr2char(s);
else
} else {
c = *s;
}
if (func_one != (fptr_T)NULL)
/* Turbo C complains without the typecast */

View File

@ -2600,13 +2600,15 @@ static bool spell_iswordp(char_u *p, win_T *wp)
c = utf_ptr2char(p);
if (c < 256 ? wp->w_s->b_spell_ismw[c]
: (wp->w_s->b_spell_ismw_mb != NULL
&& vim_strchr(wp->w_s->b_spell_ismw_mb, c) != NULL))
&& vim_strchr(wp->w_s->b_spell_ismw_mb, c) != NULL)) {
s = p + l;
}
}
c = utf_ptr2char(s);
if (c > 255)
if (c > 255) {
return spell_mb_isword_class(mb_get_class(s), wp);
}
return spelltab.st_isw[c];
}
@ -4300,14 +4302,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
&& utf_iscomposing(utf_ptr2char(fword
+ sp->ts_fcharstart))) {
sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP;
} else if (!soundfold
&& slang->sl_has_map
} else if (!soundfold && slang->sl_has_map
&& similar_chars(slang,
utf_ptr2char(tword
+ sp->ts_twordlen
- sp->ts_tcharlen),
utf_ptr2char(fword
+ sp->ts_fcharstart))) {
utf_ptr2char(tword + sp->ts_twordlen
- sp->ts_tcharlen),
utf_ptr2char(fword +
sp->ts_fcharstart))) {
// For a similar character adjust score from
// SCORE_SUBST to SCORE_SIMILAR.
sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;
@ -4518,19 +4518,21 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
if (has_mbyte) {
n = MB_CPTR2LEN(p);
c = utf_ptr2char(p);
if (p[n] == NUL)
if (p[n] == NUL) {
c2 = NUL;
else if (!soundfold && !spell_iswordp(p + n, curwin))
c2 = c; // don't swap non-word char
else
} else if (!soundfold && !spell_iswordp(p + n, curwin)) {
c2 = c; // don't swap non-word char
} else {
c2 = utf_ptr2char(p + n);
}
} else {
if (p[1] == NUL)
if (p[1] == NUL) {
c2 = NUL;
else if (!soundfold && !spell_iswordp(p + 1, curwin))
c2 = c; // don't swap non-word char
else
} else if (!soundfold && !spell_iswordp(p + 1, curwin)) {
c2 = c; // don't swap non-word char
} else {
c2 = p[1];
}
}
// When the second character is NUL we can't swap.
@ -4538,17 +4540,17 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
}
// When characters are identical, swap won't do anything.
// Also get here if the second char is not a word character.
if (c == c2) {
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP3;
break;
}
if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP)) {
go_deeper(stack, depth, SCORE_SWAP);
// When characters are identical, swap won't do anything.
// Also get here if the second char is not a word character.
if (c == c2) {
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP3;
break;
}
if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP)) {
go_deeper(stack, depth, SCORE_SWAP);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: swap %c and %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
@ -4597,10 +4599,11 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
c = utf_ptr2char(p);
fl = MB_CPTR2LEN(p + n);
c2 = utf_ptr2char(p + n);
if (!soundfold && !spell_iswordp(p + n + fl, curwin))
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
c3 = c; // don't swap non-word char
else
} else {
c3 = utf_ptr2char(p + n + fl);
}
} else {
c = *p;
c2 = p[1];
@ -5604,25 +5607,29 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
if (c1 >= 256) {
buf[mb_char2bytes(c1, buf)] = 0;
hi = hash_find(&slang->sl_map_hash, buf);
if (HASHITEM_EMPTY(hi))
if (HASHITEM_EMPTY(hi)) {
m1 = 0;
else
} else {
m1 = utf_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
} else
}
} else {
m1 = slang->sl_map_array[c1];
if (m1 == 0)
}
if (m1 == 0) {
return false;
}
if (c2 >= 256) {
buf[mb_char2bytes(c2, buf)] = 0;
hi = hash_find(&slang->sl_map_hash, buf);
if (HASHITEM_EMPTY(hi))
if (HASHITEM_EMPTY(hi)) {
m2 = 0;
else
} else {
m2 = utf_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
} else
}
} else {
m2 = slang->sl_map_array[c2];
}
return m1 == m2;
}
@ -5660,10 +5667,12 @@ add_suggestion (
MB_PTR_BACK(goodword, pgood);
MB_PTR_BACK(su->su_badptr, pbad);
if (has_mbyte) {
if (utf_ptr2char(pgood) != utf_ptr2char(pbad))
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
break;
} else if (*pgood != *pbad)
}
} else if (*pgood != *pbad) {
break;
}
}
if (badlen == 0 && goodlen == 0)
@ -7608,5 +7617,3 @@ int expand_spelling(linenr_T lnum, char_u *pat, char_u ***matchp)
*matchp = ga.ga_data;
return ga.ga_len;
}