mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2343: Vim9: return type of readfile() is any
Problem: Vim9: return type of readfile() is any. Solution: Add readblob() so that readfile() can be expected to always return a list of strings. (closes #7671)
This commit is contained in:
@@ -1640,11 +1640,11 @@ f_readdirex(typval_T *argvars, typval_T *rettv)
|
||||
/*
|
||||
* "readfile()" function
|
||||
*/
|
||||
void
|
||||
f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
static void
|
||||
read_file_or_blob(typval_T *argvars, typval_T *rettv, int always_blob)
|
||||
{
|
||||
int binary = FALSE;
|
||||
int blob = FALSE;
|
||||
int blob = always_blob;
|
||||
int failed = FALSE;
|
||||
char_u *fname;
|
||||
FILE *fd;
|
||||
@@ -1796,7 +1796,8 @@ f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (dest < buf)
|
||||
{
|
||||
adjust_prevlen = (int)(buf - dest); // must be 1 or 2
|
||||
// must be 1 or 2
|
||||
adjust_prevlen = (int)(buf - dest);
|
||||
dest = buf;
|
||||
}
|
||||
if (readlen > p - buf + 1)
|
||||
@@ -1866,6 +1867,24 @@ f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* "readblob()" function
|
||||
*/
|
||||
void
|
||||
f_readblob(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
read_file_or_blob(argvars, rettv, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* "readfile()" function
|
||||
*/
|
||||
void
|
||||
f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
read_file_or_blob(argvars, rettv, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* "resolve()" function
|
||||
*/
|
||||
|
Reference in New Issue
Block a user