aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-24 14:36:20 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-02-28 13:28:24 +0800
commitadfa55ba99febaa1eb5ebe1800ec5f94c4b4b664 (patch)
tree3a9bf2c894e1a0924aee1dc39f19cb01fdd31366 /src/nvim/eval/typval.c
parent9a271f6afd7a9b1c17d694b57ee1f489496000aa (diff)
downloadrneovim-adfa55ba99febaa1eb5ebe1800ec5f94c4b4b664.tar.gz
rneovim-adfa55ba99febaa1eb5ebe1800ec5f94c4b4b664.tar.bz2
rneovim-adfa55ba99febaa1eb5ebe1800ec5f94c4b4b664.zip
vim-patch:8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Problem: Vim9: blob tests for legacy and Vim9 script are separate. Solution: Add CheckLegacyAndVim9Success(). Make blob index assign work. https://github.com/vim/vim/commit/68452177ca4cda4a9d5f93892e437447cf9404c8 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r--src/nvim/eval/typval.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 0a30cdb62e..476faafb77 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -2710,6 +2710,22 @@ bool tv_blob_equal(const blob_T *const b1, const blob_T *const b2)
return true;
}
+/// Set bytes "n1" to "n2" (inclusive) in "dest" to the value of "src".
+/// Caller must make sure "src" is a blob.
+/// Returns FAIL if the number of bytes does not match.
+int tv_blob_set_range(blob_T *dest, long n1, long n2, typval_T *src)
+{
+ if (n2 - n1 + 1 != tv_blob_len(src->vval.v_blob)) {
+ emsg(_("E972: Blob value does not have the right number of bytes"));
+ return FAIL;
+ }
+
+ for (int il = (int)n1, ir = 0; il <= (int)n2; il++) {
+ tv_blob_set(dest, il, tv_blob_get(src->vval.v_blob, ir++));
+ }
+ return OK;
+}
+
/// "remove({blob})" function
void tv_blob_remove(typval_T *argvars, typval_T *rettv, const char *arg_errmsg)
{