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)
diff --git a/src/filepath.c b/src/filepath.c
index 0db0dcf..81fe749 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -1640,11 +1640,11 @@
/*
* "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 @@
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)
@@ -1867,6 +1868,24 @@
}
/*
+ * "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
*/
void