patch 9.0.2040: trim(): hard to use default mask

Problem:  trim(): hard to use default mask
Solution: Use default 'mask' when it is v:none

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

'v:none' is already used to mean "use the default argument value" in
user defined functions.  See |none-function_argument| in help.

closes: #13363

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
diff --git a/src/strings.c b/src/strings.c
index c04cbe8..f1c8af8 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -1962,7 +1962,7 @@
 
     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 @@
     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;
 	}
     }