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

View File

@ -476,9 +476,10 @@ bool leftcol_changed(void)
int gchar_cursor(void) int gchar_cursor(void)
{ {
if (has_mbyte) if (has_mbyte) {
return utf_ptr2char(get_cursor_pos_ptr()); 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) + return ml_get_buf(curbuf, curwin->w_cursor.lnum, false) +
curwin->w_cursor.col; curwin->w_cursor.col;
} }

View File

@ -6198,12 +6198,10 @@ int oneright(void)
/* Adjust for multi-wide char (excluding TAB) */ /* Adjust for multi-wide char (excluding TAB) */
ptr = get_cursor_pos_ptr(); ptr = get_cursor_pos_ptr();
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc( coladvance(getviscol() + ((*ptr != TAB && vim_isprintc(utf_ptr2char(ptr))) ?
utf_ptr2char(ptr) ptr2cells(ptr) : 1));
)) curwin->w_set_curswant = true;
? ptr2cells(ptr) : 1)); // Return OK if the cursor moved, FAIL otherwise (at window edge).
curwin->w_set_curswant = TRUE;
/* Return OK if the cursor moved, FAIL otherwise (at window edge). */
return (prevpos.col != curwin->w_cursor.col return (prevpos.col != curwin->w_cursor.col
|| prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL; || prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL;
} }
@ -6258,10 +6256,10 @@ int oneleft(void)
/* Adjust for multi-wide char (not a TAB) */ /* Adjust for multi-wide char (not a TAB) */
ptr = get_cursor_pos_ptr(); ptr = get_cursor_pos_ptr();
if (*ptr != TAB && vim_isprintc( if (*ptr != TAB && vim_isprintc(utf_ptr2char(ptr))
utf_ptr2char(ptr) && ptr2cells(ptr) > 1) {
) && ptr2cells(ptr) > 1)
curwin->w_cursor.coladd = 0; curwin->w_cursor.coladd = 0;
}
} }
curwin->w_set_curswant = TRUE; 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; ) { for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) {
if (has_mbyte) { if (has_mbyte) {
len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1; len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1;
if (!vim_iswordc(utf_ptr2char(w - len))) if (!vim_iswordc(utf_ptr2char(w - len))) {
break; break;
}
w -= len; w -= len;
} else { } else {
if (!vim_iswordc(w[-1])) 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; int len;
if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1) { if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1) {
if (!vim_isprintc(utf_ptr2char(p))) if (!vim_isprintc(utf_ptr2char(p))) {
break; break;
}
p += len - 1; p += len - 1;
} else if (*p == TAB) } else if (*p == TAB)
*p = ' '; *p = ' ';

View File

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

View File

@ -1749,11 +1749,12 @@ del_lines (
int gchar_pos(pos_T *pos) 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 utf_ptr2char(ptr);
return (int)*ptr; }
return (int)(*ptr);
} }
/* /*
@ -2840,4 +2841,3 @@ int goto_im(void)
{ {
return p_im && stuff_empty() && typebuf_typed(); return p_im && stuff_empty() && typebuf_typed();
} }

View File

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

View File

@ -775,10 +775,11 @@ static int get_equi_class(char_u **pp)
if (has_mbyte) if (has_mbyte)
l = (*mb_ptr2len)(p + 2); l = (*mb_ptr2len)(p + 2);
if (p[l + 2] == '=' && p[l + 3] == ']') { if (p[l + 2] == '=' && p[l + 3] == ']') {
if (has_mbyte) if (has_mbyte) {
c = utf_ptr2char(p + 2); c = utf_ptr2char(p + 2);
else } else {
c = p[2]; c = p[2];
}
*pp += l + 4; *pp += l + 4;
return c; return c;
} }
@ -1110,10 +1111,11 @@ static int get_coll_element(char_u **pp)
if (has_mbyte) if (has_mbyte)
l = (*mb_ptr2len)(p + 2); l = (*mb_ptr2len)(p + 2);
if (p[l + 2] == '.' && p[l + 3] == ']') { if (p[l + 2] == '.' && p[l + 3] == ']') {
if (has_mbyte) if (has_mbyte) {
c = utf_ptr2char(p + 2); c = utf_ptr2char(p + 2);
else } else {
c = p[2]; c = p[2];
}
*pp += l + 4; *pp += l + 4;
return c; return c;
} }
@ -1299,10 +1301,11 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
} }
if (OP(scan) == EXACTLY) { if (OP(scan) == EXACTLY) {
if (has_mbyte) if (has_mbyte) {
r->regstart = utf_ptr2char(OPERAND(scan)); r->regstart = utf_ptr2char(OPERAND(scan));
else } else {
r->regstart = *OPERAND(scan); r->regstart = *OPERAND(scan);
}
} else if (OP(scan) == BOW } else if (OP(scan) == BOW
|| OP(scan) == EOW || OP(scan) == EOW
|| OP(scan) == NOTHING || 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) { || OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) {
char_u *regnext_scan = regnext(scan); char_u *regnext_scan = regnext(scan);
if (OP(regnext_scan) == EXACTLY) { if (OP(regnext_scan) == EXACTLY) {
if (has_mbyte) if (has_mbyte) {
r->regstart = utf_ptr2char(OPERAND(regnext_scan)); r->regstart = utf_ptr2char(OPERAND(regnext_scan));
else } else {
r->regstart = *OPERAND(regnext_scan); r->regstart = *OPERAND(regnext_scan);
}
} }
} }
@ -2906,17 +2910,19 @@ static int peekchr(void)
* Next character can never be (made) magic? * Next character can never be (made) magic?
* Then backslashing it won't do anything. * Then backslashing it won't do anything.
*/ */
if (has_mbyte) if (has_mbyte) {
curchr = utf_ptr2char(regparse + 1); curchr = utf_ptr2char(regparse + 1);
else } else {
curchr = c; curchr = c;
}
} }
break; break;
} }
default: default:
if (has_mbyte) if (has_mbyte) {
curchr = utf_ptr2char(regparse); curchr = utf_ptr2char(regparse);
}
} }
return curchr; return curchr;
@ -3468,10 +3474,11 @@ static long bt_regexec_both(char_u *line,
if (prog->regmust != NULL) { if (prog->regmust != NULL) {
int c; int c;
if (has_mbyte) if (has_mbyte) {
c = utf_ptr2char(prog->regmust); c = utf_ptr2char(prog->regmust);
else } else {
c = *prog->regmust; c = *prog->regmust;
}
s = line + col; s = line + col;
// This is used very often, esp. for ":global". Use two versions of // 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) { if (prog->reganch) {
int c; int c;
if (has_mbyte) if (has_mbyte) {
c = utf_ptr2char(regline + col); c = utf_ptr2char(regline + col);
else } else {
c = regline[col]; c = regline[col];
}
if (prog->regstart == NUL if (prog->regstart == NUL
|| prog->regstart == c || prog->regstart == c
|| (rex.reg_ic || (rex.reg_ic
@ -3860,10 +3868,11 @@ regmatch (
} else { } else {
if (WITH_NL(op)) if (WITH_NL(op))
op -= ADD_NL; op -= ADD_NL;
if (has_mbyte) if (has_mbyte) {
c = utf_ptr2char(reginput); c = utf_ptr2char(reginput);
else } else {
c = *reginput; c = *reginput;
}
switch (op) { switch (op) {
case BOL: case BOL:
if (reginput != regline) if (reginput != regline)
@ -6782,8 +6791,9 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
} }
c = *src++; c = *src++;
} }
} else if (has_mbyte) } else if (has_mbyte) {
c = utf_ptr2char(src - 1); c = utf_ptr2char(src - 1);
}
/* Write to buffer, if copy is set. */ /* Write to buffer, if copy is set. */
if (func_one != (fptr_T)NULL) 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; dst += 2;
} else { } else {
if (has_mbyte) if (has_mbyte) {
c = utf_ptr2char(s); c = utf_ptr2char(s);
else } else {
c = *s; c = *s;
}
if (func_one != (fptr_T)NULL) if (func_one != (fptr_T)NULL)
/* Turbo C complains without the typecast */ /* 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); c = utf_ptr2char(p);
if (c < 256 ? wp->w_s->b_spell_ismw[c] if (c < 256 ? wp->w_s->b_spell_ismw[c]
: (wp->w_s->b_spell_ismw_mb != NULL : (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; s = p + l;
}
} }
c = utf_ptr2char(s); c = utf_ptr2char(s);
if (c > 255) if (c > 255) {
return spell_mb_isword_class(mb_get_class(s), wp); return spell_mb_isword_class(mb_get_class(s), wp);
}
return spelltab.st_isw[c]; 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 && utf_iscomposing(utf_ptr2char(fword
+ sp->ts_fcharstart))) { + sp->ts_fcharstart))) {
sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP; sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP;
} else if (!soundfold } else if (!soundfold && slang->sl_has_map
&& slang->sl_has_map
&& similar_chars(slang, && similar_chars(slang,
utf_ptr2char(tword utf_ptr2char(tword + sp->ts_twordlen
+ sp->ts_twordlen - sp->ts_tcharlen),
- sp->ts_tcharlen), utf_ptr2char(fword +
utf_ptr2char(fword sp->ts_fcharstart))) {
+ sp->ts_fcharstart))) {
// For a similar character adjust score from // For a similar character adjust score from
// SCORE_SUBST to SCORE_SIMILAR. // SCORE_SUBST to SCORE_SIMILAR.
sp->ts_score -= SCORE_SUBST - 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) { if (has_mbyte) {
n = MB_CPTR2LEN(p); n = MB_CPTR2LEN(p);
c = utf_ptr2char(p); c = utf_ptr2char(p);
if (p[n] == NUL) if (p[n] == NUL) {
c2 = NUL; c2 = NUL;
else if (!soundfold && !spell_iswordp(p + n, curwin)) } else if (!soundfold && !spell_iswordp(p + n, curwin)) {
c2 = c; // don't swap non-word char c2 = c; // don't swap non-word char
else } else {
c2 = utf_ptr2char(p + n); c2 = utf_ptr2char(p + n);
}
} else { } else {
if (p[1] == NUL) if (p[1] == NUL) {
c2 = NUL; c2 = NUL;
else if (!soundfold && !spell_iswordp(p + 1, curwin)) } else if (!soundfold && !spell_iswordp(p + 1, curwin)) {
c2 = c; // don't swap non-word char c2 = c; // don't swap non-word char
else } else {
c2 = p[1]; c2 = p[1];
}
} }
// When the second character is NUL we can't swap. // 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) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI; sp->ts_state = STATE_REP_INI;
break; break;
} }
// When characters are identical, swap won't do anything. // When characters are identical, swap won't do anything.
// Also get here if the second char is not a word character. // Also get here if the second char is not a word character.
if (c == c2) { if (c == c2) {
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP3; sp->ts_state = STATE_SWAP3;
break; break;
} }
if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP)) { if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP)) {
go_deeper(stack, depth, SCORE_SWAP); go_deeper(stack, depth, SCORE_SWAP);
#ifdef DEBUG_TRIEWALK #ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: swap %c and %c", sprintf(changename[depth], "%.*s-%s: swap %c and %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx, 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); c = utf_ptr2char(p);
fl = MB_CPTR2LEN(p + n); fl = MB_CPTR2LEN(p + n);
c2 = utf_ptr2char(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 c3 = c; // don't swap non-word char
else } else {
c3 = utf_ptr2char(p + n + fl); c3 = utf_ptr2char(p + n + fl);
}
} else { } else {
c = *p; c = *p;
c2 = p[1]; c2 = p[1];
@ -5604,25 +5607,29 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
if (c1 >= 256) { if (c1 >= 256) {
buf[mb_char2bytes(c1, buf)] = 0; buf[mb_char2bytes(c1, buf)] = 0;
hi = hash_find(&slang->sl_map_hash, buf); hi = hash_find(&slang->sl_map_hash, buf);
if (HASHITEM_EMPTY(hi)) if (HASHITEM_EMPTY(hi)) {
m1 = 0; m1 = 0;
else } else {
m1 = utf_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1); m1 = utf_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
} else }
} else {
m1 = slang->sl_map_array[c1]; m1 = slang->sl_map_array[c1];
if (m1 == 0) }
if (m1 == 0) {
return false; return false;
}
if (c2 >= 256) { if (c2 >= 256) {
buf[mb_char2bytes(c2, buf)] = 0; buf[mb_char2bytes(c2, buf)] = 0;
hi = hash_find(&slang->sl_map_hash, buf); hi = hash_find(&slang->sl_map_hash, buf);
if (HASHITEM_EMPTY(hi)) if (HASHITEM_EMPTY(hi)) {
m2 = 0; m2 = 0;
else } else {
m2 = utf_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1); m2 = utf_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);
} else }
} else {
m2 = slang->sl_map_array[c2]; m2 = slang->sl_map_array[c2];
}
return m1 == m2; return m1 == m2;
} }
@ -5660,10 +5667,12 @@ add_suggestion (
MB_PTR_BACK(goodword, pgood); MB_PTR_BACK(goodword, pgood);
MB_PTR_BACK(su->su_badptr, pbad); MB_PTR_BACK(su->su_badptr, pbad);
if (has_mbyte) { if (has_mbyte) {
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
break; break;
} else if (*pgood != *pbad) }
} else if (*pgood != *pbad) {
break; break;
}
} }
if (badlen == 0 && goodlen == 0) 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; *matchp = ga.ga_data;
return ga.ga_len; return ga.ga_len;
} }