summaryrefslogtreecommitdiff
path: root/src/typval.c
diff options
context:
space:
mode:
authorrbtnn <naru123456789@gmail.com>2021-12-18 18:33:46 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-18 18:33:46 +0000
commit0ccb5842f5fb103763d106c7aa364d758343c35a (patch)
tree76ea36f2abf5035e3695132e0cc5b59e2e9a325c /src/typval.c
parent605ec91e5a7330d61be313637e495fa02a6dc264 (diff)
downloadvim-git-0ccb5842f5fb103763d106c7aa364d758343c35a.tar.gz
patch 8.2.3848: cannot use reduce() for a stringv8.2.3848
Problem: Cannot use reduce() for a string. Solution: Make reduce() work with a string. (Naruhiko Nishino, closes #9366)
Diffstat (limited to 'src/typval.c')
-rw-r--r--src/typval.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/typval.c b/src/typval.c
index 09381f279..7716873bb 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -663,6 +663,23 @@ check_for_string_or_list_arg(typval_T *args, int idx)
}
/*
+ * Give an error and return FAIL unless "args[idx]" is a string, a list or a
+ * blob.
+ */
+ int
+check_for_string_or_list_or_blob_arg(typval_T *args, int idx)
+{
+ if (args[idx].v_type != VAR_STRING
+ && args[idx].v_type != VAR_LIST
+ && args[idx].v_type != VAR_BLOB)
+ {
+ semsg(_(e_string_list_or_blob_required_for_argument_nr), idx + 1);
+ return FAIL;
+ }
+ return OK;
+}
+
+/*
* Check for an optional string or list argument at 'idx'
*/
int
@@ -697,10 +714,7 @@ check_for_string_or_number_or_list_arg(typval_T *args, int idx)
&& args[idx].v_type != VAR_NUMBER
&& args[idx].v_type != VAR_LIST)
{
- if (idx >= 0)
- semsg(_(e_string_number_or_list_required_for_argument_nr), idx + 1);
- else
- emsg(_(e_stringreq));
+ semsg(_(e_string_number_or_list_required_for_argument_nr), idx + 1);
return FAIL;
}
return OK;
@@ -742,10 +756,7 @@ check_for_list_or_blob_arg(typval_T *args, int idx)
{
if (args[idx].v_type != VAR_LIST && args[idx].v_type != VAR_BLOB)
{
- if (idx >= 0)
- semsg(_(e_list_or_blob_required_for_argument_nr), idx + 1);
- else
- emsg(_(e_listreq));
+ semsg(_(e_list_or_blob_required_for_argument_nr), idx + 1);
return FAIL;
}
return OK;