aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/charset.c1
-rw-r--r--src/nvim/spell.c47
-rw-r--r--src/nvim/spell_defs.h13
-rw-r--r--src/nvim/spellfile.c78
4 files changed, 28 insertions, 111 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index e9140f8ec5..0f9e2e23c0 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -8,7 +8,6 @@
#include <assert.h>
#include <string.h>
#include <wctype.h>
-#include <wchar.h> // for towupper() and towlower()
#include <inttypes.h>
#include "nvim/vim.h"
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index a221f3fd75..6cb8d01f51 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -848,7 +848,7 @@ static void find_word(matchinf_T *mip, int mode)
mip->mi_compflags[mip->mi_complen] = ((unsigned)flags >> 24);
mip->mi_compflags[mip->mi_complen + 1] = NUL;
if (word_ends) {
- char_u fword[MAXWLEN];
+ char_u fword[MAXWLEN] = { 0 };
if (slang->sl_compsylmax < MAXWLEN) {
// "fword" is only needed for checking syllables.
@@ -1026,26 +1026,25 @@ match_checkcompoundpattern (
// Returns true if "flags" is a valid sequence of compound flags and "word"
// does not have too many syllables.
-static bool can_compound(slang_T *slang, char_u *word, char_u *flags)
+static bool can_compound(slang_T *slang, const char_u *word,
+ const char_u *flags)
+ FUNC_ATTR_NONNULL_ALL
{
- char_u uflags[MAXWLEN * 2];
- int i;
- char_u *p;
+ char_u uflags[MAXWLEN * 2] = { 0 };
- if (slang->sl_compprog == NULL)
+ if (slang->sl_compprog == NULL) {
return false;
- if (enc_utf8) {
- // Need to convert the single byte flags to utf8 characters.
- p = uflags;
- for (i = 0; flags[i] != NUL; i++) {
- p += utf_char2bytes(flags[i], p);
- }
- *p = NUL;
- p = uflags;
- } else
- p = flags;
- if (!vim_regexec_prog(&slang->sl_compprog, false, p, 0))
+ }
+ // Need to convert the single byte flags to utf8 characters.
+ char_u *p = uflags;
+ for (int i = 0; flags[i] != NUL; i++) {
+ p += utf_char2bytes(flags[i], p);
+ }
+ *p = NUL;
+ p = uflags;
+ if (!vim_regexec_prog(&slang->sl_compprog, false, p, 0)) {
return false;
+ }
// Count the number of syllables. This may be slow, do it last. If there
// are too many syllables AND the number of compound words is above
@@ -3607,7 +3606,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
{
char_u tword[MAXWLEN]; // good word collected so far
trystate_T stack[MAXWLEN];
- char_u preword[MAXWLEN * 3]; // word found with proper case;
+ char_u preword[MAXWLEN * 3] = { 0 }; // word found with proper case;
// concatenation of prefix compound
// words and split word. NUL terminated
// when going deeper but not when coming
@@ -4272,9 +4271,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// For changing a composing character adjust
// the score from SCORE_SUBST to
// SCORE_SUBCOMP.
- if (enc_utf8
- && utf_iscomposing(utf_ptr2char(tword + sp->ts_twordlen
- - sp->ts_tcharlen))
+ if (utf_iscomposing(utf_ptr2char(tword + sp->ts_twordlen
+ - sp->ts_tcharlen))
&& utf_iscomposing(utf_ptr2char(fword
+ sp->ts_fcharstart))) {
sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP;
@@ -5859,7 +5857,7 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res)
// 255, sl_sal the rest.
for (s = inword; *s != NUL; ) {
c = mb_cptr2char_adv((const char_u **)&s);
- if (enc_utf8 ? utf_class(c) == 0 : ascii_iswhite(c)) {
+ if (utf_class(c) == 0) {
c = ' ';
} else if (c < 256) {
c = slang->sl_sal_first[c];
@@ -5936,9 +5934,10 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res)
const char_u *t = s;
c = mb_cptr2char_adv((const char_u **)&s);
if (slang->sl_rem_accents) {
- if (enc_utf8 ? utf_class(c) == 0 : ascii_iswhite(c)) {
- if (did_white)
+ if (utf_class(c) == 0) {
+ if (did_white) {
continue;
+ }
c = ' ';
did_white = true;
} else {
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index e83b21b219..034c580b3e 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -261,20 +261,15 @@ typedef struct trystate_S {
// Use our own character-case definitions, because the current locale may
// differ from what the .spl file uses.
// These must not be called with negative number!
-#include <wchar.h> // for towupper() and towlower()
// Multi-byte implementation. For Unicode we can call utf_*(), but don't do
// that for ASCII, because we don't want to use 'casemap' here. Otherwise use
// the "w" library function for characters above 255.
-#define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
- : (c) < \
- 256 ? (int)spelltab.st_fold[c] : (int)towlower(c))
+#define SPELL_TOFOLD(c) ((c) >= 128 ? utf_fold(c) : (int)spelltab.st_fold[c])
-#define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? mb_toupper(c) \
- : (c) < \
- 256 ? (int)spelltab.st_upper[c] : (int)towupper(c))
+#define SPELL_TOUPPER(c) ((c) >= 128 ? mb_toupper(c) \
+ : (int)spelltab.st_upper[c])
-#define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? mb_isupper(c) \
- : (c) < 256 ? spelltab.st_isu[c] : iswupper(c))
+#define SPELL_ISUPPER(c) ((c) >= 128 ? mb_isupper(c) : spelltab.st_isu[c])
// First language that is loaded, start of the linked list of loaded
// languages.
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 14abfda9ff..f8c10d0258 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -304,9 +304,6 @@
static char *e_spell_trunc = N_("E758: Truncated spell file");
static char *e_afftrailing = N_("Trailing text in %s line %d: %s");
static char *e_affname = N_("Affix name too long in %s line %d: %s");
-static char *e_affform = N_("E761: Format error in affix file FOL, LOW or UPP");
-static char *e_affrange = N_(
- "E762: Character in FOL, LOW or UPP is out of range");
static char *msg_compressing = N_("Compressing word tree...");
#define MAXLINELEN 500 // Maximum length in bytes of a line in a .aff
@@ -1386,8 +1383,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
// Inserting backslashes may double the length, "^\(\)$<Nul>" is 7 bytes.
// Conversion to utf-8 may double the size.
c = todo * 2 + 7;
- if (enc_utf8)
- c += todo * 2;
+ c += todo * 2;
pat = xmalloc(c);
// We also need a list of all flags that can appear at the start and one
@@ -2624,19 +2620,6 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
spin->si_clear_chartab = false;
}
- // Don't write a word table for an ASCII file, so that we don't check
- // for conflicts with a word table that matches 'encoding'.
- // Don't write one for utf-8 either, we use utf_*() and
- // mb_get_class(), the list of chars in the file will be incomplete.
- if (!spin->si_ascii
- && !enc_utf8
- ) {
- if (fol == NULL || low == NULL || upp == NULL)
- smsg(_("Missing FOL/LOW/UPP line in %s"), fname);
- else
- (void)set_spell_chartab(fol, low, upp);
- }
-
xfree(fol);
xfree(low);
xfree(upp);
@@ -5533,65 +5516,6 @@ static void init_spellfile(void)
}
}
-// Set the spell character tables from strings in the affix file.
-static int set_spell_chartab(char_u *fol, char_u *low, char_u *upp)
-{
- // We build the new tables here first, so that we can compare with the
- // previous one.
- spelltab_T new_st;
- char_u *pf = fol, *pl = low, *pu = upp;
- int f, l, u;
-
- clear_spell_chartab(&new_st);
-
- while (*pf != NUL) {
- if (*pl == NUL || *pu == NUL) {
- EMSG(_(e_affform));
- return FAIL;
- }
- f = mb_ptr2char_adv((const char_u **)&pf);
- l = mb_ptr2char_adv((const char_u **)&pl);
- u = mb_ptr2char_adv((const char_u **)&pu);
- // Every character that appears is a word character.
- if (f < 256)
- new_st.st_isw[f] = true;
- if (l < 256)
- new_st.st_isw[l] = true;
- if (u < 256)
- new_st.st_isw[u] = true;
-
- // if "LOW" and "FOL" are not the same the "LOW" char needs
- // case-folding
- if (l < 256 && l != f) {
- if (f >= 256) {
- EMSG(_(e_affrange));
- return FAIL;
- }
- new_st.st_fold[l] = f;
- }
-
- // if "UPP" and "FOL" are not the same the "UPP" char needs
- // case-folding, it's upper case and the "UPP" is the upper case of
- // "FOL" .
- if (u < 256 && u != f) {
- if (f >= 256) {
- EMSG(_(e_affrange));
- return FAIL;
- }
- new_st.st_fold[u] = f;
- new_st.st_isu[u] = true;
- new_st.st_upper[f] = u;
- }
- }
-
- if (*pl != NUL || *pu != NUL) {
- EMSG(_(e_affform));
- return FAIL;
- }
-
- return set_spell_finish(&new_st);
-}
-
// Set the spell character tables from strings in the .spl file.
static void
set_spell_charflags (