lint: clean-up after parent commits

This commit is contained in:
ZviRackover 2018-09-02 02:14:47 +03:00
parent ac13e65ae0
commit 329cfc3303
10 changed files with 70 additions and 60 deletions

View File

@ -8656,7 +8656,7 @@ static char_u *do_insert_char_pre(int c)
if (!has_event(EVENT_INSERTCHARPRE)) {
return NULL;
}
buf[utf_char2bytes(c, (char_u *) buf)] = NUL;
buf[utf_char2bytes(c, (char_u *)buf)] = NUL;
// Lock the text to avoid weird things from happening.
textlock++;

View File

@ -4718,10 +4718,11 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
++p;
/* For "\u" store the number according to
* 'encoding'. */
if (c != 'X')
if (c != 'X') {
name += utf_char2bytes(nr, name);
else
} else {
*name++ = nr;
}
}
break;
@ -9477,8 +9478,9 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
temp[i++] = K_SPECIAL;
temp[i++] = K_SECOND(n);
temp[i++] = K_THIRD(n);
} else
} else {
i += utf_char2bytes(n, temp + i);
}
temp[i++] = NUL;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave(temp);
@ -18344,8 +18346,7 @@ void set_vim_var_char(int c)
{
char buf[MB_MAXBYTES + 1];
buf[utf_char2bytes(c, (char_u *) buf)] = NUL;
buf[utf_char2bytes(c, (char_u *)buf)] = NUL;
set_vim_var_string(VV_CHAR, buf, -1);
}

View File

