mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 22:08:18 +00:00
lint: fix clint errors around mb_tolower calls
This commit is contained in:
@@ -2303,8 +2303,9 @@ static void ins_compl_longest_match(compl_T *match)
|
|||||||
c2 = *s;
|
c2 = *s;
|
||||||
}
|
}
|
||||||
if (match->cp_icase ? (mb_tolower(c1) != mb_tolower(c2))
|
if (match->cp_icase ? (mb_tolower(c1) != mb_tolower(c2))
|
||||||
: (c1 != c2))
|
: (c1 != c2)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
mb_ptr_adv(p);
|
mb_ptr_adv(p);
|
||||||
mb_ptr_adv(s);
|
mb_ptr_adv(s);
|
||||||
|
@@ -16792,7 +16792,8 @@ void timer_teardown(void)
|
|||||||
static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
rettv->v_type = VAR_STRING;
|
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)
|
static void f_toupper(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
rettv->v_type = VAR_STRING;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1179,10 +1179,8 @@ int utf_fold(int a)
|
|||||||
// invalid values or can't handle latin1 when the locale is C.
|
// invalid values or can't handle latin1 when the locale is C.
|
||||||
// Speed is most important here.
|
// Speed is most important here.
|
||||||
|
|
||||||
/*
|
/// Return the upper-case equivalent of "a", which is a UCS-4 character. Use
|
||||||
* Return the upper-case equivalent of "a", which is a UCS-4 character. Use
|
/// simple case folding.
|
||||||
* simple case folding.
|
|
||||||
*/
|
|
||||||
int mb_toupper(int a)
|
int mb_toupper(int a)
|
||||||
{
|
{
|
||||||
/* If 'casemap' contains "keepascii" use ASCII style toupper(). */
|
/* If 'casemap' contains "keepascii" use ASCII style toupper(). */
|
||||||
@@ -1205,14 +1203,12 @@ int mb_toupper(int a)
|
|||||||
|
|
||||||
bool mb_islower(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 (mb_toupper(a) != a) || a == 0xdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Return the lower-case equivalent of "a", which is a UCS-4 character. Use
|
||||||
* Return the lower-case equivalent of "a", which is a UCS-4 character. Use
|
/// simple case folding.
|
||||||
* simple case folding.
|
|
||||||
*/
|
|
||||||
int mb_tolower(int a)
|
int mb_tolower(int a)
|
||||||
{
|
{
|
||||||
/* If 'casemap' contains "keepascii" use ASCII style tolower(). */
|
/* If 'casemap' contains "keepascii" use ASCII style tolower(). */
|
||||||
|
@@ -2730,7 +2730,7 @@ do_dialog (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make the character lowercase, as chars in "hotkeys" are. */
|
// Make the character lowercase, as chars in "hotkeys" are.
|
||||||
c = mb_tolower(c);
|
c = mb_tolower(c);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
for (i = 0; hotkeys[i]; ++i) {
|
for (i = 0; hotkeys[i]; ++i) {
|
||||||
|
@@ -1957,15 +1957,17 @@ int swapchar(int op_type, pos_T *pos)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
nc = c;
|
nc = c;
|
||||||
if (mb_islower(c)) {
|
if (mb_islower(c)) {
|
||||||
if (op_type == OP_ROT13)
|
if (op_type == OP_ROT13) {
|
||||||
nc = ROT13(c, 'a');
|
nc = ROT13(c, 'a');
|
||||||
else if (op_type != OP_LOWER)
|
} else if (op_type != OP_LOWER) {
|
||||||
nc = mb_toupper(c);
|
nc = mb_toupper(c);
|
||||||
|
}
|
||||||
} else if (mb_isupper(c)) {
|
} else if (mb_isupper(c)) {
|
||||||
if (op_type == OP_ROT13)
|
if (op_type == OP_ROT13) {
|
||||||
nc = ROT13(c, 'A');
|
nc = ROT13(c, 'A');
|
||||||
else if (op_type != OP_UPPER)
|
} else if (op_type != OP_UPPER) {
|
||||||
nc = mb_tolower(c);
|
nc = mb_tolower(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (nc != c) {
|
if (nc != c) {
|
||||||
if (enc_utf8 && (c >= 0x80 || nc >= 0x80)) {
|
if (enc_utf8 && (c >= 0x80 || nc >= 0x80)) {
|
||||||
@@ -3328,9 +3330,10 @@ void ex_display(exarg_T *eap)
|
|||||||
get_clipboard(name, &yb, true);
|
get_clipboard(name, &yb, true);
|
||||||
|
|
||||||
if (name == mb_tolower(redir_reg)
|
if (name == mb_tolower(redir_reg)
|
||||||
|| (redir_reg == '"' && yb == y_previous))
|
|| (redir_reg == '"' && yb == y_previous)) {
|
||||||
continue; /* do not list register being written to, the
|
continue; // do not list register being written to, the
|
||||||
* pointer can be freed */
|
// pointer can be freed
|
||||||
|
}
|
||||||
|
|
||||||
if (yb->y_array != NULL) {
|
if (yb->y_array != NULL) {
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
|
@@ -1865,7 +1865,7 @@ int pathcmp(const char *p, const char *q, int maxlen)
|
|||||||
if (vim_ispathsep(c2))
|
if (vim_ispathsep(c2))
|
||||||
return 1;
|
return 1;
|
||||||
return p_fic ? mb_toupper(c1) - mb_toupper(c2)
|
return p_fic ? mb_toupper(c1) - mb_toupper(c2)
|
||||||
: c1 - c2; /* no match */
|
: c1 - c2; // no match
|
||||||
}
|
}
|
||||||
|
|
||||||
i += MB_PTR2LEN((char_u *)p + i);
|
i += MB_PTR2LEN((char_u *)p + i);
|
||||||
|
@@ -4573,12 +4573,14 @@ regmatch (
|
|||||||
if (OP(next) == EXACTLY) {
|
if (OP(next) == EXACTLY) {
|
||||||
rst.nextb = *OPERAND(next);
|
rst.nextb = *OPERAND(next);
|
||||||
if (ireg_ic) {
|
if (ireg_ic) {
|
||||||
if (mb_isupper(rst.nextb))
|
if (mb_isupper(rst.nextb)) {
|
||||||
rst.nextb_ic = mb_tolower(rst.nextb);
|
rst.nextb_ic = mb_tolower(rst.nextb);
|
||||||
else
|
} else {
|
||||||
rst.nextb_ic = mb_toupper(rst.nextb);
|
rst.nextb_ic = mb_toupper(rst.nextb);
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
rst.nextb_ic = rst.nextb;
|
rst.nextb_ic = rst.nextb;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rst.nextb = NUL;
|
rst.nextb = NUL;
|
||||||
rst.nextb_ic = 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
|
/* tolower() and toupper() can be slow, comparing twice should be a lot
|
||||||
* faster (esp. when using MS Visual C++!).
|
* faster (esp. when using MS Visual C++!).
|
||||||
* For UTF-8 need to use folded case. */
|
* For UTF-8 need to use folded case. */
|
||||||
if (enc_utf8 && c > 0x80)
|
if (c > 0x80) {
|
||||||
cc = utf_fold(c);
|
cc = utf_fold(c);
|
||||||
else if (mb_isupper(c))
|
} else if (mb_isupper(c)) {
|
||||||
cc = mb_tolower(c);
|
cc = mb_tolower(c);
|
||||||
else if (mb_islower(c))
|
} else if (mb_islower(c)) {
|
||||||
cc = mb_toupper(c);
|
cc = mb_toupper(c);
|
||||||
else
|
} else {
|
||||||
return vim_strchr(s, c);
|
return vim_strchr(s, c);
|
||||||
|
}
|
||||||
|
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) {
|
for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) {
|
||||||
|
@@ -4391,8 +4391,9 @@ static int check_char_class(int class, int c)
|
|||||||
return OK;
|
return OK;
|
||||||
break;
|
break;
|
||||||
case NFA_CLASS_UPPER:
|
case NFA_CLASS_UPPER:
|
||||||
if (mb_isupper(c))
|
if (mb_isupper(c)) {
|
||||||
return OK;
|
return OK;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NFA_CLASS_XDIGIT:
|
case NFA_CLASS_XDIGIT:
|
||||||
if (ascii_isxdigit(c))
|
if (ascii_isxdigit(c))
|
||||||
@@ -5586,16 +5587,18 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
|||||||
}
|
}
|
||||||
if (ireg_ic) {
|
if (ireg_ic) {
|
||||||
int curc_low = mb_tolower(curc);
|
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) {
|
if (mb_tolower(c1) == curc_low) {
|
||||||
result = result_if_matched;
|
result = result_if_matched;
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (done)
|
}
|
||||||
|
if (done) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (state->c < 0 ? check_char_class(state->c, curc)
|
} else if (state->c < 0 ? check_char_class(state->c, curc)
|
||||||
: (curc == state->c
|
: (curc == state->c
|
||||||
@@ -6003,8 +6006,9 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
|||||||
#endif
|
#endif
|
||||||
result = (c == curc);
|
result = (c == curc);
|
||||||
|
|
||||||
if (!result && ireg_ic)
|
if (!result && ireg_ic) {
|
||||||
result = mb_tolower(c) == mb_tolower(curc);
|
result = mb_tolower(c) == mb_tolower(curc);
|
||||||
|
}
|
||||||
|
|
||||||
// If ireg_icombine is not set only skip over the character
|
// If ireg_icombine is not set only skip over the character
|
||||||
// itself. When it is set skip over composing characters.
|
// itself. When it is set skip over composing characters.
|
||||||
|
@@ -335,23 +335,26 @@ int pat_has_uppercase(char_u *pat)
|
|||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) {
|
if ((l = mb_ptr2len(p)) > 1) {
|
||||||
if (enc_utf8 && mb_isupper(utf_ptr2char(p)))
|
if (mb_isupper(utf_ptr2char(p))) {
|
||||||
return TRUE;
|
return true;
|
||||||
|
}
|
||||||
p += l;
|
p += l;
|
||||||
} else if (*p == '\\') {
|
} else if (*p == '\\') {
|
||||||
if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */
|
if (p[1] == '_' && p[2] != NUL) { // skip "\_X"
|
||||||
p += 3;
|
p += 3;
|
||||||
else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */
|
} else if (p[1] == '%' && p[2] != NUL) { // skip "\%X"
|
||||||
p += 3;
|
p += 3;
|
||||||
else if (p[1] != NUL) /* skip "\X" */
|
} else if (p[1] != NUL) { // skip "\X"
|
||||||
p += 2;
|
p += 2;
|
||||||
else
|
} else {
|
||||||
p += 1;
|
p += 1;
|
||||||
} else if (mb_isupper(*p))
|
}
|
||||||
return TRUE;
|
} else if (mb_isupper(*p)) {
|
||||||
else
|
return true;
|
||||||
++p;
|
} else {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -2526,8 +2526,7 @@ void clear_spell_chartab(spelltab_T *sp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init the chartab used for spelling. Only depends on 'encoding'.
|
// Init the chartab used for spelling. Called once while starting up.
|
||||||
// Called once while starting up and when 'encoding' changes.
|
|
||||||
// The default is to use isalpha(), but the spell file should define the word
|
// 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
|
// characters to make it possible that 'encoding' differs from the current
|
||||||
// locale. For utf-8 we don't use isalpha() but our own functions.
|
// 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;
|
did_set_spelltab = false;
|
||||||
clear_spell_chartab(&spelltab);
|
clear_spell_chartab(&spelltab);
|
||||||
if (enc_dbcs) {
|
for (i = 128; i < 256; i++) {
|
||||||
// DBCS: assume double-wide characters are word characters.
|
int f = utf_fold(i);
|
||||||
for (i = 128; i <= 255; ++i)
|
int u = mb_toupper(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_isu[i] = mb_isupper(i);
|
||||||
spelltab.st_isw[i] = spelltab.st_isu[i] || mb_islower(i);
|
spelltab.st_isw[i] = spelltab.st_isu[i] || mb_islower(i);
|
||||||
// The folded/upper-cased value is different between latin1 and
|
// The folded/upper-cased value is different between latin1 and
|
||||||
// utf8 for 0xb5, causing E763 for no good reason. Use the latin1
|
// utf8 for 0xb5, causing E763 for no good reason. Use the latin1
|
||||||
// value for utf-8 to avoid this.
|
// value for utf-8 to avoid this.
|
||||||
spelltab.st_fold[i] = (f < 256) ? f : i;
|
spelltab.st_fold[i] = (f < 256) ? f : i;
|
||||||
spelltab.st_upper[i] = (u < 256) ? u : 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user