From db9ef6263ec5b7885782ccf0a93e06b0c71f6944 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 8 Apr 2017 16:45:38 +0200 Subject: mbyte: replace vim_tolower with mb_tolower handling locale correctly --- src/nvim/regexp.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 9baa53d2a2..7e2fc261f2 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2350,7 +2350,7 @@ collection: break; case CLASS_LOWER: for (cu = 1; cu <= 255; cu++) { - if (vim_islower(cu) && cu != 170 && cu != 186) { + if (mb_islower(cu) && cu != 170 && cu != 186) { regmbc(cu); } } @@ -2376,7 +2376,7 @@ collection: break; case CLASS_UPPER: for (cu = 1; cu <= 255; cu++) { - if (vim_isupper(cu)) { + if (mb_isupper(cu)) { regmbc(cu); } } @@ -3474,7 +3474,7 @@ static long bt_regexec_both(char_u *line, || (ireg_ic && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) || (c < 255 && prog->regstart < 255 - && vim_tolower(prog->regstart) == vim_tolower(c))))) { + && mb_tolower(prog->regstart) == mb_tolower(c))))) { retval = regtry(prog, col); } else { retval = 0; @@ -4155,7 +4155,7 @@ regmatch ( if (*opnd != *reginput && (!ireg_ic || (!enc_utf8 - && vim_tolower(*opnd) != vim_tolower(*reginput)))) { + && mb_tolower(*opnd) != mb_tolower(*reginput)))) { status = RA_NOMATCH; } else if (*opnd == NUL) { // match empty string always works; happens when "~" is @@ -4573,10 +4573,10 @@ regmatch ( if (OP(next) == EXACTLY) { rst.nextb = *OPERAND(next); if (ireg_ic) { - if (vim_isupper(rst.nextb)) - rst.nextb_ic = vim_tolower(rst.nextb); + if (mb_isupper(rst.nextb)) + rst.nextb_ic = mb_tolower(rst.nextb); else - rst.nextb_ic = vim_toupper(rst.nextb); + rst.nextb_ic = mb_toupper(rst.nextb); } else rst.nextb_ic = rst.nextb; } else { @@ -5339,8 +5339,8 @@ do_class: * would have been used for it. It does handle single-byte * characters, such as latin1. */ if (ireg_ic) { - cu = vim_toupper(*opnd); - cl = vim_tolower(*opnd); + cu = mb_toupper(*opnd); + cl = mb_tolower(*opnd); while (count < maxcount && (*scan == cu || *scan == cl)) { count++; scan++; @@ -6314,10 +6314,10 @@ static char_u *cstrchr(char_u *s, int c) * For UTF-8 need to use folded case. */ if (enc_utf8 && c > 0x80) cc = utf_fold(c); - else if (vim_isupper(c)) - cc = vim_tolower(c); - else if (vim_islower(c)) - cc = vim_toupper(c); + else if (mb_isupper(c)) + cc = mb_tolower(c); + else if (mb_islower(c)) + cc = mb_toupper(c); else return vim_strchr(s, c); @@ -6348,28 +6348,28 @@ static char_u *cstrchr(char_u *s, int c) static fptr_T do_upper(int *d, int c) { - *d = vim_toupper(c); + *d = mb_toupper(c); return (fptr_T)NULL; } static fptr_T do_Upper(int *d, int c) { - *d = vim_toupper(c); + *d = mb_toupper(c); return (fptr_T)do_Upper; } static fptr_T do_lower(int *d, int c) { - *d = vim_tolower(c); + *d = mb_tolower(c); return (fptr_T)NULL; } static fptr_T do_Lower(int *d, int c) { - *d = vim_tolower(c); + *d = mb_tolower(c); return (fptr_T)do_Lower; } -- cgit From c1cf03398143f4dc0ac9155988edad349d24deca Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 9 Apr 2017 10:08:26 +0200 Subject: lint: fix clint errors around mb_tolower calls --- src/nvim/regexp.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/nvim/regexp.c') 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)) { -- cgit