summaryrefslogtreecommitdiff
path: root/src/filepath.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-13 20:38:03 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-13 20:38:03 +0100
commitc423ad77ed763c11ba67729bbf63c1cf0915231f (patch)
treed50a83a06633e84412413b5b6c8fcbe58a4acf75 /src/filepath.c
parent9145846b6aa411e3ab5c0d145b37808654352877 (diff)
downloadvim-git-c423ad77ed763c11ba67729bbf63c1cf0915231f.tar.gz
patch 8.2.2343: Vim9: return type of readfile() is anyv8.2.2343
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)
Diffstat (limited to 'src/filepath.c')
-rw-r--r--src/filepath.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/filepath.c b/src/filepath.c
index 0db0dcfb1..81fe74924 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -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)
@@ -1867,6 +1868,24 @@ f_readfile(typval_T *argvars, typval_T *rettv)
}
/*
+ * "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