diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-04-09 10:08:26 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2017-04-10 12:02:26 +0200 |
commit | c1cf03398143f4dc0ac9155988edad349d24deca (patch) | |
tree | ab3992856251b9adb86f44611f0c9c36926b8e0d | |
parent | acc06b0b7b99925d7567d2e79c2f5e88434edae8 (diff) | |
download | rneovim-c1cf03398143f4dc0ac9155988edad349d24deca.tar.gz rneovim-c1cf03398143f4dc0ac9155988edad349d24deca.tar.bz2 rneovim-c1cf03398143f4dc0ac9155988edad349d24deca.zip |
lint: fix clint errors around mb_tolower calls
-rw-r--r-- | src/nvim/edit.c | 3 | ||||
-rw-r--r-- | src/nvim/eval.c | 6 | ||||
-rw-r--r-- | src/nvim/mbyte.c | 14 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 17 | ||||
-rw-r--r-- | src/nvim/path.c | 2 | ||||
-rw-r--r-- | src/nvim/regexp.c | 17 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 14 | ||||
-rw-r--r-- | src/nvim/search.c | 25 | ||||
-rw-r--r-- | src/nvim/spell.c | 44 |
10 files changed, 68 insertions, 76 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index aa254b0577..fe00027dec 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2303,8 +2303,9 @@ static void ins_compl_longest_match(compl_T *match) c2 = *s; } if (match->cp_icase ? (mb_tolower(c1) != mb_tolower(c2)) - : (c1 != c2)) + : (c1 != c2)) { break; + } if (has_mbyte) { mb_ptr_adv(p); mb_ptr_adv(s); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ed07de51c8..0663e19b9a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16792,7 +16792,8 @@ void timer_teardown(void) static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr) { rettv->v_type = VAR_STRING; - rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]), false); + rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]), + false); } /* @@ -16801,7 +16802,8 @@ static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_toupper(typval_T *argvars, typval_T *rettv, FunPtr fptr) { rettv->v_type = VAR_STRING; - rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]), true); + rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]), + true); } /* diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 5f5abbeac5..b18459a2b5 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1179,10 +1179,8 @@ int utf_fold(int a) // invalid values or can't handle latin1 when the locale is C. // Speed is most important here. -/* - * Return the upper-case equivalent of "a", which is a UCS-4 character. Use - * simple case folding. - */ +/// Return the upper-case equivalent of "a", which is a UCS-4 character. Use +/// simple case folding. int mb_toupper(int a) { /* If 'casemap' contains "keepascii" use ASCII style toupper(). */ @@ -1205,14 +1203,12 @@ int mb_toupper(int a) bool mb_islower(int a) { - /* German sharp s is lower case but has no upper case equivalent. */ + // German sharp s is lower case but has no upper case equivalent. return (mb_toupper(a) != a) || a == 0xdf; } -/* - * Return the lower-case equivalent of "a", which is a UCS-4 character. Use - * simple case folding. - */ +/// Return the lower-case equivalent of "a", which is a UCS-4 character. Use +/// simple case folding. int mb_tolower(int a) { /* If 'casemap' contains "keepascii" use ASCII style tolower(). */ diff --git a/src/nvim/message.c b/src/nvim/message.c index 2cc426cf42..3e4a1e10b6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2730,7 +2730,7 @@ do_dialog ( break; } - /* Make the character lowercase, as chars in "hotkeys" are. */ + // Make the character lowercase, as chars in "hotkeys" are. c = mb_tolower(c); retval = 1; for (i = 0; hotkeys[i]; ++i) { diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c5b7e65983..f11d6b69b2 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1957,15 +1957,17 @@ int swapchar(int op_type, pos_T *pos) return FALSE; nc = c; if (mb_islower(c)) { - if (op_type == OP_ROT13) + if (op_type == OP_ROT13) { nc = ROT13(c, 'a'); - else if (op_type != OP_LOWER) + } else if (op_type != OP_LOWER) { nc = mb_toupper(c); + } } else if (mb_isupper(c)) { - if (op_type == OP_ROT13) + if (op_type == OP_ROT13) { nc = ROT13(c, 'A'); - else if (op_type != OP_UPPER) + } else if (op_type != OP_UPPER) { nc = mb_tolower(c); + } } if (nc != c) { if (enc_utf8 && (c >= 0x80 || nc >= 0x80)) { @@ -3328,9 +3330,10 @@ void ex_display(exarg_T *eap) get_clipboard(name, &yb, true); if (name == mb_tolower(redir_reg) - || (redir_reg == '"' && yb == y_previous)) - continue; /* do not list register being written to, the - * pointer can be freed */ + || (redir_reg == '"' && yb == y_previous)) { + continue; // do not list register being written to, the + // pointer can be freed + } if (yb->y_array != NULL) { msg_putchar('\n'); diff --git a/src/nvim/path.c b/src/nvim/path.c index 781522f63f..205fc2ed62 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1865,7 +1865,7 @@ int pathcmp(const char *p, const char *q, int maxlen) if (vim_ispathsep(c2)) return 1; return p_fic ? mb_toupper(c1) - mb_toupper(c2) - : c1 - c2; /* no match */ + : c1 - c2; // no match } i += MB_PTR2LEN((char_u *)p + i); diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 7e2fc261f2..4b5e17b00b 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -4573,12 +4573,14 @@ regmatch ( if (OP(next) == EXACTLY) { rst.nextb = *OPERAND(next); if (ireg_ic) { - if (mb_isupper(rst.nextb)) + if (mb_isupper(rst.nextb)) { rst.nextb_ic = mb_tolower(rst.nextb); - else + } else { rst.nextb_ic = mb_toupper(rst.nextb); - } else + } + } else { rst.nextb_ic = rst.nextb; + } } else { rst.nextb = NUL; rst.nextb_ic = NUL; @@ -6312,14 +6314,15 @@ static char_u *cstrchr(char_u *s, int c) /* tolower() and toupper() can be slow, comparing twice should be a lot * faster (esp. when using MS Visual C++!). * For UTF-8 need to use folded case. */ - if (enc_utf8 && c > 0x80) + if (c > 0x80) { cc = utf_fold(c); - else if (mb_isupper(c)) + } else if (mb_isupper(c)) { cc = mb_tolower(c); - else if (mb_islower(c)) + } else if (mb_islower(c)) { cc = mb_toupper(c); - else + } else { return vim_strchr(s, c); + } if (has_mbyte) { for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) { diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 1d57595cbe..caf26fdd35 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4391,8 +4391,9 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_UPPER: - if (mb_isupper(c)) + if (mb_isupper(c)) { return OK; + } break; case NFA_CLASS_XDIGIT: if (ascii_isxdigit(c)) @@ -5586,16 +5587,18 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, } if (ireg_ic) { int curc_low = mb_tolower(curc); - int done = FALSE; + int done = false; - for (; c1 <= c2; ++c1) + for (; c1 <= c2; c1++) { if (mb_tolower(c1) == curc_low) { result = result_if_matched; done = TRUE; break; } - if (done) + } + if (done) { break; + } } } else if (state->c < 0 ? check_char_class(state->c, curc) : (curc == state->c @@ -6003,8 +6006,9 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, #endif result = (c == curc); - if (!result && ireg_ic) + if (!result && ireg_ic) { result = mb_tolower(c) == mb_tolower(curc); + } // If ireg_icombine is not set only skip over the character // itself. When it is set skip over composing characters. diff --git a/src/nvim/search.c b/src/nvim/search.c index 4f060b2b8b..91a558045f 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -335,23 +335,26 @@ int pat_has_uppercase(char_u *pat) while (*p != NUL) { int l; - if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { - if (enc_utf8 && mb_isupper(utf_ptr2char(p))) - return TRUE; + if ((l = mb_ptr2len(p)) > 1) { + if (mb_isupper(utf_ptr2char(p))) { + return true; + } p += l; } else if (*p == '\\') { - if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */ + if (p[1] == '_' && p[2] != NUL) { // skip "\_X" p += 3; - else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */ + } else if (p[1] == '%' && p[2] != NUL) { // skip "\%X" p += 3; - else if (p[1] != NUL) /* skip "\X" */ + } else if (p[1] != NUL) { // skip "\X" p += 2; - else + } else { p += 1; - } else if (mb_isupper(*p)) - return TRUE; - else - ++p; + } + } else if (mb_isupper(*p)) { + return true; + } else { + p++; + } } return FALSE; } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 99661d0ef5..18febda1d8 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2526,8 +2526,7 @@ void clear_spell_chartab(spelltab_T *sp) } } -// Init the chartab used for spelling. Only depends on 'encoding'. -// Called once while starting up and when 'encoding' changes. +// Init the chartab used for spelling. Called once while starting up. // The default is to use isalpha(), but the spell file should define the word // characters to make it possible that 'encoding' differs from the current // locale. For utf-8 we don't use isalpha() but our own functions. @@ -2537,36 +2536,17 @@ void init_spell_chartab(void) did_set_spelltab = false; clear_spell_chartab(&spelltab); - if (enc_dbcs) { - // DBCS: assume double-wide characters are word characters. - for (i = 128; i <= 255; ++i) - if (MB_BYTE2LEN(i) == 2) - spelltab.st_isw[i] = true; - } else if (enc_utf8) { - for (i = 128; i < 256; ++i) { - int f = utf_fold(i); - int u = mb_toupper(i); - - spelltab.st_isu[i] = mb_isupper(i); - spelltab.st_isw[i] = spelltab.st_isu[i] || mb_islower(i); - // The folded/upper-cased value is different between latin1 and - // utf8 for 0xb5, causing E763 for no good reason. Use the latin1 - // value for utf-8 to avoid this. - spelltab.st_fold[i] = (f < 256) ? f : i; - spelltab.st_upper[i] = (u < 256) ? u : i; - } - } else { - // Rough guess: use locale-dependent library functions. - for (i = 128; i < 256; ++i) { - if (mb_isupper(i)) { - spelltab.st_isw[i] = true; - spelltab.st_isu[i] = true; - spelltab.st_fold[i] = mb_tolower(i); - } else if (mb_islower(i)) { - spelltab.st_isw[i] = true; - spelltab.st_upper[i] = mb_toupper(i); - } - } + for (i = 128; i < 256; i++) { + int f = utf_fold(i); + int u = mb_toupper(i); + + spelltab.st_isu[i] = mb_isupper(i); + spelltab.st_isw[i] = spelltab.st_isu[i] || mb_islower(i); + // The folded/upper-cased value is different between latin1 and + // utf8 for 0xb5, causing E763 for no good reason. Use the latin1 + // value for utf-8 to avoid this. + spelltab.st_fold[i] = (f < 256) ? f : i; + spelltab.st_upper[i] = (u < 256) ? u : i; } } |