summaryrefslogtreecommitdiff
path: root/src/time.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-07-15 12:49:58 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-15 12:49:58 +0200
commit1a71d31bf34b0b2b08517903826004ec6fd440e5 (patch)
tree05f54a00199737fe81fdf49e9ea72c09dba483d9 /src/time.c
parentc816a2c22667108fcd61f445de2c926f78ff9fa7 (diff)
downloadvim-git-1a71d31bf34b0b2b08517903826004ec6fd440e5.tar.gz
patch 8.2.3162: Vim9: argument types are not checked at compile timev8.2.3162
Problem: Vim9: argument types are not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes #8560)
Diffstat (limited to 'src/time.c')
-rw-r--r--src/time.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/time.c b/src/time.c
index 02c5da9dd..796fc58c9 100644
--- a/src/time.c
+++ b/src/time.c
@@ -169,6 +169,10 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
# ifdef FEAT_RELTIME
proftime_T res;
proftime_T start;
+ long n1, n2;
+
+ if (rettv_list_alloc(rettv) != OK)
+ return;
if (argvars[0].v_type == VAR_UNKNOWN)
{
@@ -198,20 +202,15 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
profile_sub(&res, &start);
}
- if (rettv_list_alloc(rettv) == OK)
- {
- long n1, n2;
-
# ifdef MSWIN
- n1 = res.HighPart;
- n2 = res.LowPart;
+ n1 = res.HighPart;
+ n2 = res.LowPart;
# else
- n1 = res.tv_sec;
- n2 = res.tv_usec;
+ n1 = res.tv_sec;
+ n2 = res.tv_usec;
# endif
- list_append_number(rettv->vval.v_list, (varnumber_T)n1);
- list_append_number(rettv->vval.v_list, (varnumber_T)n2);
- }
+ list_append_number(rettv->vval.v_list, (varnumber_T)n1);
+ list_append_number(rettv->vval.v_list, (varnumber_T)n2);
# endif
}
@@ -269,6 +268,12 @@ f_strftime(typval_T *argvars, typval_T *rettv)
time_t seconds;
char_u *p;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || (argvars[1].v_type != VAR_UNKNOWN
+ && check_for_number_arg(argvars, 1) == FAIL)))
+ return;
+
rettv->v_type = VAR_STRING;
p = tv_get_string(&argvars[0]);