mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
fix(eval): checking for a non-empty string is too strict (#15987)
Cherry-pick check_for_nonempty_string() from patch vim-8.2.2133 and
apply it on the bases of https://github.com/neovim/neovim/pull/13489
2a9d5d386b
This commit is contained in:
@@ -3146,19 +3146,31 @@ float_T tv_get_float(const typval_T *const tv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Give an error and return FAIL unless "tv" is a non-empty string.
|
||||
// Give an error and return FAIL unless "tv" is a string.
|
||||
int tv_check_for_string(const typval_T *const tv)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||
{
|
||||
if (tv->v_type != VAR_STRING
|
||||
|| tv->vval.v_string == NULL
|
||||
|| *tv->vval.v_string == NUL) {
|
||||
if (tv->v_type != VAR_STRING) {
|
||||
EMSG(_(e_stringreq));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
// Give an error and return FAIL unless "tv" is a non-empty string.
|
||||
int tv_check_for_nonempty_string(const typval_T *const tv)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||
{
|
||||
if (tv_check_for_string(tv) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (tv->vval.v_string == NULL || *tv->vval.v_string == NUL) {
|
||||
EMSG(_(e_non_empty_string_required));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/// Get the string value of a "stringish" VimL object.
|
||||
///
|
||||
/// @param[in] tv Object to get value of.
|
||||
|
Reference in New Issue
Block a user