aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-28 14:12:58 +0800
committerGitHub <noreply@github.com>2023-02-28 14:12:58 +0800
commitbefb47f2e11a3f1035e6825b6f9fa7574c37ed0e (patch)
treed78b2cc1f02d99828e092e0f27d5dbfce9136668 /src/nvim/eval.c
parent9a271f6afd7a9b1c17d694b57ee1f489496000aa (diff)
parent1f1227f12b69616484cc0f8b49d555df4a94678b (diff)
downloadrneovim-befb47f2e11a3f1035e6825b6f9fa7574c37ed0e.tar.gz
rneovim-befb47f2e11a3f1035e6825b6f9fa7574c37ed0e.tar.bz2
rneovim-befb47f2e11a3f1035e6825b6f9fa7574c37ed0e.zip
Merge pull request #22446 from zeertzjq/vim-8.2.2757
vim-patch:8.2.{2757,2765,2767}
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 841588d4c3..cce7b9a13c 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1498,21 +1498,14 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const
tv_clear(&var1);
const int bloblen = tv_blob_len(lp->ll_tv->vval.v_blob);
- if (lp->ll_n1 < 0 || lp->ll_n1 > bloblen
- || (lp->ll_range && lp->ll_n1 == bloblen)) {
- if (!quiet) {
- semsg(_(e_blobidx), (int64_t)lp->ll_n1);
- }
+ if (tv_blob_check_index(bloblen, lp->ll_n1, quiet) == FAIL) {
tv_clear(&var2);
return NULL;
}
if (lp->ll_range && !lp->ll_empty2) {
lp->ll_n2 = (long)tv_get_number(&var2);
tv_clear(&var2);
- if (lp->ll_n2 < 0 || lp->ll_n2 >= bloblen || lp->ll_n2 < lp->ll_n1) {
- if (!quiet) {
- semsg(_(e_blobidx), (int64_t)lp->ll_n2);
- }
+ if (tv_blob_check_range(bloblen, lp->ll_n1, lp->ll_n2, quiet) == FAIL) {
return NULL;
}
}
@@ -1620,17 +1613,9 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool
lp->ll_n2 = tv_blob_len(lp->ll_blob) - 1;
}
- if (lp->ll_n2 - lp->ll_n1 + 1 != tv_blob_len(rettv->vval.v_blob)) {
- emsg(_("E972: Blob value does not have the right number of bytes"));
+ if (tv_blob_set_range(lp->ll_blob, lp->ll_n1, lp->ll_n2, rettv) == FAIL) {
return;
}
- if (lp->ll_empty2) {
- lp->ll_n2 = tv_blob_len(lp->ll_blob);
- }
-
- for (int il = (int)lp->ll_n1, ir = 0; il <= (int)lp->ll_n2; il++) {
- tv_blob_set(lp->ll_blob, il, tv_blob_get(rettv->vval.v_blob, ir++));
- }
} else {
bool error = false;
const char val = (char)tv_get_number_chk(rettv, &error);