aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZviRackover <zvirack@gmail.com>2018-09-02 02:14:47 +0300
committerZviRackover <zvirack@gmail.com>2018-09-09 10:45:50 +0300
commit329cfc3303cffd5c9aad7b2ad7f4323354d68b0d (patch)
treee9abce8472ef283396c7830947c56e1d6154ef86 /src
parentac13e65ae0ce98516e816ba4fcf468d19e750c30 (diff)
downloadrneovim-329cfc3303cffd5c9aad7b2ad7f4323354d68b0d.tar.gz
rneovim-329cfc3303cffd5c9aad7b2ad7f4323354d68b0d.tar.bz2
rneovim-329cfc3303cffd5c9aad7b2ad7f4323354d68b0d.zip
lint: clean-up after parent commits
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c11
-rw-r--r--src/nvim/ex_getln.c13
-rw-r--r--src/nvim/getchar.c10
-rw-r--r--src/nvim/keymap.c11
-rw-r--r--src/nvim/regexp.c47
-rw-r--r--src/nvim/screen.c4
-rw-r--r--src/nvim/search.c9
-rw-r--r--src/nvim/spell.c18
-rw-r--r--src/nvim/spellfile.c5
10 files changed, 70 insertions, 60 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 414e2fd36c..e42fe4efb0 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -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++;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 0a84c26762..38a080b1ef 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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);
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 15308692e1..c2559e051d 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -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;
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 75d05fc891..8f1e5bb6c1 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -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;
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index ea1e84452e..ade5487ec8 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -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++;
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 085b70ad7e..4f51a8b4cf 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -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++;
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 63d8f5d506..69c3d3067d 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -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);
}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 34364b61c2..7e06f96b87 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -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
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 92ded29a70..970e50771d 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -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;
}
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index cc9af6fd80..f52ae61534 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -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>