diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-01 18:27:41 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-09-16 00:14:46 +0100 |
commit | e88961943b85434ceebff6a31089c635ac39cd66 (patch) | |
tree | 715ec2acac329e04e5b1a265c63e2e0a960c4341 /src/nvim/eval/funcs.c | |
parent | 3d6bb8b3fbe21d8a7a4ba975682eb9a4e5170859 (diff) | |
download | rneovim-e88961943b85434ceebff6a31089c635ac39cd66.tar.gz rneovim-e88961943b85434ceebff6a31089c635ac39cd66.tar.bz2 rneovim-e88961943b85434ceebff6a31089c635ac39cd66.zip |
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
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 21 |
1 files changed, 15 insertions, 6 deletions
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) { |