mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0252: not properly recognizing word characters between 128 and 255
Problem: Characters below 256 that are not one byte are not always
recognized as word characters.
Solution: Make vim_iswordc() and vim_iswordp() work the same way. Add a test
for this. (Ozaki Kiichi)
4019cf90b8
This commit is contained in:
parent
70626e6a1e
commit
6ff892165a
@ -842,7 +842,7 @@ bool vim_iswordc_tab(const int c, const uint64_t *const chartab)
|
|||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
return (c >= 0x100
|
return (c >= 0x100
|
||||||
? (utf_class(c) >= 2)
|
? (utf_class_tab(c, chartab) >= 2)
|
||||||
: (c > 0 && GET_CHARTAB_TAB(chartab, c) != 0));
|
: (c > 0 && GET_CHARTAB_TAB(chartab, c) != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,10 +866,7 @@ bool vim_iswordc_buf(int c, buf_T *buf)
|
|||||||
bool vim_iswordp(char_u *p)
|
bool vim_iswordp(char_u *p)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (MB_BYTE2LEN(*p) > 1) {
|
return vim_iswordp_buf(p, curbuf);
|
||||||
return mb_get_class(p) >= 2;
|
|
||||||
}
|
|
||||||
return GET_CHARTAB(curbuf, *p) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Just like vim_iswordc_buf() but uses a pointer to the (multi-byte)
|
/// Just like vim_iswordc_buf() but uses a pointer to the (multi-byte)
|
||||||
@ -882,10 +879,12 @@ bool vim_iswordp(char_u *p)
|
|||||||
bool vim_iswordp_buf(char_u *p, buf_T *buf)
|
bool vim_iswordp_buf(char_u *p, buf_T *buf)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (MB_BYTE2LEN(*p) > 1) {
|
int c = *p;
|
||||||
return mb_get_class(p) >= 2;
|
|
||||||
|
if (MB_BYTE2LEN(c) > 1) {
|
||||||
|
c = utf_ptr2char(p);
|
||||||
}
|
}
|
||||||
return GET_CHARTAB(buf, *p) != 0;
|
return vim_iswordc_buf(c, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check that "c" is a valid file-name character.
|
/// Check that "c" is a valid file-name character.
|
||||||
|
@ -428,7 +428,7 @@ int mb_get_class_tab(const char_u *p, const uint64_t *const chartab)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return utf_class(utf_ptr2char(p));
|
return utf_class_tab(utf_ptr2char(p), chartab);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1039,7 +1039,12 @@ bool utf_printable(int c)
|
|||||||
* 1: punctuation
|
* 1: punctuation
|
||||||
* 2 or bigger: some class of word character.
|
* 2 or bigger: some class of word character.
|
||||||
*/
|
*/
|
||||||
int utf_class(int c)
|
int utf_class(const int c)
|
||||||
|
{
|
||||||
|
return utf_class_tab(c, curbuf->b_chartab);
|
||||||
|
}
|
||||||
|
|
||||||
|
int utf_class_tab(const int c, const uint64_t *const chartab)
|
||||||
{
|
{
|
||||||
/* sorted list of non-overlapping intervals */
|
/* sorted list of non-overlapping intervals */
|
||||||
static struct clinterval {
|
static struct clinterval {
|
||||||
@ -1122,11 +1127,13 @@ int utf_class(int c)
|
|||||||
|
|
||||||
/* First quick check for Latin1 characters, use 'iskeyword'. */
|
/* First quick check for Latin1 characters, use 'iskeyword'. */
|
||||||
if (c < 0x100) {
|
if (c < 0x100) {
|
||||||
if (c == ' ' || c == '\t' || c == NUL || c == 0xa0)
|
if (c == ' ' || c == '\t' || c == NUL || c == 0xa0) {
|
||||||
return 0; /* blank */
|
return 0; // blank
|
||||||
if (vim_iswordc(c))
|
}
|
||||||
return 2; /* word character */
|
if (vim_iswordc_tab(c, chartab)) {
|
||||||
return 1; /* punctuation */
|
return 2; // word character
|
||||||
|
}
|
||||||
|
return 1; // punctuation
|
||||||
}
|
}
|
||||||
|
|
||||||
/* binary search in table */
|
/* binary search in table */
|
||||||
|
Loading…
Reference in New Issue
Block a user