summaryrefslogtreecommitdiffstats
path: root/src/blob.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-12 21:21:02 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-12 21:21:02 +0200
commit68452177ca4cda4a9d5f93892e437447cf9404c8 (patch)
tree67db842620f7929316586ef2883977864402bc70 /src/blob.c
parentcfc3023cb6ce5aaec13f49bc4b821feb05e3fb03 (diff)
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separatev8.2.2757
Problem: Vim9: blob tests for legacy and Vim9 script are separate. Solution: Add CheckLegacyAndVim9Success(). Make blob index assign work.
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/blob.c b/src/blob.c
index 8d260f172b..d758beb19d 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -337,6 +337,28 @@ blob_slice_or_index(
}
/*
+ * 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
+blob_set_range(blob_T *dest, long n1, long n2, typval_T *src)
+{
+ int il, ir;
+
+ if (n2 - n1 + 1 != blob_len(src->vval.v_blob))
+ {
+ emsg(_("E972: Blob value does not have the right number of bytes"));
+ return FAIL;
+ }
+
+ ir = 0;
+ for (il = n1; il <= n2; il++)
+ blob_set(dest, il, blob_get(src->vval.v_blob, ir++));
+ return OK;
+}
+
+/*
* "remove({blob})" function
*/
void