@ -1765,7 +1765,6 @@ static int command_line_handle_key(CommandLineState *s)
s->j = utf_char2bytes(s->c, IObuff);
IObuff[s->j] = NUL; // exclude composing chars
put_on_cmdline(IObuff, s->j, true);
}
return command_line_changed(s);
}
@ -2369,10 +2368,10 @@ redraw:
c1 = '?';
}
len = utf_char2bytes(c1, (char_u *)line_ga.ga_data + line_ga.ga_len);
if (c1 == '\n')
if (c1 == '\n') {
msg_putchar('\n');
else if (c1 == TAB) {
/* Don't use chartabsize(), 'ts' can be different */
} else if (c1 == TAB) {
// Don't use chartabsize(), 'ts' can be different.
do {
msg_putchar(' ');
} while (++vcol % 8);
@ -2891,9 +2890,9 @@ static void draw_cmdline(int start, int len)
newlen += utf_char2bytes(u8c, arshape_buf + newlen);
if (u8cc[0] != 0) {
newlen += utf_char2bytes(u8cc[0], arshape_buf + newlen);
if (u8cc[1] != 0)
newlen += utf_char2bytes(u8cc[1],
arshape_buf + newlen);
if (u8cc[1] != 0) {
newlen += utf_char2bytes(u8cc[1], arshape_buf + newlen);
}
}
} else {
prev_c = u8c;

View File

@ -3655,11 +3655,13 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
tb[j++] = (char_u)K_SECOND(c);
tb[j++] = (char_u)K_THIRD(c);
} else {
if (c < ABBR_OFF && (c < ' ' || c > '~'))
tb[j++] = Ctrl_V; /* special char needs CTRL-V */
/* if ABBR_OFF has been added, remove it here */
if (c >= ABBR_OFF)
if (c < ABBR_OFF && (c < ' ' || c > '~')) {
tb[j++] = Ctrl_V; // special char needs CTRL-V
}
// if ABBR_OFF has been added, remove it here.
if (c >= ABBR_OFF) {
c -= ABBR_OFF;
}
j += utf_char2bytes(c, tb + j);
}
tb[j] = NUL;

View File

@ -462,14 +462,13 @@ char_u *get_special_key_name(int c, int modifiers)
string[idx++] = '_';
string[idx++] = (char_u)KEY2TERMCAP0(c);
string[idx++] = KEY2TERMCAP1(c);
}
/* Not a special key, only modifiers, output directly */
else {
if (utf_char2len(c) > 1)
} else {
// Not a special key, only modifiers, output directly.
if (utf_char2len(c) > 1) {
idx += utf_char2bytes(c, string + idx);
else if (vim_isprintc(c))
} else if (vim_isprintc(c)) {
string[idx++] = (char_u)c;
else {
} else {
s = transchar(c);
while (*s)
string[idx++] = *s++;

View File

@ -2538,10 +2538,11 @@ static void regc(int b)
*/
static void regmbc(int c)
{
if (regcode == JUST_CALC_SIZE)
if (regcode == JUST_CALC_SIZE) {
regsize += utf_char2len(c);
else
} else {
regcode += utf_char2bytes(c, regcode);
}
}
/*
@ -6757,22 +6758,23 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
cc = c;
}
int totlen = utfc_ptr2len(src - 1);
int totlen = utfc_ptr2len(src - 1);
if (copy)
utf_char2bytes(cc, dst);
dst += utf_char2len(cc) - 1;
int clen = utf_ptr2len(src - 1);
if (copy) {
utf_char2bytes(cc, dst);
}
dst += utf_char2len(cc) - 1;
int clen = utf_ptr2len(src - 1);
/* If the character length is shorter than "totlen", there
* are composing characters; copy them as-is. */
if (clen < totlen) {
if (copy)
memmove(dst + 1, src - 1 + clen,
(size_t)(totlen - clen));
dst += totlen - clen;
// If the character length is shorter than "totlen", there
// are composing characters; copy them as-is.
if (clen < totlen) {
if (copy) {
memmove(dst + 1, src - 1 + clen, (size_t)(totlen - clen));
}
src += totlen - 1;
dst += totlen - clen;
}
src += totlen - 1;
dst++;
} else {
if (REG_MULTI) {
@ -6849,20 +6851,19 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
if (has_mbyte) {
int l;
/* Copy composing characters separately, one
* at a time. */
if (enc_utf8)
l = utf_ptr2len(s) - 1;
else
l = utfc_ptr2len(s) - 1;
// Copy composing characters separately, one
// at a time.
l = utf_ptr2len(s) - 1;
s += l;
len -= l;
if (copy)
if (copy) {
utf_char2bytes(cc, dst);
}
dst += utf_char2len(cc) - 1;
} else if (copy)
} else if (copy) {
*dst = cc;
}
dst++;
}

View File

@ -5121,7 +5121,7 @@ win_redr_custom (
/* fill up with "fillchar" */
while (width < maxwidth && len < (int)sizeof(buf) - 1) {
len += utf_char2bytes(fillchar, buf + len);
++width;
width++;
}
buf[len] = NUL;
@ -6955,7 +6955,7 @@ static void win_redr_ruler(win_T *wp, int always)
// Need at least 3 chars left for get_rel_pos() + NUL.
while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) {
i += utf_char2bytes(fillchar, buffer + i);
++o;
o++;
}
get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i);
}

View File

@ -1378,9 +1378,12 @@ int searchc(cmdarg_T *cap, int t_cmd)
set_csearch_until(t_cmd);
lastc_bytelen = utf_char2bytes(c, lastc_bytes);
if (cap->ncharC1 != 0) {
lastc_bytelen += utf_char2bytes(cap->ncharC1, lastc_bytes + lastc_bytelen);
if (cap->ncharC2 != 0)
lastc_bytelen += utf_char2bytes(cap->ncharC2, lastc_bytes + lastc_bytelen);
lastc_bytelen += utf_char2bytes(cap->ncharC1,
lastc_bytes + lastc_bytelen);
if (cap->ncharC2 != 0) {
lastc_bytelen += utf_char2bytes(cap->ncharC2,
lastc_bytes + lastc_bytelen);
}
}
}
} else { // repeat previous search

View File

@ -3461,8 +3461,9 @@ static void allcap_copy(char_u *word, char_u *wcopy)
} else
c = SPELL_TOUPPER(c);
if (d - wcopy >= MAXWLEN - MB_MAXBYTES)
if (d - wcopy >= MAXWLEN - MB_MAXBYTES) {
break;
}
d += utf_char2bytes(c, d);
}
*d = NUL;
@ -4531,15 +4532,16 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP;
++depth;
depth++;
fl = mb_char2len(c2);
memmove(p, p + n, fl);
utf_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
} else
} else {
// If this swap doesn't work then SWAP3 won't either.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNSWAP:
@ -4586,7 +4588,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP3;
++depth;
depth++;
tl = mb_char2len(c3);
memmove(p, p + n + fl, tl);
utf_char2bytes(c2, p + tl);
@ -5895,8 +5897,9 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res)
if (c != NUL && c != prevc) {
ri += utf_char2bytes(c, res + ri);
if (ri + MB_MAXBYTES > MAXWLEN)
if (ri + MB_MAXBYTES > MAXWLEN) {
break;
}
prevc = c;
}
}
@ -6416,10 +6419,11 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res)
// Convert wide characters in "wres" to a multi-byte string in "res".
l = 0;
for (n = 0; n < reslen; ++n) {
for (n = 0; n < reslen; n++) {
l += utf_char2bytes(wres[n], res + l);
if (l + MB_MAXBYTES > MAXWLEN)
if (l + MB_MAXBYTES > MAXWLEN) {
break;
}
}
res[l] = NUL;
}

View File

@ -1457,8 +1457,9 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
*pp++ = '|';
atstart = 1;
} else { // normal char, "[abc]" and '*' are copied as-is
if (c == '?' || c == '+' || c == '~')
if (c == '?' || c == '+' || c == '~') {
*pp++ = '\\'; // "a?" becomes "a\?", "a+" becomes "a\+"
}
pp += utf_char2bytes(c, pp);
}
}
@ -4241,7 +4242,7 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname)
// Form the <folchars> string first, we need to know its length.
size_t l = 0;
for (size_t i = 128; i < 256; ++i) {
for (size_t i = 128; i < 256; i++) {
l += (size_t)utf_char2bytes(spelltab.st_fold[i], folchars + l);
}
put_bytes(fd, 1 + 128 + 2 + l, 4); // <sectionlen>