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)
diff --git a/src/typval.c b/src/typval.c
index 64112e7..affd668 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -341,14 +341,12 @@
#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;
@@ -357,6 +355,22 @@
}
/*
+ * 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.
* tv_get_string() uses a single, static buffer. YOU CAN ONLY USE IT ONCE!