Mercurial > vim
comparison src/evalvars.c @ 20725:f4455c71a8aa v8.2.0915
patch 8.2.0915: search() cannot skip over matches like searchpair() can
Commit: https://github.com/vim/vim/commit/adc17a5f9d207fd1623fd923457a46efc9214777
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 6 18:37:51 2020 +0200
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 https://github.com/vim/vim/issues/861)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 06 Jun 2020 18:45:03 +0200 |
parents | 70d561931721 |
children | ab27db64f1fb |
comparison
equal
deleted
inserted
replaced
20724:b4f459787045 | 20725:f4455c71a8aa |
---|---|
3809 callback->cb_free_name = FALSE; | 3809 callback->cb_free_name = FALSE; |
3810 } | 3810 } |
3811 callback->cb_name = NULL; | 3811 callback->cb_name = NULL; |
3812 } | 3812 } |
3813 | 3813 |
3814 /* | |
3815 * Process a function argument that can be a string expression or a function | |
3816 * reference. | |
3817 * "tv" must remain valid until calling evalarg_clean()! | |
3818 * Returns FAIL when the argument is invalid. | |
3819 */ | |
3820 int | |
3821 evalarg_get(typval_T *tv, evalarg_T *eva) | |
3822 { | |
3823 if (tv->v_type == VAR_STRING | |
3824 || tv->v_type == VAR_NUMBER | |
3825 || tv->v_type == VAR_BOOL | |
3826 || tv->v_type == VAR_SPECIAL) | |
3827 { | |
3828 eva->eva_string = tv_get_string_buf(tv, eva->eva_buf); | |
3829 return OK; | |
3830 } | |
3831 | |
3832 eva->eva_callback = get_callback(tv); | |
3833 return eva->eva_callback.cb_name == NULL ? FAIL : OK; | |
3834 } | |
3835 | |
3836 /* | |
3837 * Return whether "eva" has a valid expression or callback. | |
3838 */ | |
3839 int | |
3840 evalarg_valid(evalarg_T *eva) | |
3841 { | |
3842 return eva->eva_string != NULL || eva->eva_callback.cb_name != NULL; | |
3843 } | |
3844 | |
3845 /* | |
3846 * Invoke the expression or callback "eva" and return the result in "tv". | |
3847 * Returns FAIL if something failed | |
3848 */ | |
3849 int | |
3850 evalarg_call(evalarg_T *eva, typval_T *tv) | |
3851 { | |
3852 typval_T argv[1]; | |
3853 | |
3854 if (eva->eva_string != NULL) | |
3855 return eval0(eva->eva_string, tv, NULL, EVAL_EVALUATE); | |
3856 | |
3857 argv[0].v_type = VAR_UNKNOWN; | |
3858 return call_callback(&eva->eva_callback, -1, tv, 0, argv); | |
3859 } | |
3860 | |
3861 /* | |
3862 * Like evalarg_call(), but just return TRUE of FALSE. | |
3863 * Sets "error" to TRUE if evaluation failed. | |
3864 */ | |
3865 int | |
3866 evalarg_call_bool(evalarg_T *eva, int *error) | |
3867 { | |
3868 typval_T tv; | |
3869 int r; | |
3870 | |
3871 if (evalarg_call(eva, &tv) == FAIL) | |
3872 { | |
3873 *error = TRUE; | |
3874 return FALSE; | |
3875 } | |
3876 r = tv_get_number(&tv); | |
3877 clear_tv(&tv); | |
3878 *error = FALSE; | |
3879 return r; | |
3880 } | |
3881 | |
3882 void | |
3883 evalarg_clean(evalarg_T *eva) | |
3884 { | |
3885 if (eva->eva_string == NULL) | |
3886 free_callback(&eva->eva_callback); | |
3887 } | |
3888 | |
3814 #endif // FEAT_EVAL | 3889 #endif // FEAT_EVAL |