aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-04 14:44:13 +0800
committerGitHub <noreply@github.com>2023-05-04 14:44:13 +0800
commit24d4a825693db5f8454a389259a76f71f8697832 (patch)
treeef2a8f106faec12f3ba4d9e67a6be4db04fa3e43 /src/nvim
parenta1bd31e6010c803fd842db6bdb0d531a71e67837 (diff)
parent7ddf235d7e71ee8373b11baa6a49381311f5d61d (diff)
downloadrneovim-24d4a825693db5f8454a389259a76f71f8697832.tar.gz
rneovim-24d4a825693db5f8454a389259a76f71f8697832.tar.bz2
rneovim-24d4a825693db5f8454a389259a76f71f8697832.zip
Merge pull request #23466 from zeertzjq/vim-9.0.0138
vim-patch:9.0.{0138,0240}: two spell fixes
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/charset.c12
-rw-r--r--src/nvim/spell.c2
-rw-r--r--src/nvim/spellfile.c5
3 files changed, 16 insertions, 3 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 3d4e0abda9..8cae831881 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -858,8 +858,10 @@ bool vim_iswordp_buf(const char *const p, buf_T *const buf)
return vim_iswordc_buf(c, buf);
}
-/// Check that "c" is a valid file-name character.
+/// Check that "c" is a valid file-name character as specified with the
+/// 'isfname' option.
/// Assume characters above 0x100 are valid (multi-byte).
+/// To be used for commands like "gf".
///
/// @param c character to check
bool vim_isfilec(int c)
@@ -868,6 +870,14 @@ bool vim_isfilec(int c)
return c >= 0x100 || (c > 0 && (g_chartab[c] & CT_FNAME_CHAR));
}
+/// Check if "c" is a valid file-name character, including characters left
+/// out of 'isfname' to make "gf" work, such as comma, space, '@', etc.
+bool vim_is_fname_char(int c)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ return vim_isfilec(c) || c == ',' || c == ' ' || c == '@';
+}
+
/// Check that "c" is a valid file-name character or a wildcard character
/// Assume characters above 0x100 are valid (multi-byte).
/// Explicitly interpret ']' as a wildcard character as path_has_wildcard("]")
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index d1d1b9180f..84875261f1 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -3621,7 +3621,7 @@ bool valid_spellfile(const char *val)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
for (const char *s = val; *s != NUL; s++) {
- if (!vim_isfilec((uint8_t)(*s)) && *s != ',' && *s != ' ') {
+ if (!vim_is_fname_char((uint8_t)(*s))) {
return false;
}
}
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index b93dd55042..dae9edcf4f 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -4971,9 +4971,12 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
spin->si_sugtree = true;
// Go through the whole case-folded tree, soundfold each word and put it
- // in the trie.
+ // in the trie. Bail out if the tree is empty.
byts = slang->sl_fbyts;
idxs = slang->sl_fidxs;
+ if (byts == NULL || idxs == NULL) {
+ return FAIL;
+ }
arridx[0] = 0;
curi[0] = 1;