mirror of
https://github.com/neovim/neovim.git
synced 2025-09-10 21:38:19 +00:00
vim-patch:8.1.0755: error message for get() on a Blob with invalid index
Problem: Error message for get() on a Blob with invalid index.
Solution: Return an empty Blob, like get() on a List does.
2ea773b468
This commit is contained in:
@@ -2809,14 +2809,18 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
if (argvars[0].v_type == VAR_BLOB) {
|
||||
bool error = false;
|
||||
const int idx = tv_get_number_chk(&argvars[1], &error);
|
||||
int idx = tv_get_number_chk(&argvars[1], &error);
|
||||
|
||||
if (!error) {
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
if (idx >= tv_blob_len(argvars[0].vval.v_blob)) {
|
||||
EMSGN(_(e_blobidx), idx);
|
||||
if (idx < 0) {
|
||||
idx = tv_blob_len(argvars[0].vval.v_blob) + idx;
|
||||
}
|
||||
if (idx < 0 || idx >= tv_blob_len(argvars[0].vval.v_blob)) {
|
||||
rettv->vval.v_number = -1;
|
||||
} else {
|
||||
rettv->vval.v_number = tv_blob_get(argvars[0].vval.v_blob, idx);
|
||||
tv = rettv;
|
||||
}
|
||||
}
|
||||
} else if (argvars[0].v_type == VAR_LIST) {
|
||||
|
Reference in New Issue
Block a user