diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-07-17 19:11:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-17 19:11:07 +0200 |
commit | a9a7c0c602b231dc37c4b0f62ade0421c84fca03 (patch) | |
tree | a7e6e2dcad98c9dd2244cf9c368360b71abf61a6 /src/terminal.c | |
parent | 20c370d9f2ee89cb854054edf71f5004f6efff77 (diff) | |
download | vim-git-a9a7c0c602b231dc37c4b0f62ade0421c84fca03.tar.gz |
patch 8.2.3173: Vim9: argument types are not checked at compile timev8.2.3173
Problem: Vim9: argument types are not checked at compile time.
Solution: Add more type checks. (Yegappan Lakshmanan, closes #8581)
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/terminal.c b/src/terminal.c index 9db04756d..52645643b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -6093,10 +6093,18 @@ f_term_scrape(typval_T *argvars, typval_T *rettv) void f_term_sendkeys(typval_T *argvars, typval_T *rettv UNUSED) { - buf_T *buf = term_get_buf(argvars, "term_sendkeys()"); + buf_T *buf; char_u *msg; term_T *term; + if (in_vim9script() + && ((argvars[0].v_type != VAR_STRING + && argvars[0].v_type != VAR_NUMBER + && check_for_string_arg(argvars, 0) == FAIL) + || check_for_string_arg(argvars, 1) == FAIL)) + return; + + buf = term_get_buf(argvars, "term_sendkeys()"); if (buf == NULL) return; @@ -6193,10 +6201,18 @@ f_term_setansicolors(typval_T *argvars, typval_T *rettv UNUSED) void f_term_setapi(typval_T *argvars, typval_T *rettv UNUSED) { - buf_T *buf = term_get_buf(argvars, "term_setapi()"); + buf_T *buf; term_T *term; char_u *api; + if (in_vim9script() + && ((argvars[0].v_type != VAR_STRING + && argvars[0].v_type != VAR_NUMBER + && check_for_string_arg(argvars, 0) == FAIL) + || check_for_string_arg(argvars, 1) == FAIL)) + return; + + buf = term_get_buf(argvars, "term_setapi()"); if (buf == NULL) return; term = buf->b_term; @@ -6215,10 +6231,18 @@ f_term_setapi(typval_T *argvars, typval_T *rettv UNUSED) f_term_setrestore(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { #if defined(FEAT_SESSION) - buf_T *buf = term_get_buf(argvars, "term_setrestore()"); + buf_T *buf; term_T *term; char_u *cmd; + if (in_vim9script() + && ((argvars[0].v_type != VAR_STRING + && argvars[0].v_type != VAR_NUMBER + && check_for_string_arg(argvars, 0) == FAIL) + || check_for_string_arg(argvars, 1) == FAIL)) + return; + + buf = term_get_buf(argvars, "term_setrestore()"); if (buf == NULL) return; term = buf->b_term; @@ -6237,10 +6261,18 @@ f_term_setrestore(typval_T *argvars UNUSED, typval_T *rettv UNUSED) void f_term_setkill(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { - buf_T *buf = term_get_buf(argvars, "term_setkill()"); + buf_T *buf; term_T *term; char_u *how; + if (in_vim9script() + && ((argvars[0].v_type != VAR_STRING + && argvars[0].v_type != VAR_NUMBER + && check_for_string_arg(argvars, 0) == FAIL) + || check_for_string_arg(argvars, 1) == FAIL)) + return; + + buf = term_get_buf(argvars, "term_setkill()"); if (buf == NULL) return; term = buf->b_term; @@ -6286,8 +6318,17 @@ f_term_start(typval_T *argvars, typval_T *rettv) void f_term_wait(typval_T *argvars, typval_T *rettv UNUSED) { - buf_T *buf = term_get_buf(argvars, "term_wait()"); + buf_T *buf; + + if (in_vim9script() + && ((argvars[0].v_type != VAR_STRING + && argvars[0].v_type != VAR_NUMBER + && check_for_string_arg(argvars, 0) == FAIL) || + (argvars[1].v_type != VAR_UNKNOWN + && check_for_number_arg(argvars, 1) == FAIL))) + return; + buf = term_get_buf(argvars, "term_wait()"); if (buf == NULL) return; if (buf->b_term->tl_job == NULL) |