comparison src/time.c @ 25252:acda780ffc3e v8.2.3162

patch 8.2.3162: Vim9: argument types are not checked at compile time Commit: https://github.com/vim/vim/commit/1a71d31bf34b0b2b08517903826004ec6fd440e5 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Jul 15 12:49:58 2021 +0200 patch 8.2.3162: Vim9: argument types are not checked at compile time Problem: Vim9: argument types are not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8560)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Jul 2021 13:00:06 +0200
parents 532faf893d37
children 4d3c68196d05
comparison
equal deleted inserted replaced
25251:6024f64e0d2b 25252:acda780ffc3e
167 f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED) 167 f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
168 { 168 {
169 # ifdef FEAT_RELTIME 169 # ifdef FEAT_RELTIME
170 proftime_T res; 170 proftime_T res;
171 proftime_T start; 171 proftime_T start;
172 long n1, n2;
173
174 if (rettv_list_alloc(rettv) != OK)
175 return;
172 176
173 if (argvars[0].v_type == VAR_UNKNOWN) 177 if (argvars[0].v_type == VAR_UNKNOWN)
174 { 178 {
175 // No arguments: get current time. 179 // No arguments: get current time.
176 profile_start(&res); 180 profile_start(&res);
196 return; 200 return;
197 } 201 }
198 profile_sub(&res, &start); 202 profile_sub(&res, &start);
199 } 203 }
200 204
201 if (rettv_list_alloc(rettv) == OK)
202 {
203 long n1, n2;
204
205 # ifdef MSWIN 205 # ifdef MSWIN
206 n1 = res.HighPart; 206 n1 = res.HighPart;
207 n2 = res.LowPart; 207 n2 = res.LowPart;
208 # else 208 # else
209 n1 = res.tv_sec; 209 n1 = res.tv_sec;
210 n2 = res.tv_usec; 210 n2 = res.tv_usec;
211 # endif 211 # endif
212 list_append_number(rettv->vval.v_list, (varnumber_T)n1); 212 list_append_number(rettv->vval.v_list, (varnumber_T)n1);
213 list_append_number(rettv->vval.v_list, (varnumber_T)n2); 213 list_append_number(rettv->vval.v_list, (varnumber_T)n2);
214 }
215 # endif 214 # endif
216 } 215 }
217 216
218 # ifdef FEAT_FLOAT 217 # ifdef FEAT_FLOAT
219 /* 218 /*
266 { 265 {
267 struct tm tmval; 266 struct tm tmval;
268 struct tm *curtime; 267 struct tm *curtime;
269 time_t seconds; 268 time_t seconds;
270 char_u *p; 269 char_u *p;
270
271 if (in_vim9script()
272 && (check_for_string_arg(argvars, 0) == FAIL
273 || (argvars[1].v_type != VAR_UNKNOWN
274 && check_for_number_arg(argvars, 1) == FAIL)))
275 return;
271 276
272 rettv->v_type = VAR_STRING; 277 rettv->v_type = VAR_STRING;
273 278
274 p = tv_get_string(&argvars[0]); 279 p = tv_get_string(&argvars[0]);
275 if (argvars[1].v_type == VAR_UNKNOWN) 280 if (argvars[1].v_type == VAR_UNKNOWN)