To: vim_dev@googlegroups.com Subject: Patch 8.2.3796 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3796 Problem: The funcexe_T struct members are not named consistently. Solution: Prefix "fe_" to all the members. Files: src/structs.h, src/eval.c, src/list.c, src/regexp.c, src/terminal.c, src/userfunc.c, src/vim9execute.c *** ../vim-8.2.3795/src/structs.h 2021-12-13 13:11:00.696262332 +0000 --- src/structs.h 2021-12-13 13:48:44.966524687 +0000 *************** *** 1992,2006 **** // called_func_argcount) // typedef struct { ! int (* argv_func)(int, typval_T *, int, int); ! linenr_T firstline; // first line of range ! linenr_T lastline; // last line of range ! int *doesrange; // if not NULL: return: function handled range ! int evaluate; // actually evaluate expressions ! partial_T *partial; // for extra arguments ! dict_T *selfdict; // Dictionary for "self" ! typval_T *basetv; // base for base->method() ! type_T *check_type; // type from funcref or NULL int fe_found_var; // if the function is not found then give an // error that a variable is not callable. } funcexe_T; --- 1992,2006 ---- // called_func_argcount) // typedef struct { ! int (* fe_argv_func)(int, typval_T *, int, int); ! linenr_T fe_firstline; // first line of range ! linenr_T fe_lastline; // last line of range ! int *fe_doesrange; // if not NULL: return: function handled range ! int fe_evaluate; // actually evaluate expressions ! partial_T *fe_partial; // for extra arguments ! dict_T *fe_selfdict; // Dictionary for "self" ! typval_T *fe_basetv; // base for base->method() ! type_T *fe_check_type; // type from funcref or NULL int fe_found_var; // if the function is not found then give an // error that a variable is not callable. } funcexe_T; *** ../vim-8.2.3795/src/eval.c 2021-12-12 16:26:35.864627610 +0000 --- src/eval.c 2021-12-13 14:12:08.201660739 +0000 *************** *** 256,262 **** if (s == NULL || *s == NUL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.evaluate = TRUE; if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) return FAIL; } --- 256,262 ---- if (s == NULL || *s == NUL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.fe_evaluate = TRUE; if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) return FAIL; } *************** *** 280,287 **** if (s == NULL || *s == NUL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.evaluate = TRUE; ! funcexe.partial = partial; if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) return FAIL; } --- 280,287 ---- if (s == NULL || *s == NUL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.fe_evaluate = TRUE; ! funcexe.fe_partial = partial; if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) return FAIL; } *************** *** 644,652 **** rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this CLEAR_FIELD(funcexe); ! funcexe.firstline = curwin->w_cursor.lnum; ! funcexe.lastline = curwin->w_cursor.lnum; ! funcexe.evaluate = TRUE; ret = call_func(func, -1, rettv, argc, argv, &funcexe); if (ret == FAIL) clear_tv(rettv); --- 644,652 ---- rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this CLEAR_FIELD(funcexe); ! funcexe.fe_firstline = curwin->w_cursor.lnum; ! funcexe.fe_lastline = curwin->w_cursor.lnum; ! funcexe.fe_evaluate = TRUE; ret = call_func(func, -1, rettv, argc, argv, &funcexe); if (ret == FAIL) clear_tv(rettv); *************** *** 2009,2020 **** // Invoke the function. CLEAR_FIELD(funcexe); ! funcexe.firstline = curwin->w_cursor.lnum; ! funcexe.lastline = curwin->w_cursor.lnum; ! funcexe.evaluate = evaluate; ! funcexe.partial = partial; ! funcexe.basetv = basetv; ! funcexe.check_type = type; funcexe.fe_found_var = found_var; ret = get_func_tv(s, len, rettv, arg, evalarg, &funcexe); } --- 2009,2020 ---- // Invoke the function. CLEAR_FIELD(funcexe); ! funcexe.fe_firstline = curwin->w_cursor.lnum; ! funcexe.fe_lastline = curwin->w_cursor.lnum; ! funcexe.fe_evaluate = evaluate; ! funcexe.fe_partial = partial; ! funcexe.fe_basetv = basetv; ! funcexe.fe_check_type = type; funcexe.fe_found_var = found_var; ret = get_func_tv(s, len, rettv, arg, evalarg, &funcexe); } *************** *** 3805,3816 **** s = (char_u *)""; CLEAR_FIELD(funcexe); ! funcexe.firstline = curwin->w_cursor.lnum; ! funcexe.lastline = curwin->w_cursor.lnum; ! funcexe.evaluate = evaluate; ! funcexe.partial = pt; ! funcexe.selfdict = selfdict; ! funcexe.basetv = basetv; ret = get_func_tv(s, -1, rettv, arg, evalarg, &funcexe); theend: --- 3805,3816 ---- s = (char_u *)""; CLEAR_FIELD(funcexe); ! funcexe.fe_firstline = curwin->w_cursor.lnum; ! funcexe.fe_lastline = curwin->w_cursor.lnum; ! funcexe.fe_evaluate = evaluate; ! funcexe.fe_partial = pt; ! funcexe.fe_selfdict = selfdict; ! funcexe.fe_basetv = basetv; ret = get_func_tv(s, -1, rettv, arg, evalarg, &funcexe); theend: *** ../vim-8.2.3795/src/list.c 2021-12-05 22:19:22.832153464 +0000 --- src/list.c 2021-12-13 14:12:48.273620454 +0000 *************** *** 1935,1943 **** rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this CLEAR_FIELD(funcexe); ! funcexe.evaluate = TRUE; ! funcexe.partial = partial; ! funcexe.selfdict = sortinfo->item_compare_selfdict; res = call_func(func_name, -1, &rettv, 2, argv, &funcexe); clear_tv(&argv[0]); clear_tv(&argv[1]); --- 1935,1943 ---- rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this CLEAR_FIELD(funcexe); ! funcexe.fe_evaluate = TRUE; ! funcexe.fe_partial = partial; ! funcexe.fe_selfdict = sortinfo->item_compare_selfdict; res = call_func(func_name, -1, &rettv, 2, argv, &funcexe); clear_tv(&argv[0]); clear_tv(&argv[1]); *************** *** 3203,3211 **** return; } ! vim_memset(&funcexe, 0, sizeof(funcexe)); ! funcexe.evaluate = TRUE; ! funcexe.partial = partial; if (argvars[0].v_type == VAR_LIST) { --- 3203,3211 ---- return; } ! CLEAR_FIELD(funcexe); ! funcexe.fe_evaluate = TRUE; ! funcexe.fe_partial = partial; if (argvars[0].v_type == VAR_LIST) { *** ../vim-8.2.3795/src/regexp.c 2021-12-05 21:46:31.168891156 +0000 --- src/regexp.c 2021-12-13 14:13:05.285603082 +0000 *************** *** 2033,2040 **** argv[0].vval.v_list = &matchList.sl_list; matchList.sl_list.lv_len = 0; CLEAR_FIELD(funcexe); ! funcexe.argv_func = fill_submatch_list; ! funcexe.evaluate = TRUE; if (expr->v_type == VAR_FUNC) { s = expr->vval.v_string; --- 2033,2040 ---- argv[0].vval.v_list = &matchList.sl_list; matchList.sl_list.lv_len = 0; CLEAR_FIELD(funcexe); ! funcexe.fe_argv_func = fill_submatch_list; ! funcexe.fe_evaluate = TRUE; if (expr->v_type == VAR_FUNC) { s = expr->vval.v_string; *************** *** 2045,2051 **** partial_T *partial = expr->vval.v_partial; s = partial_name(partial); ! funcexe.partial = partial; call_func(s, -1, &rettv, 1, argv, &funcexe); } if (matchList.sl_list.lv_len > 0) --- 2045,2051 ---- partial_T *partial = expr->vval.v_partial; s = partial_name(partial); ! funcexe.fe_partial = partial; call_func(s, -1, &rettv, 1, argv, &funcexe); } if (matchList.sl_list.lv_len > 0) *** ../vim-8.2.3795/src/terminal.c 2021-12-09 10:50:48.566865615 +0000 --- src/terminal.c 2021-12-13 14:13:28.197579274 +0000 *************** *** 4334,4342 **** argvars[0].vval.v_number = term->tl_buffer->b_fnum; argvars[1] = item->li_next->li_tv; CLEAR_FIELD(funcexe); ! funcexe.firstline = 1L; ! funcexe.lastline = 1L; ! funcexe.evaluate = TRUE; if (call_func(func, -1, &rettv, 2, argvars, &funcexe) == OK) { clear_tv(&rettv); --- 4334,4342 ---- argvars[0].vval.v_number = term->tl_buffer->b_fnum; argvars[1] = item->li_next->li_tv; CLEAR_FIELD(funcexe); ! funcexe.fe_firstline = 1L; ! funcexe.fe_lastline = 1L; ! funcexe.fe_evaluate = TRUE; if (call_func(func, -1, &rettv, 2, argvars, &funcexe) == OK) { clear_tv(&rettv); *** ../vim-8.2.3795/src/userfunc.c 2021-12-13 11:31:00.488529501 +0000 --- src/userfunc.c 2021-12-13 14:15:52.445422666 +0000 *************** *** 1696,1703 **** * Get the arguments. */ argp = *arg; ! while (argcount < MAX_FUNC_ARGS - (funcexe->partial == NULL ? 0 ! : funcexe->partial->pt_argc)) { // skip the '(' or ',' and possibly line breaks argp = skipwhite_and_linebreak(argp + 1, evalarg); --- 1696,1703 ---- * Get the arguments. */ argp = *arg; ! while (argcount < MAX_FUNC_ARGS - (funcexe->fe_partial == NULL ? 0 ! : funcexe->fe_partial->pt_argc)) { // skip the '(' or ',' and possibly line breaks argp = skipwhite_and_linebreak(argp + 1, evalarg); *************** *** 2500,2506 **** if (do_profiling == PROF_YES) profile_may_start_func(&profile_info, fp, caller); #endif ! call_def_function(fp, argcount, argvars, funcexe->partial, rettv); funcdepth_decrement(); #ifdef FEAT_PROFILE if (do_profiling == PROF_YES && (fp->uf_profiling --- 2500,2506 ---- if (do_profiling == PROF_YES) profile_may_start_func(&profile_info, fp, caller); #endif ! call_def_function(fp, argcount, argvars, funcexe->fe_partial, rettv); funcdepth_decrement(); #ifdef FEAT_PROFILE if (do_profiling == PROF_YES && (fp->uf_profiling *************** *** 2575,2583 **** if ((fp->uf_flags & FC_NOARGS) == 0) { add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "firstline", ! (varnumber_T)funcexe->firstline); add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "lastline", ! (varnumber_T)funcexe->lastline); } for (i = 0; i < argcount || i < fp->uf_args.ga_len; ++i) { --- 2575,2583 ---- if ((fp->uf_flags & FC_NOARGS) == 0) { add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "firstline", ! (varnumber_T)funcexe->fe_firstline); add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "lastline", ! (varnumber_T)funcexe->fe_lastline); } for (i = 0; i < argcount || i < fp->uf_args.ga_len; ++i) { *************** *** 2870,2877 **** { int error; ! if (fp->uf_flags & FC_RANGE && funcexe->doesrange != NULL) ! *funcexe->doesrange = TRUE; error = check_user_func_argcount(fp, argcount); if (error != FCERR_UNKNOWN) return error; --- 2870,2877 ---- { int error; ! if (fp->uf_flags & FC_RANGE && funcexe->fe_doesrange != NULL) ! *funcexe->fe_doesrange = TRUE; error = check_user_func_argcount(fp, argcount); if (error != FCERR_UNKNOWN) return error; *************** *** 3126,3136 **** funcexe_T funcexe; CLEAR_FIELD(funcexe); ! funcexe.firstline = curwin->w_cursor.lnum; ! funcexe.lastline = curwin->w_cursor.lnum; ! funcexe.evaluate = TRUE; ! funcexe.partial = partial; ! funcexe.selfdict = selfdict; r = call_func(name, -1, rettv, argc, argv, &funcexe); } --- 3126,3136 ---- funcexe_T funcexe; CLEAR_FIELD(funcexe); ! funcexe.fe_firstline = curwin->w_cursor.lnum; ! funcexe.fe_lastline = curwin->w_cursor.lnum; ! funcexe.fe_evaluate = TRUE; ! funcexe.fe_partial = partial; ! funcexe.fe_selfdict = selfdict; r = call_func(name, -1, rettv, argc, argv, &funcexe); } *************** *** 3168,3175 **** if (callback->cb_name == NULL || *callback->cb_name == NUL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.evaluate = TRUE; ! funcexe.partial = callback->cb_partial; ++callback_depth; ret = call_func(callback->cb_name, len, rettv, argcount, argvars, &funcexe); --callback_depth; --- 3168,3175 ---- if (callback->cb_name == NULL || *callback->cb_name == NUL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.fe_evaluate = TRUE; ! funcexe.fe_partial = callback->cb_partial; ++callback_depth; ret = call_func(callback->cb_name, len, rettv, argcount, argvars, &funcexe); --callback_depth; *************** *** 3265,3276 **** char_u *name = NULL; int argcount = argcount_in; typval_T *argvars = argvars_in; ! dict_T *selfdict = funcexe->selfdict; typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" or ! // "funcexe->basetv" is not NULL int argv_clear = 0; int argv_base = 0; ! partial_T *partial = funcexe->partial; type_T check_type; // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) --- 3265,3276 ---- char_u *name = NULL; int argcount = argcount_in; typval_T *argvars = argvars_in; ! dict_T *selfdict = funcexe->fe_selfdict; typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" or ! // "funcexe->fe_basetv" is not NULL int argv_clear = 0; int argv_base = 0; ! partial_T *partial = funcexe->fe_partial; type_T check_type; // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) *************** *** 3290,3297 **** fname = fname_trans_sid(name, fname_buf, &tofree, &error); } ! if (funcexe->doesrange != NULL) ! *funcexe->doesrange = FALSE; if (partial != NULL) { --- 3290,3297 ---- fname = fname_trans_sid(name, fname_buf, &tofree, &error); } ! if (funcexe->fe_doesrange != NULL) ! *funcexe->fe_doesrange = FALSE; if (partial != NULL) { *************** *** 3316,3343 **** argvars = argv; argcount = partial->pt_argc + argcount_in; ! if (funcexe->check_type != NULL ! && funcexe->check_type->tt_argcount != -1) { ! // Now funcexe->check_type is missing the added arguments, make ! // a copy of the type with the correction. ! check_type = *funcexe->check_type; ! funcexe->check_type = &check_type; check_type.tt_argcount += partial->pt_argc; check_type.tt_min_argcount += partial->pt_argc; } } } ! if (error == FCERR_NONE && funcexe->check_type != NULL && funcexe->evaluate) { // Check that the argument types are OK for the types of the funcref. ! if (check_argument_types(funcexe->check_type, argvars, argcount, (name != NULL) ? name : funcname) == FAIL) error = FCERR_OTHER; } ! if (error == FCERR_NONE && funcexe->evaluate) { char_u *rfname = fname; int is_global = FALSE; --- 3316,3344 ---- argvars = argv; argcount = partial->pt_argc + argcount_in; ! if (funcexe->fe_check_type != NULL ! && funcexe->fe_check_type->tt_argcount != -1) { ! // Now funcexe->fe_check_type is missing the added arguments, ! // make a copy of the type with the correction. ! check_type = *funcexe->fe_check_type; ! funcexe->fe_check_type = &check_type; check_type.tt_argcount += partial->pt_argc; check_type.tt_min_argcount += partial->pt_argc; } } } ! if (error == FCERR_NONE && funcexe->fe_check_type != NULL ! && funcexe->fe_evaluate) { // Check that the argument types are OK for the types of the funcref. ! if (check_argument_types(funcexe->fe_check_type, argvars, argcount, (name != NULL) ? name : funcname) == FAIL) error = FCERR_OTHER; } ! if (error == FCERR_NONE && funcexe->fe_evaluate) { char_u *rfname = fname; int is_global = FALSE; *************** *** 3398,3413 **** #endif else if (fp != NULL) { ! if (funcexe->argv_func != NULL) // postponed filling in the arguments, do it now ! argcount = funcexe->argv_func(argcount, argvars, argv_clear, ! fp->uf_args.ga_len); ! if (funcexe->basetv != NULL) { // Method call: base->Method() mch_memmove(&argv[1], argvars, sizeof(typval_T) * argcount); ! argv[0] = *funcexe->basetv; argcount++; argvars = argv; argv_base = 1; --- 3399,3414 ---- #endif else if (fp != NULL) { ! if (funcexe->fe_argv_func != NULL) // postponed filling in the arguments, do it now ! argcount = funcexe->fe_argv_func(argcount, argvars, ! argv_clear, fp->uf_args.ga_len); ! if (funcexe->fe_basetv != NULL) { // Method call: base->Method() mch_memmove(&argv[1], argvars, sizeof(typval_T) * argcount); ! argv[0] = *funcexe->fe_basetv; argcount++; argvars = argv; argv_base = 1; *************** *** 3417,3430 **** funcexe, selfdict); } } ! else if (funcexe->basetv != NULL) { /* * expr->method(): Find the method name in the table, call its * implementation with the base as one of the arguments. */ error = call_internal_method(fname, argcount, argvars, rettv, ! funcexe->basetv); } else { --- 3418,3431 ---- funcexe, selfdict); } } ! else if (funcexe->fe_basetv != NULL) { /* * expr->method(): Find the method name in the table, call its * implementation with the base as one of the arguments. */ error = call_internal_method(fname, argcount, argvars, rettv, ! funcexe->fe_basetv); } else { *************** *** 5098,5110 **** arg = startarg; CLEAR_FIELD(funcexe); ! funcexe.firstline = eap->line1; ! funcexe.lastline = eap->line2; ! funcexe.doesrange = &doesrange; ! funcexe.evaluate = !eap->skip; ! funcexe.partial = partial; ! funcexe.selfdict = fudi.fd_dict; ! funcexe.check_type = type; funcexe.fe_found_var = found_var; rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this if (get_func_tv(name, -1, &rettv, &arg, &evalarg, &funcexe) == FAIL) --- 5099,5111 ---- arg = startarg; CLEAR_FIELD(funcexe); ! funcexe.fe_firstline = eap->line1; ! funcexe.fe_lastline = eap->line2; ! funcexe.fe_doesrange = &doesrange; ! funcexe.fe_evaluate = !eap->skip; ! funcexe.fe_partial = partial; ! funcexe.fe_selfdict = fudi.fd_dict; ! funcexe.fe_check_type = type; funcexe.fe_found_var = found_var; rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this if (get_func_tv(name, -1, &rettv, &arg, &evalarg, &funcexe) == FAIL) *** ../vim-8.2.3795/src/vim9execute.c 2021-12-11 16:13:32.227721221 +0000 --- src/vim9execute.c 2021-12-13 14:16:20.897390558 +0000 *************** *** 876,888 **** if (call_prepare(argcount, argvars, ectx) == FAIL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.evaluate = TRUE; ! funcexe.selfdict = selfdict != NULL ? selfdict : dict_stack_get_dict(); // Call the user function. Result goes in last position on the stack. // TODO: add selfdict if there is one error = call_user_func_check(ufunc, argcount, argvars, ! STACK_TV_BOT(-1), &funcexe, funcexe.selfdict); // Clear the arguments. for (idx = 0; idx < argcount; ++idx) --- 876,888 ---- if (call_prepare(argcount, argvars, ectx) == FAIL) return FAIL; CLEAR_FIELD(funcexe); ! funcexe.fe_evaluate = TRUE; ! funcexe.fe_selfdict = selfdict != NULL ? selfdict : dict_stack_get_dict(); // Call the user function. Result goes in last position on the stack. // TODO: add selfdict if there is one error = call_user_func_check(ufunc, argcount, argvars, ! STACK_TV_BOT(-1), &funcexe, funcexe.fe_selfdict); // Clear the arguments. for (idx = 0; idx < argcount; ++idx) *** ../vim-8.2.3795/src/version.c 2021-12-13 13:11:00.692262343 +0000 --- src/version.c 2021-12-13 14:26:27.180645662 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3796, /**/ -- The startling truth finally became apparent, and it was this: Numbers written on restaurant checks within the confines of restaurants do not follow the same mathematical laws as numbers written on any other pieces of paper in any other parts of the Universe. This single statement took the scientific world by storm. So many mathematical conferences got held in such good restaurants that many of the finest minds of a generation died of obesity and heart failure, and the science of mathematics was put back by years. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// 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 ///