forked from aniani/vim
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Problem: Vim9: checking for a non-empty string is too strict. Solution: Check for any string. (closes #7447)
This commit is contained in:
22
src/typval.c
22
src/typval.c
@@ -341,14 +341,12 @@ tv_get_float(typval_T *varp)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
check_for_string(typval_T *tv)
|
||||
{
|
||||
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;
|
||||
@@ -356,6 +354,22 @@ check_for_string(typval_T *tv)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "tv" is a non-empty string.
|
||||
*/
|
||||
int
|
||||
check_for_nonempty_string(typval_T *tv)
|
||||
{
|
||||
if (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 variable.
|
||||
* If it is a Number variable, the number is converted into a string.
|
||||
|
Reference in New Issue
Block a user