summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-13 19:10:33 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-13 19:10:33 +0100
commit05500ece6282407f9f7227aaf564e24147326863 (patch)
treee7a2edc95b8ffc7e50fb542f7447ed7030e03570 /src/evalfunc.c
parent8c8b8bb56c724cc1bfc3d8520eec33f2d399697c (diff)
patch 8.1.0742: not all Blob operations are testedv8.1.0742
Problem: Not all Blob operations are tested. Solution: Add more testing for Blob.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index c1c8c23bd5..066716a913 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1258,8 +1258,14 @@ f_add(typval_T *argvars, typval_T *rettv)
&& !tv_check_lock(b->bv_lock,
(char_u *)N_("add() argument"), TRUE))
{
- ga_append(&b->bv_ga, (char_u)tv_get_number(&argvars[1]));
- copy_tv(&argvars[0], rettv);
+ int error = FALSE;
+ varnumber_T n = tv_get_number_chk(&argvars[1], &error);
+
+ if (!error)
+ {
+ ga_append(&b->bv_ga, (int)n);
+ copy_tv(&argvars[0], rettv);
+ }
}
}
else
@@ -3196,7 +3202,6 @@ f_empty(typval_T *argvars, typval_T *rettv)
case VAR_BLOB:
n = argvars[0].vval.v_blob == NULL
- || argvars[0].vval.v_blob->bv_ga.ga_data == NULL
|| argvars[0].vval.v_blob->bv_ga.ga_len == 0;
break;
@@ -7029,6 +7034,13 @@ f_index(typval_T *argvars, typval_T *rettv)
b = argvars[0].vval.v_blob;
if (b == NULL)
return;
+ if (start < 0)
+ {
+ start = blob_len(b) + start;
+ if (start < 0)
+ start = 0;
+ }
+
for (idx = start; idx < blob_len(b); ++idx)
{
tv.v_type = VAR_NUMBER;