From e88961943b85434ceebff6a31089c635ac39cd66 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 1 Aug 2021 18:27:41 +0100 Subject: fix(eval): partially port v8.2.3284 These were issues that I found while porting that I fixed upstream. :^) Very little of the patch can be exactly ported as we're a bit behind on dependant patches (we also can't use the exact :for emsg, as we don't support iterating over Strings yet), so just translate the fixes as best as we can for now. Include latest relevant doc changes from: - v8.1.0815 - v8.2.2658 --- src/nvim/eval/funcs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 660c069e7f..ec13aa7fbd 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4984,12 +4984,16 @@ static void f_insert(typval_T *argvars, typval_T *rettv, FunPtr fptr) bool error = false; if (argvars[0].v_type == VAR_BLOB) { - if (argvars[0].vval.v_blob == NULL) { + blob_T *const b = argvars[0].vval.v_blob; + + if (b == NULL + || var_check_lock(b->bv_lock, N_("insert() argument"), + TV_TRANSLATE)) { return; } long before = 0; - const int len = tv_blob_len(argvars[0].vval.v_blob); + const int len = tv_blob_len(b); if (argvars[2].v_type != VAR_UNKNOWN) { before = (long)tv_get_number_chk(&argvars[2], &error); @@ -5010,11 +5014,11 @@ static void f_insert(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - ga_grow(&argvars[0].vval.v_blob->bv_ga, 1); - char_u *const p = (char_u *)argvars[0].vval.v_blob->bv_ga.ga_data; + ga_grow(&b->bv_ga, 1); + char_u *const p = (char_u *)b->bv_ga.ga_data; memmove(p + before + 1, p + before, (size_t)len - before); *(p + before) = val; - argvars[0].vval.v_blob->bv_ga.ga_len++; + b->bv_ga.ga_len++; tv_copy(&argvars[0], rettv); } else if (argvars[0].v_type != VAR_LIST) { @@ -7312,11 +7316,16 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } } else if (argvars[0].v_type == VAR_BLOB) { + blob_T *const b = argvars[0].vval.v_blob; + + if (b != NULL && var_check_lock(b->bv_lock, arg_errmsg, TV_TRANSLATE)) { + return; + } + bool error = false; idx = (long)tv_get_number_chk(&argvars[1], &error); if (!error) { - blob_T *const b = argvars[0].vval.v_blob; const int len = tv_blob_len(b); if (idx < 0) { -- cgit