test: port kword_test to Lua for utf_char2bytes()

Use LuaJIT FFI to create char pointer.
Validate output with utf_ptr2char(), vim_iswordc() and vim_iswordp().
Use const for LuaJIT string-to-char conversion.
This commit is contained in:
Jan Edmund Lazo
2018-06-26 23:26:04 -04:00
parent 6ff892165a
commit 3e4a058b01
2 changed files with 14 additions and 4 deletions

View File

@@ -826,7 +826,7 @@ bool vim_isIDc(int c)
/// For multi-byte characters mb_get_class() is used (builtin rules).
///
/// @param c character to check
bool vim_iswordc(int c)
bool vim_iswordc(const int c)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return vim_iswordc_buf(c, curbuf);
@@ -852,7 +852,7 @@ bool vim_iswordc_tab(const int c, const uint64_t *const chartab)
///
/// @param c character to check
/// @param buf buffer whose keywords to use
bool vim_iswordc_buf(int c, buf_T *buf)
bool vim_iswordc_buf(const int c, buf_T *const buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(2)
{
return vim_iswordc_tab(c, buf->b_chartab);
@@ -863,7 +863,7 @@ bool vim_iswordc_buf(int c, buf_T *buf)
/// @param p pointer to the multi-byte character
///
/// @return true if "p" points to a keyword character.
bool vim_iswordp(char_u *p)
bool vim_iswordp(const char_u *const p)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
return vim_iswordp_buf(p, curbuf);
@@ -876,7 +876,7 @@ bool vim_iswordp(char_u *p)
/// @param buf buffer whose keywords to use
///
/// @return true if "p" points to a keyword character.
bool vim_iswordp_buf(char_u *p, buf_T *buf)
bool vim_iswordp_buf(const char_u *const p, buf_T *const buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
int c = *p;