diff options
Diffstat (limited to 'src/strings.c')
-rw-r--r-- | src/strings.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/strings.c b/src/strings.c index c04cbe84f6..f1c8af8f99 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1962,7 +1962,7 @@ f_trim(typval_T *argvars, typval_T *rettv) if (in_vim9script() && (check_for_string_arg(argvars, 0) == FAIL - || check_for_opt_string_arg(argvars, 1) == FAIL + || check_for_opt_string_or_none_arg(argvars, 1, NULL) == FAIL || (argvars[1].v_type != VAR_UNKNOWN && check_for_opt_number_arg(argvars, 2) == FAIL))) return; @@ -1971,26 +1971,24 @@ f_trim(typval_T *argvars, typval_T *rettv) if (head == NULL) return; - if (check_for_opt_string_arg(argvars, 1) == FAIL) + if (check_for_opt_string_or_none_arg(argvars, 1, NULL) == FAIL) return; if (argvars[1].v_type == VAR_STRING) - { mask = tv_get_string_buf_chk(&argvars[1], buf2); - if (argvars[2].v_type != VAR_UNKNOWN) - { - int error = 0; + if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) + { + int error = 0; - // leading or trailing characters to trim - dir = (int)tv_get_number_chk(&argvars[2], &error); - if (error) - return; - if (dir < 0 || dir > 2) - { - semsg(_(e_invalid_argument_str), tv_get_string(&argvars[2])); - return; - } + // leading or trailing characters to trim + dir = (int)tv_get_number_chk(&argvars[2], &error); + if (error) + return; + if (dir < 0 || dir > 2) + { + semsg(_(e_invalid_argument_str), tv_get_string(&argvars[2])); + return; } } |