1
0
forked from aniani/vim

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:
Bram Moolenaar
2021-01-13 20:38:03 +01:00
parent 9145846b6a
commit c423ad77ed
7 changed files with 74 additions and 10 deletions

View File

@@ -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
*/