forked from aniani/vim
patch 9.0.2041: trim(): hard to use default mask
Problem: trim(): hard to use default mask (partly revert v9.0.2040) Solution: use default mask when it is empty 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. Currently, an empty 'mask' will make 'trim()' call return 'text' value that is passed in unmodified. It is unlikely that someone is using it, so the chances of scripts being broken by this change are low. Also, this reverts commit 9.0.2040 (which uses v:none for the default and requires to use an empty string instead). closes: #13358 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
This commit is contained in:
committed by
Christian Brabandt
parent
5a33ce2a66
commit
8079917447
31
src/typval.c
31
src/typval.c
@@ -450,37 +450,6 @@ check_for_opt_string_arg(typval_T *args, int idx)
|
||||
|| check_for_string_arg(args, idx) != FAIL) ? OK : FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for an optional string argument at 'idx', that can also be 'v:none' to
|
||||
* use the default value.
|
||||
*
|
||||
* If 'is_none' is non-NULL it is set to 0 and updated to 1 when "args[idx]" is
|
||||
* 'v:none'.
|
||||
*/
|
||||
int
|
||||
check_for_opt_string_or_none_arg(typval_T *args, int idx, int *is_none)
|
||||
{
|
||||
if (is_none != NULL)
|
||||
*is_none = 0;
|
||||
|
||||
if (args[idx].v_type == VAR_UNKNOWN)
|
||||
return OK;
|
||||
|
||||
if (args[idx].v_type == VAR_SPECIAL
|
||||
&& args[idx].vval.v_number == VVAL_NONE)
|
||||
{
|
||||
if (is_none != NULL)
|
||||
*is_none = 1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (args[idx].v_type == VAR_STRING)
|
||||
return OK;
|
||||
|
||||
semsg(_(e_string_or_none_required_for_argument_nr), idx + 1);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give an error and return FAIL unless "args[idx]" is a number.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user