summaryrefslogtreecommitdiffstats
path: root/src/filepath.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-07-20 17:51:51 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-20 17:51:51 +0200
commit83494b4ac61898f687d6ef9dce4bad5802fb8e51 (patch)
tree36f06f4a70bd9a515527064cd8985029ab27c6a6 /src/filepath.c
parent9bb0dad0d8283c86fddf5b950f4fbb6fb8f12741 (diff)
patch 8.2.3188: Vim9: argument types are not checked at compile timev8.2.3188
Problem: Vim9: argument types are not checked at compile time. Solution: Add several more type checks, also at runtime. (Yegappan Lakshmanan, closes #8587)
Diffstat (limited to 'src/filepath.c')
-rw-r--r--src/filepath.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/filepath.c b/src/filepath.c
index 40b5761aee..0d59a6b4f8 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -1254,6 +1254,15 @@ f_glob(typval_T *argvars, typval_T *rettv)
expand_T xpc;
int error = FALSE;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_opt_bool_arg(argvars, 1) == FAIL
+ || (argvars[1].v_type != VAR_UNKNOWN
+ && (check_for_opt_bool_arg(argvars, 2) == FAIL
+ || (argvars[2].v_type != VAR_UNKNOWN
+ && check_for_opt_bool_arg(argvars, 3) == FAIL)))))
+ return;
+
// When the optional second argument is non-zero, don't remove matches
// for 'wildignore' and don't put matches for 'suffixes' at the end.
rettv->v_type = VAR_STRING;
@@ -1318,11 +1327,23 @@ f_globpath(typval_T *argvars, typval_T *rettv)
{
int flags = WILD_IGNORE_COMPLETESLASH;
char_u buf1[NUMBUFLEN];
- char_u *file = tv_get_string_buf_chk(&argvars[1], buf1);
+ char_u *file;
int error = FALSE;
garray_T ga;
int i;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_string_arg(argvars, 1) == FAIL
+ || check_for_opt_bool_arg(argvars, 2) == FAIL
+ || (argvars[2].v_type != VAR_UNKNOWN
+ && (check_for_opt_bool_arg(argvars, 3) == FAIL
+ || (argvars[3].v_type != VAR_UNKNOWN
+ && check_for_opt_bool_arg(argvars, 4) == FAIL)))))
+ return;
+
+ file = tv_get_string_buf_chk(&argvars[1], buf1);
+
// When the optional second argument is non-zero, don't remove matches
// for 'wildignore' and don't put matches for 'suffixes' at the end.
rettv->v_type = VAR_STRING;
@@ -1449,8 +1470,7 @@ f_pathshorten(typval_T *argvars, typval_T *rettv)
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
- || (argvars[1].v_type != VAR_UNKNOWN
- && check_for_number_arg(argvars, 1) == FAIL)))
+ || check_for_opt_number_arg(argvars, 1) == FAIL))
return;
if (argvars[1].v_type != VAR_UNKNOWN)
@@ -2423,10 +2443,12 @@ f_browse(typval_T *argvars UNUSED, typval_T *rettv)
int error = FALSE;
if (in_vim9script()
- && (check_for_string_arg(argvars, 1) == FAIL
+ && (check_for_bool_arg(argvars, 0) == FAIL
+ || check_for_string_arg(argvars, 1) == FAIL
|| check_for_string_arg(argvars, 2) == FAIL
|| check_for_string_arg(argvars, 3) == FAIL))
return;
+
save = (int)tv_get_number_chk(&argvars[0], &error);
title = tv_get_string_chk(&argvars[1]);
initdir = tv_get_string_buf_chk(&argvars[2], buf);