mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 01:08:20 +00:00
vim-patch:8.2.0915: search() cannot skip over matches like searchpair() can
Problem: Search() cannot skip over matches like searchpair() can. Solution: Add an optional "skip" argument. (Christian Brabandt, closes vim/vim#861)adc17a5f9d
Enable skip arg usage in autoload/freebasic.vim evalarg_T doesn't really matter because it's deleted in v8.2.0918 (and reincarnated for Vim9 script in v8.2.1047), but I found out too late :P Anyway: - Port evalarg_T into eval.h and use const char * and Callback fields - Use EVALARG_INIT to initialize - Return bool over OK/FAIL from evalarg functions - Remove check from evalarg_clean as callback_free ignores None callbacks anyway - Move eva_buf field into evalarg_get as a local (not sure what reason it has being in the struct) N/A patches for version.c: vim-patch:8.2.4355: unnecessary call to check_colorcolumn() Problem: Unnecessary call to check_colorcolumn(). Solution: Remove the call. (Sean Dewar, closes vim/vim#9748)0f7ff851cb
This commit is contained in:
@@ -3381,6 +3381,67 @@ static int eval_func(char_u **const arg, char_u *const name, const int name_len,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Process a function argument that can be a string expression or a function
|
||||
/// reference.
|
||||
/// "tv" must remain valid until calling evalarg_clean()!
|
||||
/// @return false when the argument is invalid.
|
||||
bool evalarg_get(typval_T *const tv, evalarg_T *const eva)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (tv->v_type == VAR_STRING || tv->v_type == VAR_NUMBER || tv->v_type == VAR_BOOL
|
||||
|| tv->v_type == VAR_SPECIAL) {
|
||||
char numbuf[NUMBUFLEN];
|
||||
eva->eva_string = tv_get_string_buf(tv, numbuf);
|
||||
return true;
|
||||
}
|
||||
|
||||
return callback_from_typval(&eva->eva_callback, tv);
|
||||
}
|
||||
|
||||
/// @return whether "eva" has a valid expression or callback.
|
||||
bool evalarg_valid(const evalarg_T *const eva)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_CONST
|
||||
{
|
||||
return eva->eva_string != NULL || eva->eva_callback.type != kCallbackNone;
|
||||
}
|
||||
|
||||
/// Invoke the expression or callback "eva" and return the result in "tv".
|
||||
/// @return false if something failed
|
||||
bool evalarg_call(evalarg_T *const eva, typval_T *const tv)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (eva->eva_string != NULL) {
|
||||
return eval0((char_u *)eva->eva_string, tv, NULL, true);
|
||||
}
|
||||
|
||||
typval_T argv[1];
|
||||
argv[0].v_type = VAR_UNKNOWN;
|
||||
return callback_call(&eva->eva_callback, 0, argv, tv);
|
||||
}
|
||||
|
||||
/// Like evalarg_call(), but just return true or false.
|
||||
/// Sets "error" to true if evaluation failed.
|
||||
bool evalarg_call_bool(evalarg_T *const eva, bool *const error)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
typval_T tv;
|
||||
if (!evalarg_call(eva, &tv)) {
|
||||
*error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool r = tv_get_number(&tv);
|
||||
tv_clear(&tv);
|
||||
*error = false;
|
||||
return r;
|
||||
}
|
||||
|
||||
void evalarg_clean(evalarg_T *const eva)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
callback_free(&eva->eva_callback);
|
||||
}
|
||||
|
||||
// TODO(ZyX-I): move to eval/expressions
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user