To: vim_dev@googlegroups.com Subject: Patch 9.0.0634 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0634 Problem: Evaluating "expr" options has more overhead than needed. Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr', "expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr', 'formatexpr', 'indentexpr' and 'charconvert'. Files: runtime/doc/options.txt, runtime/doc/print.txt, runtime/doc/diff.txt, src/eval.c, src/proto/eval.pro, src/beval.c, src/buffer.c, src/clientserver.c, src/evalvars.c, src/ex_docmd.c, src/ex_eval.c, src/filepath.c, src/findfile.c, src/fold.c, src/if_ole.cpp, src/if_perl.xs, src/if_tcl.c, src/map.c, src/regexp.c, src/register.c, src/screen.c, src/scriptfile.c, src/textformat.c *** ../vim-9.0.0633/runtime/doc/options.txt 2022-09-11 16:59:48.934110049 +0100 --- runtime/doc/options.txt 2022-10-01 19:28:32.899586824 +0100 *************** *** 1600,1605 **** --- 1626,1634 ---- Note that v:charconvert_from and v:charconvert_to may be different from 'encoding'. Vim internally uses UTF-8 instead of UCS-2 or UCS-4. + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + Encryption is not done by Vim when using 'charconvert'. If you want to encrypt the file after conversion, 'charconvert' should take care of this. *************** *** 3637,3642 **** --- 3667,3675 ---- < This will invoke the mylang#Format() function in the autoload/mylang.vim file in 'runtimepath'. |autoload| + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + The expression is also evaluated when 'textwidth' is set and adding text beyond that limit. This happens under the same conditions as when internal formatting is used. Make sure the cursor is kept in the *************** *** 4505,4515 **** If the expression starts with s: or ||, then it is replaced with the script ID (|local-function|). Example: > ! set includeexpr=s:MyIncludeExpr(v:fname) ! set includeexpr=SomeIncludeExpr(v:fname) < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. The expression will be evaluated in the |sandbox| when set from a modeline, see |sandbox-option|. This option cannot be set in a modeline when 'modelineexpr' is off. --- 4540,4553 ---- If the expression starts with s: or ||, then it is replaced with the script ID (|local-function|). Example: > ! set includeexpr=s:MyIncludeExpr() ! set includeexpr=SomeIncludeExpr() < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. + It is more efficient if the value is just a function call without + arguments, see |expr-option-function|. + The expression will be evaluated in the |sandbox| when set from a modeline, see |sandbox-option|. This option cannot be set in a modeline when 'modelineexpr' is off. *************** *** 4591,4596 **** --- 4629,4637 ---- < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + The expression must return the number of spaces worth of indent. It can return "-1" to keep the current indent (this means 'autoindent' is used for the indent). *************** *** 7440,7448 **** The file is used for all languages. expr:{expr} Evaluate expression {expr}. Use a function to avoid ! trouble with spaces. |v:val| holds the badly spelled ! word. The expression must evaluate to a List of ! Lists, each with a suggestion and a score. Example: [['the', 33], ['that', 44]] ~ Set 'verbose' and use |z=| to see the scores that the --- 7482,7492 ---- The file is used for all languages. expr:{expr} Evaluate expression {expr}. Use a function to avoid ! trouble with spaces. Best is to call a function ! without arguments, see |expr-option-function|. ! |v:val| holds the badly spelled word. The expression ! must evaluate to a List of Lists, each with a ! suggestion and a score. Example: [['the', 33], ['that', 44]] ~ Set 'verbose' and use |z=| to see the scores that the *** ../vim-9.0.0633/runtime/doc/print.txt 2022-06-28 11:21:06.000000000 +0100 --- runtime/doc/print.txt 2022-10-01 18:15:34.823389696 +0100 *************** *** 158,170 **** If you change this option, using a function is an easy way to avoid having to escape all the spaces. Example: > ! :set printexpr=PrintFile(v:fname_in) ! :function PrintFile(fname) ! : call system("ghostview " .. a:fname) ! : call delete(a:fname) : return v:shell_error :endfunc Be aware that some print programs return control before they have read the file. If you delete the file too soon it will not be printed. These programs usually offer an option to have them remove the file when printing is done. --- 158,173 ---- If you change this option, using a function is an easy way to avoid having to escape all the spaces. Example: > ! :set printexpr=PrintFile() ! :function PrintFile() ! : call system("ghostview " .. v:fname_in) ! : call delete(v:fname_in) : return v:shell_error :endfunc + It is more efficient if the option is set to just a function call, + see |expr-option-function|. + Be aware that some print programs return control before they have read the file. If you delete the file too soon it will not be printed. These programs usually offer an option to have them remove the file when printing is done. *** ../vim-9.0.0633/runtime/doc/diff.txt 2022-06-28 11:21:05.000000000 +0100 --- runtime/doc/diff.txt 2022-10-01 19:11:31.089952294 +0100 *************** *** 376,381 **** --- 376,384 ---- 'diffopt' option. 'diffexpr' cannot change the value of 'lines' and 'columns'. + The advantage of using a function call without arguments is that it is faster, + see |expr-option-function|. + Example (this does almost the same as 'diffexpr' being empty): > set diffexpr=MyDiff() *************** *** 441,446 **** --- 444,452 ---- v:fname_diff patch file v:fname_out resulting patched file + The advantage of using a function call without arguments is that it is faster, + see |expr-option-function|. + Example (this does the same as 'patchexpr' being empty): > set patchexpr=MyPatch() *** ../vim-9.0.0633/src/eval.c 2022-10-01 15:32:42.539442245 +0100 --- src/eval.c 2022-10-01 19:19:45.688507520 +0100 *************** *** 143,159 **** char_u *arg, int *error, exarg_T *eap, ! int skip) // only parse, don't execute { typval_T tv; varnumber_T retval = FALSE; evalarg_T evalarg; fill_evalarg_from_eap(&evalarg, eap, skip); if (skip) ++emsg_skip; ! if (eval0(arg, &tv, eap, &evalarg) == FAIL) *error = TRUE; else { --- 143,165 ---- char_u *arg, int *error, exarg_T *eap, ! int skip, // only parse, don't execute ! int use_simple_function) { typval_T tv; varnumber_T retval = FALSE; evalarg_T evalarg; + int r; fill_evalarg_from_eap(&evalarg, eap, skip); if (skip) ++emsg_skip; ! if (use_simple_function) ! r = eval0_simple_funccal(arg, &tv, eap, &evalarg); ! else ! r = eval0(arg, &tv, eap, &evalarg); ! if (r == FAIL) *error = TRUE; else { *************** *** 601,614 **** eval_to_string_eap( char_u *arg, int convert, ! exarg_T *eap) { typval_T tv; char_u *retval; evalarg_T evalarg; fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip); ! if (eval0(arg, &tv, NULL, &evalarg) == FAIL) retval = NULL; else { --- 607,626 ---- eval_to_string_eap( char_u *arg, int convert, ! exarg_T *eap, ! int use_simple_function) { typval_T tv; char_u *retval; evalarg_T evalarg; + int r; fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip); ! if (use_simple_function) ! r = eval0_simple_funccal(arg, &tv, NULL, &evalarg); ! else ! r = eval0(arg, &tv, NULL, &evalarg); ! if (r == FAIL) retval = NULL; else { *************** *** 623,631 **** char_u * eval_to_string( char_u *arg, ! int convert) { ! return eval_to_string_eap(arg, convert, NULL); } /* --- 635,644 ---- char_u * eval_to_string( char_u *arg, ! int convert, ! int use_simple_function) { ! return eval_to_string_eap(arg, convert, NULL, use_simple_function); } /* *************** *** 637,643 **** eval_to_string_safe( char_u *arg, int use_sandbox, ! int keep_script_version) { char_u *retval; funccal_entry_T funccal_entry; --- 650,657 ---- eval_to_string_safe( char_u *arg, int use_sandbox, ! int keep_script_version, ! int use_simple_function) { char_u *retval; funccal_entry_T funccal_entry; *************** *** 651,657 **** ++sandbox; ++textlock; may_garbage_collect = FALSE; ! retval = eval_to_string(arg, FALSE); if (use_sandbox) --sandbox; --textlock; --- 665,671 ---- ++sandbox; ++textlock; may_garbage_collect = FALSE; ! retval = eval_to_string(arg, FALSE, use_simple_function); if (use_sandbox) --sandbox; --textlock; *************** *** 667,681 **** * Returns -1 for an error. */ varnumber_T ! eval_to_number(char_u *expr) { typval_T rettv; varnumber_T retval; char_u *p = skipwhite(expr); ++emsg_off; ! if (eval1(&p, &rettv, &EVALARG_EVALUATE) == FAIL) retval = -1; else { --- 681,700 ---- * Returns -1 for an error. */ varnumber_T ! eval_to_number(char_u *expr, int use_simple_function) { typval_T rettv; varnumber_T retval; char_u *p = skipwhite(expr); + int r = NOTDONE; ++emsg_off; ! if (use_simple_function) ! r = may_call_simple_func(expr, &rettv); ! if (r == NOTDONE) ! r = eval1(&p, &rettv, &EVALARG_EVALUATE); ! if (r == FAIL) retval = -1; else { *************** *** 695,708 **** typval_T * eval_expr(char_u *arg, exarg_T *eap) { typval_T *tv; evalarg_T evalarg; fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip); tv = ALLOC_ONE(typval_T); ! if (tv != NULL && eval0(arg, tv, eap, &evalarg) == FAIL) ! VIM_CLEAR(tv); clear_evalarg(&evalarg, eap); return tv; --- 714,743 ---- typval_T * eval_expr(char_u *arg, exarg_T *eap) { + return eval_expr_ext(arg, eap, FALSE); + } + + typval_T * + eval_expr_ext(char_u *arg, exarg_T *eap, int use_simple_function) + { typval_T *tv; evalarg_T evalarg; fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip); tv = ALLOC_ONE(typval_T); ! if (tv != NULL) ! { ! int r = NOTDONE; ! ! if (use_simple_function) ! r = eval0_simple_funccal(arg, tv, eap, &evalarg); ! if (r == NOTDONE) ! r = eval0(arg, tv, eap, &evalarg); ! ! if (r == FAIL) ! VIM_CLEAR(tv); ! } clear_evalarg(&evalarg, eap); return tv; *************** *** 899,910 **** { char_u *arg; typval_T tv; - int r = NOTDONE; varnumber_T retval; char_u *s; sctx_T saved_sctx = current_sctx; int use_sandbox = was_set_insecurely((char_u *)"foldexpr", ! OPT_LOCAL); arg = skipwhite(wp->w_p_fde); current_sctx = wp->w_p_script_ctx[WV_FDE]; --- 934,944 ---- { char_u *arg; typval_T tv; varnumber_T retval; char_u *s; sctx_T saved_sctx = current_sctx; int use_sandbox = was_set_insecurely((char_u *)"foldexpr", ! OPT_LOCAL); arg = skipwhite(wp->w_p_fde); current_sctx = wp->w_p_script_ctx[WV_FDE]; *************** *** 915,934 **** ++textlock; *cp = NUL; ! // If the expression is "FuncName()" then we can skip a lot of overhead. ! char_u *parens = (char_u *)strstr((char *)arg, "()"); ! if (parens != NULL && *skipwhite(parens + 2) == NUL) ! { ! char_u *p = STRNCMP(arg, "", 5) == 0 ? skipdigits(arg + 5) : arg; ! ! if (to_name_end(p, TRUE) == parens) ! r = call_simple_func(arg, (int)(parens - arg), &tv); ! } ! ! if (r == NOTDONE) ! r = eval0(arg, &tv, NULL, &EVALARG_EVALUATE); ! ! if (r == FAIL) retval = 0; else { --- 949,957 ---- ++textlock; *cp = NUL; ! // Evaluate the expression. If the expression is "FuncName()" call the ! // function directly. ! if (eval0_simple_funccal(arg, &tv, NULL, &EVALARG_EVALUATE) == FAIL) retval = 0; else { *************** *** 2428,2436 **** } /* ! * The "evaluate" argument: When FALSE, the argument is only parsed but not ! * executed. The function may return OK, but the rettv will be of type ! * VAR_UNKNOWN. The function still returns FAIL for a syntax error. */ /* --- 2451,2460 ---- } /* ! * The "eval" functions have an "evalarg" argument: When NULL or ! * "evalarg->eval_flags" does not have EVAL_EVALUATE, then the argument is only ! * parsed but not executed. The functions may return OK, but the rettv will be ! * of type VAR_UNKNOWN. The functions still returns FAIL for a syntax error. */ /* *************** *** 2452,2457 **** --- 2476,2522 ---- } /* + * If "arg" is a simple function call without arguments then call it and return + * the result. Otherwise return NOTDONE. + */ + int + may_call_simple_func( + char_u *arg, + typval_T *rettv) + { + char_u *parens = (char_u *)strstr((char *)arg, "()"); + int r = NOTDONE; + + // If the expression is "FuncName()" then we can skip a lot of overhead. + if (parens != NULL && *skipwhite(parens + 2) == NUL) + { + char_u *p = STRNCMP(arg, "", 5) == 0 ? skipdigits(arg + 5) : arg; + + if (to_name_end(p, TRUE) == parens) + r = call_simple_func(arg, (int)(parens - arg), rettv); + } + return r; + } + + /* + * Handle zero level expression with optimization for a simple function call. + * Same arguments and return value as eval0(). + */ + int + eval0_simple_funccal( + char_u *arg, + typval_T *rettv, + exarg_T *eap, + evalarg_T *evalarg) + { + int r = may_call_simple_func(arg, rettv); + + if (r == NOTDONE) + r = eval0_retarg(arg, rettv, eap, evalarg, NULL); + return r; + } + + /* * Like eval0() but when "retarg" is not NULL store the pointer to after the * expression and don't check what comes after the expression. */ *************** *** 6283,6289 **** c1 = *in_end; *in_end = NUL; ! temp_result = eval_to_string(expr_start + 1, FALSE); if (temp_result != NULL) { retval = alloc(STRLEN(temp_result) + (expr_start - in_start) --- 6348,6354 ---- c1 = *in_end; *in_end = NUL; ! temp_result = eval_to_string(expr_start + 1, FALSE, FALSE); if (temp_result != NULL) { retval = alloc(STRLEN(temp_result) + (expr_start - in_start) *** ../vim-9.0.0633/src/proto/eval.pro 2022-09-28 16:16:10.252335644 +0100 --- src/proto/eval.pro 2022-10-01 19:26:42.763751647 +0100 *************** *** 4,10 **** void eval_init(void); void eval_clear(void); void fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip); ! int eval_to_bool(char_u *arg, int *error, exarg_T *eap, int skip); int eval_expr_valid_arg(typval_T *tv); funccall_T *eval_expr_get_funccal(typval_T *expr, typval_T *rettv); int eval_expr_typval(typval_T *expr, typval_T *argv, int argc, funccall_T *fc_arg, typval_T *rettv); --- 4,10 ---- void eval_init(void); void eval_clear(void); void fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip); ! int eval_to_bool(char_u *arg, int *error, exarg_T *eap, int skip, int use_simple_function); int eval_expr_valid_arg(typval_T *tv); funccall_T *eval_expr_get_funccal(typval_T *expr, typval_T *rettv); int eval_expr_typval(typval_T *expr, typval_T *argv, int argc, funccall_T *fc_arg, typval_T *rettv); *************** *** 15,25 **** int skip_expr(char_u **pp, evalarg_T *evalarg); int skip_expr_concatenate(char_u **arg, char_u **start, char_u **end, evalarg_T *evalarg); char_u *typval2string(typval_T *tv, int convert); ! char_u *eval_to_string_eap(char_u *arg, int convert, exarg_T *eap); ! char_u *eval_to_string(char_u *arg, int convert); ! char_u *eval_to_string_safe(char_u *arg, int use_sandbox, int keep_script_version); ! varnumber_T eval_to_number(char_u *expr); typval_T *eval_expr(char_u *arg, exarg_T *eap); int call_vim_function(char_u *func, int argc, typval_T *argv, typval_T *rettv); void *call_func_retstr(char_u *func, int argc, typval_T *argv); void *call_func_retlist(char_u *func, int argc, typval_T *argv); --- 15,26 ---- int skip_expr(char_u **pp, evalarg_T *evalarg); int skip_expr_concatenate(char_u **arg, char_u **start, char_u **end, evalarg_T *evalarg); char_u *typval2string(typval_T *tv, int convert); ! char_u *eval_to_string_eap(char_u *arg, int convert, exarg_T *eap, int use_simple_function); ! char_u *eval_to_string(char_u *arg, int convert, int use_simple_function); ! char_u *eval_to_string_safe(char_u *arg, int use_sandbox, int keep_script_version, int use_simple_function); ! varnumber_T eval_to_number(char_u *expr, int use_simple_function); typval_T *eval_expr(char_u *arg, exarg_T *eap); + typval_T *eval_expr_ext(char_u *arg, exarg_T *eap, int use_simple_function); int call_vim_function(char_u *func, int argc, typval_T *argv, typval_T *rettv); void *call_func_retstr(char_u *func, int argc, typval_T *argv); void *call_func_retlist(char_u *func, int argc, typval_T *argv); *************** *** 38,43 **** --- 39,46 ---- char_u *eval_next_line(char_u *arg, evalarg_T *evalarg); char_u *skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg); int eval0(char_u *arg, typval_T *rettv, exarg_T *eap, evalarg_T *evalarg); + int may_call_simple_func(char_u *arg, typval_T *rettv); + int eval0_simple_funccal(char_u *arg, typval_T *rettv, exarg_T *eap, evalarg_T *evalarg); int eval0_retarg(char_u *arg, typval_T *rettv, exarg_T *eap, evalarg_T *evalarg, char_u **retarg); int eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg); void eval_addblob(typval_T *tv1, typval_T *tv2); *** ../vim-9.0.0633/src/beval.c 2022-09-27 11:46:35.151438619 +0100 --- src/beval.c 2022-10-01 19:16:54.912912143 +0100 *************** *** 278,284 **** current_sctx = curbuf->b_p_script_ctx[BV_BEXPR]; vim_free(result); ! result = eval_to_string(bexpr, TRUE); // Remove one trailing newline, it is added when the result was a // list and it's hardly ever useful. If the user really wants a --- 278,284 ---- current_sctx = curbuf->b_p_script_ctx[BV_BEXPR]; vim_free(result); ! result = eval_to_string(bexpr, TRUE, TRUE); // Remove one trailing newline, it is added when the result was a // list and it's hardly ever useful. If the user really wants a *** ../vim-9.0.0633/src/buffer.c 2022-09-28 11:48:26.677156955 +0100 --- src/buffer.c 2022-10-01 17:41:43.211498769 +0100 *************** *** 4246,4252 **** tv.vval.v_number = wp->w_id; set_var((char_u *)"g:statusline_winid", &tv, FALSE); ! usefmt = eval_to_string_safe(fmt + 2, use_sandbox, FALSE); if (usefmt == NULL) usefmt = fmt; --- 4246,4252 ---- tv.vval.v_number = wp->w_id; set_var((char_u *)"g:statusline_winid", &tv, FALSE); ! usefmt = eval_to_string_safe(fmt + 2, use_sandbox, FALSE, FALSE); if (usefmt == NULL) usefmt = fmt; *************** *** 4633,4639 **** if (curwin != save_curwin) VIsual_active = FALSE; ! str = eval_to_string_safe(p, use_sandbox, FALSE); curwin = save_curwin; curbuf = save_curbuf; --- 4633,4639 ---- if (curwin != save_curwin) VIsual_active = FALSE; ! str = eval_to_string_safe(p, use_sandbox, FALSE, FALSE); curwin = save_curwin; curbuf = save_curbuf; *** ../vim-9.0.0633/src/clientserver.c 2022-09-08 10:55:34.233826402 +0100 --- src/clientserver.c 2022-10-01 17:52:16.496794365 +0100 *************** *** 86,92 **** // to be typed. Do generate errors so that try/catch works. ++emsg_silent; ! res = eval_to_string(expr, TRUE); debug_break_level = save_dbl; redir_off = save_ro; --- 86,92 ---- // to be typed. Do generate errors so that try/catch works. ++emsg_silent; ! res = eval_to_string(expr, TRUE, FALSE); debug_break_level = save_dbl; redir_off = save_ro; *** ../vim-9.0.0633/src/evalvars.c 2022-09-21 18:59:10.671074961 +0100 --- src/evalvars.c 2022-10-01 19:27:23.383689635 +0100 *************** *** 380,386 **** if (ctx != NULL) current_sctx = *ctx; ! if (eval_to_bool(p_ccv, &err, NULL, FALSE)) err = TRUE; set_vim_var_string(VV_CC_FROM, NULL, -1); --- 380,386 ---- if (ctx != NULL) current_sctx = *ctx; ! if (eval_to_bool(p_ccv, &err, NULL, FALSE, TRUE)) err = TRUE; set_vim_var_string(VV_CC_FROM, NULL, -1); *************** *** 408,414 **** if (ctx != NULL) current_sctx = *ctx; ! if (eval_to_bool(p_pexpr, &err, NULL, FALSE)) err = TRUE; set_vim_var_string(VV_FNAME_IN, NULL, -1); --- 408,414 ---- if (ctx != NULL) current_sctx = *ctx; ! if (eval_to_bool(p_pexpr, &err, NULL, FALSE, TRUE)) err = TRUE; set_vim_var_string(VV_FNAME_IN, NULL, -1); *************** *** 444,450 **** current_sctx = *ctx; // errors are ignored ! tv = eval_expr(p_dex, NULL); free_tv(tv); set_vim_var_string(VV_FNAME_IN, NULL, -1); --- 444,450 ---- current_sctx = *ctx; // errors are ignored ! tv = eval_expr_ext(p_dex, NULL, TRUE); free_tv(tv); set_vim_var_string(VV_FNAME_IN, NULL, -1); *************** *** 472,478 **** current_sctx = *ctx; // errors are ignored ! tv = eval_expr(p_pex, NULL); free_tv(tv); set_vim_var_string(VV_FNAME_IN, NULL, -1); --- 472,478 ---- current_sctx = *ctx; // errors are ignored ! tv = eval_expr_ext(p_pex, NULL, TRUE); free_tv(tv); set_vim_var_string(VV_FNAME_IN, NULL, -1); *************** *** 497,502 **** --- 497,503 ---- char_u *p = skipwhite(expr); sctx_T saved_sctx = current_sctx; sctx_T *ctx; + int r; // Set "v:val" to the bad word. prepare_vimvar(VV_VAL, &save_val); *************** *** 507,513 **** if (ctx != NULL) current_sctx = *ctx; ! if (eval1(&p, &rettv, &EVALARG_EVALUATE) == OK) { if (rettv.v_type != VAR_LIST) clear_tv(&rettv); --- 508,517 ---- if (ctx != NULL) current_sctx = *ctx; ! r = may_call_simple_func(p, &rettv); ! if (r == NOTDONE) ! r = eval1(&p, &rettv, &EVALARG_EVALUATE); ! if (r == OK) { if (rettv.v_type != VAR_LIST) clear_tv(&rettv); *************** *** 643,649 **** if (evaluate) { *block_end = NUL; ! expr_val = eval_to_string(block_start, TRUE); *block_end = '}'; if (expr_val == NULL) return NULL; --- 647,653 ---- if (evaluate) { *block_end = NUL; ! expr_val = eval_to_string(block_start, TRUE, FALSE); *block_end = '}'; if (expr_val == NULL) return NULL; *** ../vim-9.0.0633/src/ex_docmd.c 2022-09-22 18:08:34.339338137 +0100 --- src/ex_docmd.c 2022-10-01 17:52:55.384638081 +0100 *************** *** 5778,5784 **** if (expr != NULL) { ++emsg_off; ! p = eval_to_string(expr, FALSE); --emsg_off; vim_free(expr); } --- 5778,5784 ---- if (expr != NULL) { ++emsg_off; ! p = eval_to_string(expr, FALSE, FALSE); --emsg_off; vim_free(expr); } *** ../vim-9.0.0633/src/ex_eval.c 2022-09-24 17:24:07.095558762 +0100 --- src/ex_eval.c 2022-10-01 18:28:27.456175928 +0100 *************** *** 1047,1053 **** skip = did_emsg || got_int || did_throw || (cstack->cs_idx > 0 && !(cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE)); ! result = eval_to_bool(eap->arg, &error, eap, skip); if (!skip && !error) { --- 1047,1053 ---- skip = did_emsg || got_int || did_throw || (cstack->cs_idx > 0 && !(cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE)); ! result = eval_to_bool(eap->arg, &error, eap, skip, FALSE); if (!skip && !error) { *************** *** 1176,1182 **** if (skip && ends_excmd(*eap->arg)) semsg(_(e_invalid_expression_str), eap->arg); else ! result = eval_to_bool(eap->arg, &error, eap, skip); // When throwing error exceptions, we want to throw always the first // of several errors in a row. This is what actually happens when --- 1176,1182 ---- if (skip && ends_excmd(*eap->arg)) semsg(_(e_invalid_expression_str), eap->arg); else ! result = eval_to_bool(eap->arg, &error, eap, skip, FALSE); // When throwing error exceptions, we want to throw always the first // of several errors in a row. This is what actually happens when *************** *** 1283,1289 **** /* * ":while bool-expr" */ ! result = eval_to_bool(eap->arg, &error, eap, skip); } else { --- 1283,1289 ---- /* * ":while bool-expr" */ ! result = eval_to_bool(eap->arg, &error, eap, skip, FALSE); } else { *** ../vim-9.0.0633/src/filepath.c 2022-09-28 16:16:10.256335629 +0100 --- src/filepath.c 2022-10-01 17:53:00.708616740 +0100 *************** *** 3354,3360 **** #ifdef FEAT_EVAL if (*cmd == '=') // `={expr}`: Expand expression ! buffer = eval_to_string(cmd + 1, TRUE); else #endif buffer = get_cmd_output(cmd, NULL, --- 3354,3360 ---- #ifdef FEAT_EVAL if (*cmd == '=') // `={expr}`: Expand expression ! buffer = eval_to_string(cmd + 1, TRUE, FALSE); else #endif buffer = get_cmd_output(cmd, NULL, *** ../vim-9.0.0633/src/findfile.c 2022-09-18 13:06:36.461124371 +0100 --- src/findfile.c 2022-10-01 17:42:37.003251771 +0100 *************** *** 2002,2008 **** current_sctx = curbuf->b_p_script_ctx[BV_INEX]; res = eval_to_string_safe(curbuf->b_p_inex, ! was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL), TRUE); set_vim_var_string(VV_FNAME, NULL, 0); current_sctx = save_sctx; --- 2002,2009 ---- current_sctx = curbuf->b_p_script_ctx[BV_INEX]; res = eval_to_string_safe(curbuf->b_p_inex, ! was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL), ! TRUE, TRUE); set_vim_var_string(VV_FNAME, NULL, 0); current_sctx = save_sctx; *** ../vim-9.0.0633/src/fold.c 2022-08-14 14:16:07.987582278 +0100 --- src/fold.c 2022-10-01 17:43:04.879125510 +0100 *************** *** 1960,1966 **** ++emsg_off; // handle exceptions, but don't display errors text = eval_to_string_safe(wp->w_p_fdt, ! was_set_insecurely((char_u *)"foldtext", OPT_LOCAL), TRUE); --emsg_off; if (text == NULL || did_emsg) --- 1960,1967 ---- ++emsg_off; // handle exceptions, but don't display errors text = eval_to_string_safe(wp->w_p_fdt, ! was_set_insecurely((char_u *)"foldtext", OPT_LOCAL), ! TRUE, TRUE); --emsg_off; if (text == NULL || did_emsg) *** ../vim-9.0.0633/src/if_ole.cpp 2022-01-24 11:12:27.000000000 +0000 --- src/if_ole.cpp 2022-10-01 17:54:20.676297587 +0100 *************** *** 381,387 **** /* Evaluate the expression */ ++emsg_skip; ! str = (char *)eval_to_string((char_u *)buffer, TRUE); --emsg_skip; vim_free(buffer); if (str == NULL) --- 381,387 ---- /* Evaluate the expression */ ++emsg_skip; ! str = (char *)eval_to_string((char_u *)buffer, TRUE, FALSE); --emsg_skip; vim_free(buffer); if (str == NULL) *** ../vim-9.0.0633/src/if_perl.xs 2022-09-17 21:24:45.874842348 +0100 --- src/if_perl.xs 2022-10-01 17:54:15.160319517 +0100 *************** *** 873,879 **** char_u * eval_to_string( char_u *arg UNUSED, ! int dolist UNUSED) { return NULL; } --- 873,880 ---- char_u * eval_to_string( char_u *arg UNUSED, ! int convert UNUSED, ! int use_simple_function UNUSED) { return NULL; } *************** *** 1599,1605 **** PREINIT: char_u *value; PPCODE: ! value = eval_to_string((char_u *)str, TRUE); if (value == NULL) { XPUSHs(sv_2mortal(newSViv(0))); --- 1600,1606 ---- PREINIT: char_u *value; PPCODE: ! value = eval_to_string((char_u *)str, TRUE, FALSE); if (value == NULL) { XPUSHs(sv_2mortal(newSViv(0))); *** ../vim-9.0.0633/src/if_tcl.c 2022-08-14 14:16:07.991582244 +0100 --- src/if_tcl.c 2022-10-01 17:53:05.228598615 +0100 *************** *** 1397,1403 **** #ifdef FEAT_EVAL expr = Tcl_GetStringFromObj(objv[objn], NULL); ! str = (char *)eval_to_string((char_u *)expr, TRUE); if (str == NULL) Tcl_SetResult(interp, _("invalid expression"), TCL_STATIC); else --- 1397,1403 ---- #ifdef FEAT_EVAL expr = Tcl_GetStringFromObj(objv[objn], NULL); ! str = (char *)eval_to_string((char_u *)expr, TRUE, FALSE); if (str == NULL) Tcl_SetResult(interp, _("invalid expression"), TCL_STATIC); else *** ../vim-9.0.0633/src/map.c 2022-09-12 13:35:06.510946769 +0100 --- src/map.c 2022-10-01 17:53:09.872580023 +0100 *************** *** 1711,1717 **** } // Note: the evaluation may make "mp" invalid. ! p = eval_to_string(expr, FALSE); --textlock; --ex_normal_lock; --- 1711,1717 ---- } // Note: the evaluation may make "mp" invalid. ! p = eval_to_string(expr, FALSE, FALSE); --textlock; --ex_normal_lock; *** ../vim-9.0.0633/src/regexp.c 2022-09-20 13:51:21.355306835 +0100 --- src/regexp.c 2022-10-01 17:53:13.960563658 +0100 *************** *** 2125,2131 **** // Execute instructions from ISN_SUBSTITUTE. eval_result[nested] = exe_substitute_instr(); else ! eval_result[nested] = eval_to_string(source + 2, TRUE); --nesting; if (eval_result[nested] != NULL) --- 2125,2131 ---- // Execute instructions from ISN_SUBSTITUTE. eval_result[nested] = exe_substitute_instr(); else ! eval_result[nested] = eval_to_string(source + 2, TRUE, FALSE); --nesting; if (eval_result[nested] != NULL) *** ../vim-9.0.0633/src/register.c 2022-08-31 14:46:07.911016920 +0100 --- src/register.c 2022-10-01 17:50:40.501183428 +0100 *************** *** 151,157 **** return expr_copy; ++nested; ! rv = eval_to_string_eap(expr_copy, TRUE, expr_eap); --nested; vim_free(expr_copy); return rv; --- 151,157 ---- return expr_copy; ++nested; ! rv = eval_to_string_eap(expr_copy, TRUE, expr_eap, FALSE); --nested; vim_free(expr_copy); return rv; *** ../vim-9.0.0633/src/screen.c 2022-09-26 15:18:43.778952810 +0100 --- src/screen.c 2022-10-01 17:53:18.968543621 +0100 *************** *** 1198,1204 **** curwin = wp; STRCPY(buf, "b:keymap_name"); // must be writable ++emsg_skip; ! s = p = eval_to_string(buf, FALSE); --emsg_skip; curbuf = old_curbuf; curwin = old_curwin; --- 1198,1204 ---- curwin = wp; STRCPY(buf, "b:keymap_name"); // must be writable ++emsg_skip; ! s = p = eval_to_string(buf, FALSE, FALSE); --emsg_skip; curbuf = old_curbuf; curwin = old_curwin; *************** *** 2976,2982 **** * Clear the screen. * May delay if there is something the user should read. * Allocated the screen for resizing if needed. ! * Returns TRUE when the screen was actually claared, FALSE if all display * cells were marked for updating. */ int --- 2976,2982 ---- * Clear the screen. * May delay if there is something the user should read. * Allocated the screen for resizing if needed. ! * Returns TRUE when the screen was actually cleared, FALSE if all display * cells were marked for updating. */ int *** ../vim-9.0.0633/src/scriptfile.c 2022-09-15 12:20:12.881894422 +0100 --- src/scriptfile.c 2022-10-01 19:20:35.704401977 +0100 *************** *** 810,816 **** // If runtime/filetype.vim wasn't loaded yet, the scripts will be // found when it loads. ! if (cmd != NULL && eval_to_number(cmd) > 0) { do_cmdline_cmd((char_u *)"augroup filetypedetect"); vim_snprintf((char *)pat, len, ftpat, ffname); --- 810,816 ---- // If runtime/filetype.vim wasn't loaded yet, the scripts will be // found when it loads. ! if (cmd != NULL && eval_to_number(cmd, FALSE) > 0) { do_cmdline_cmd((char_u *)"augroup filetypedetect"); vim_snprintf((char *)pat, len, ftpat, ffname); *** ../vim-9.0.0633/src/textformat.c 2022-08-14 14:16:08.003582142 +0100 --- src/textformat.c 2022-10-01 19:21:15.196322147 +0100 *************** *** 938,944 **** // Evaluate the function. if (use_sandbox) ++sandbox; ! r = (int)eval_to_number(fex); if (use_sandbox) --sandbox; --- 938,944 ---- // Evaluate the function. if (use_sandbox) ++sandbox; ! r = (int)eval_to_number(fex, TRUE); if (use_sandbox) --sandbox; *** ../vim-9.0.0633/src/version.c 2022-10-01 15:46:59.540243953 +0100 --- src/version.c 2022-10-01 19:27:57.955637999 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 634, /**/ -- A man is incomplete until he's married ... and then he's finished! /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///