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.

68452177ca

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-02-24 14:36:20 +08:00
parent 9a271f6afd
commit adfa55ba99
3 changed files with 83 additions and 65 deletions

View File

@@ -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)
{