Mercurial > vim
comparison src/terminal.c @ 25272:712e867f9721 v8.2.3173
patch 8.2.3173: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/a9a7c0c602b231dc37c4b0f62ade0421c84fca03
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Jul 17 19:11:07 2021 +0200
patch 8.2.3173: 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/8581)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 17 Jul 2021 19:15:05 +0200 |
parents | acda780ffc3e |
children | 4d3c68196d05 |
comparison
equal
deleted
inserted
replaced
25271:51a7e859b0de | 25272:712e867f9721 |
---|---|
6091 * "term_sendkeys(buf, keys)" function | 6091 * "term_sendkeys(buf, keys)" function |
6092 */ | 6092 */ |
6093 void | 6093 void |
6094 f_term_sendkeys(typval_T *argvars, typval_T *rettv UNUSED) | 6094 f_term_sendkeys(typval_T *argvars, typval_T *rettv UNUSED) |
6095 { | 6095 { |
6096 buf_T *buf = term_get_buf(argvars, "term_sendkeys()"); | 6096 buf_T *buf; |
6097 char_u *msg; | 6097 char_u *msg; |
6098 term_T *term; | 6098 term_T *term; |
6099 | 6099 |
6100 if (in_vim9script() | |
6101 && ((argvars[0].v_type != VAR_STRING | |
6102 && argvars[0].v_type != VAR_NUMBER | |
6103 && check_for_string_arg(argvars, 0) == FAIL) | |
6104 || check_for_string_arg(argvars, 1) == FAIL)) | |
6105 return; | |
6106 | |
6107 buf = term_get_buf(argvars, "term_sendkeys()"); | |
6100 if (buf == NULL) | 6108 if (buf == NULL) |
6101 return; | 6109 return; |
6102 | 6110 |
6103 msg = tv_get_string_chk(&argvars[1]); | 6111 msg = tv_get_string_chk(&argvars[1]); |
6104 if (msg == NULL) | 6112 if (msg == NULL) |
6191 * "term_setapi(buf, api)" function | 6199 * "term_setapi(buf, api)" function |
6192 */ | 6200 */ |
6193 void | 6201 void |
6194 f_term_setapi(typval_T *argvars, typval_T *rettv UNUSED) | 6202 f_term_setapi(typval_T *argvars, typval_T *rettv UNUSED) |
6195 { | 6203 { |
6196 buf_T *buf = term_get_buf(argvars, "term_setapi()"); | 6204 buf_T *buf; |
6197 term_T *term; | 6205 term_T *term; |
6198 char_u *api; | 6206 char_u *api; |
6199 | 6207 |
6208 if (in_vim9script() | |
6209 && ((argvars[0].v_type != VAR_STRING | |
6210 && argvars[0].v_type != VAR_NUMBER | |
6211 && check_for_string_arg(argvars, 0) == FAIL) | |
6212 || check_for_string_arg(argvars, 1) == FAIL)) | |
6213 return; | |
6214 | |
6215 buf = term_get_buf(argvars, "term_setapi()"); | |
6200 if (buf == NULL) | 6216 if (buf == NULL) |
6201 return; | 6217 return; |
6202 term = buf->b_term; | 6218 term = buf->b_term; |
6203 vim_free(term->tl_api); | 6219 vim_free(term->tl_api); |
6204 api = tv_get_string_chk(&argvars[1]); | 6220 api = tv_get_string_chk(&argvars[1]); |
6213 */ | 6229 */ |
6214 void | 6230 void |
6215 f_term_setrestore(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | 6231 f_term_setrestore(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
6216 { | 6232 { |
6217 #if defined(FEAT_SESSION) | 6233 #if defined(FEAT_SESSION) |
6218 buf_T *buf = term_get_buf(argvars, "term_setrestore()"); | 6234 buf_T *buf; |
6219 term_T *term; | 6235 term_T *term; |
6220 char_u *cmd; | 6236 char_u *cmd; |
6221 | 6237 |
6238 if (in_vim9script() | |
6239 && ((argvars[0].v_type != VAR_STRING | |
6240 && argvars[0].v_type != VAR_NUMBER | |
6241 && check_for_string_arg(argvars, 0) == FAIL) | |
6242 || check_for_string_arg(argvars, 1) == FAIL)) | |
6243 return; | |
6244 | |
6245 buf = term_get_buf(argvars, "term_setrestore()"); | |
6222 if (buf == NULL) | 6246 if (buf == NULL) |
6223 return; | 6247 return; |
6224 term = buf->b_term; | 6248 term = buf->b_term; |
6225 vim_free(term->tl_command); | 6249 vim_free(term->tl_command); |
6226 cmd = tv_get_string_chk(&argvars[1]); | 6250 cmd = tv_get_string_chk(&argvars[1]); |
6235 * "term_setkill(buf, how)" function | 6259 * "term_setkill(buf, how)" function |
6236 */ | 6260 */ |
6237 void | 6261 void |
6238 f_term_setkill(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | 6262 f_term_setkill(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
6239 { | 6263 { |
6240 buf_T *buf = term_get_buf(argvars, "term_setkill()"); | 6264 buf_T *buf; |
6241 term_T *term; | 6265 term_T *term; |
6242 char_u *how; | 6266 char_u *how; |
6243 | 6267 |
6268 if (in_vim9script() | |
6269 && ((argvars[0].v_type != VAR_STRING | |
6270 && argvars[0].v_type != VAR_NUMBER | |
6271 && check_for_string_arg(argvars, 0) == FAIL) | |
6272 || check_for_string_arg(argvars, 1) == FAIL)) | |
6273 return; | |
6274 | |
6275 buf = term_get_buf(argvars, "term_setkill()"); | |
6244 if (buf == NULL) | 6276 if (buf == NULL) |
6245 return; | 6277 return; |
6246 term = buf->b_term; | 6278 term = buf->b_term; |
6247 vim_free(term->tl_kill); | 6279 vim_free(term->tl_kill); |
6248 how = tv_get_string_chk(&argvars[1]); | 6280 how = tv_get_string_chk(&argvars[1]); |
6284 * "term_wait" function | 6316 * "term_wait" function |
6285 */ | 6317 */ |
6286 void | 6318 void |
6287 f_term_wait(typval_T *argvars, typval_T *rettv UNUSED) | 6319 f_term_wait(typval_T *argvars, typval_T *rettv UNUSED) |
6288 { | 6320 { |
6289 buf_T *buf = term_get_buf(argvars, "term_wait()"); | 6321 buf_T *buf; |
6290 | 6322 |
6323 if (in_vim9script() | |
6324 && ((argvars[0].v_type != VAR_STRING | |
6325 && argvars[0].v_type != VAR_NUMBER | |
6326 && check_for_string_arg(argvars, 0) == FAIL) || | |
6327 (argvars[1].v_type != VAR_UNKNOWN | |
6328 && check_for_number_arg(argvars, 1) == FAIL))) | |
6329 return; | |
6330 | |
6331 buf = term_get_buf(argvars, "term_wait()"); | |
6291 if (buf == NULL) | 6332 if (buf == NULL) |
6292 return; | 6333 return; |
6293 if (buf->b_term->tl_job == NULL) | 6334 if (buf->b_term->tl_job == NULL) |
6294 { | 6335 { |
6295 ch_log(NULL, "term_wait(): no job to wait for"); | 6336 ch_log(NULL, "term_wait(): no job to wait for"); |