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/spell.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/spell.c') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d4f49bffb2..99661d0ef5 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2545,10 +2545,10 @@ void init_spell_chartab(void) } else if (enc_utf8) { for (i = 128; i < 256; ++i) { int f = utf_fold(i); - int u = utf_toupper(i); + int u = mb_toupper(i); - spelltab.st_isu[i] = utf_isupper(i); - spelltab.st_isw[i] = spelltab.st_isu[i] || utf_islower(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. @@ -2558,13 +2558,13 @@ void init_spell_chartab(void) } else { // Rough guess: use locale-dependent library functions. for (i = 128; i < 256; ++i) { - if (vim_isupper(i)) { + if (mb_isupper(i)) { spelltab.st_isw[i] = true; spelltab.st_isu[i] = true; - spelltab.st_fold[i] = vim_tolower(i); - } else if (vim_islower(i)) { + spelltab.st_fold[i] = mb_tolower(i); + } else if (mb_islower(i)) { spelltab.st_isw[i] = true; - spelltab.st_upper[i] = vim_toupper(i); + spelltab.st_upper[i] = mb_toupper(i); } } } -- 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/spell.c | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'src/nvim/spell.c') 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; } } -- cgit From 2d72d85b23761383ac7838faed2f7b53bdce8817 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Tue, 11 Apr 2017 22:44:48 +0200 Subject: refactor: pos_T macros to functions (#6496) --- src/nvim/spell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/spell.c') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 18febda1d8..17016be35f 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -92,6 +92,7 @@ #include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/hashtab.h" +#include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" -- cgit From c2f3e361c52ec4e7149ea1d8c6a1202e0873da8e Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:11:50 +0300 Subject: *: Add comment to all C files --- src/nvim/spell.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/spell.c') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 17016be35f..25ae562e65 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1,3 +1,6 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + // spell.c: code for spell checking // // See spellfile.c for the Vim spell file format. -- cgit