mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
fix(eval): correct failure return value for readfile/blob (#27722)
Currently returns 0 on failure, but should return an empty list (or blob). Regressed in the big blob port of '21 (#15211).
This commit is contained in:
parent
3971797be1
commit
bf0c69e504
@ -6005,6 +6005,12 @@ static void read_file_or_blob(typval_T *argvars, typval_T *rettv, bool always_bl
|
||||
}
|
||||
}
|
||||
|
||||
if (blob) {
|
||||
tv_blob_alloc_ret(rettv);
|
||||
} else {
|
||||
tv_list_alloc_ret(rettv, kListLenUnknown);
|
||||
}
|
||||
|
||||
// Always open the file in binary mode, library functions have a mind of
|
||||
// their own about CR-LF conversion.
|
||||
const char *const fname = tv_get_string(&argvars[0]);
|
||||
@ -6019,7 +6025,6 @@ static void read_file_or_blob(typval_T *argvars, typval_T *rettv, bool always_bl
|
||||
}
|
||||
|
||||
if (blob) {
|
||||
tv_blob_alloc_ret(rettv);
|
||||
if (read_blob(fd, rettv, offset, size) == FAIL) {
|
||||
semsg(_(e_notread), fname);
|
||||
}
|
||||
@ -6027,7 +6032,7 @@ static void read_file_or_blob(typval_T *argvars, typval_T *rettv, bool always_bl
|
||||
return;
|
||||
}
|
||||
|
||||
list_T *const l = tv_list_alloc_ret(rettv, kListLenUnknown);
|
||||
list_T *const l = rettv->vval.v_list;
|
||||
|
||||
while (maxline < 0 || tv_list_len(l) < maxline) {
|
||||
int readlen = (int)fread(buf, 1, (size_t)io_size, fd);
|
||||
|
Loading…
Reference in New Issue
Block a user