aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/userfunc.c
Commit message (Collapse)AuthorAge
* Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahmJosh Rahm2025-02-05
|\
| * vim-patch:9.1.1074: Strange error when heredoc marker starts with "trim" ↵zeertzjq2025-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#32317) Problem: Strange error when heredoc marker starts with "trim". Solution: Check for whitespace after "trim" or "eval" (zeertzjq) For :python3 etc., a heredoc marker that starts with a lower-case letter is valid, and when it starts with "trim" it works in a script but not in a function, and this PR makes it works in a function. For :let, a heredoc marker that starts with a lower-case letter is not valid, but when it starts with "trim" or "eval" the error can be a bit confusing in a function, and this PR make it less confusing. closes: vim/vim#16574 https://github.com/vim/vim/commit/449c2e5454735fe1cfc8c21b2c6880d6bdf4cd6e
| * vim-patch:9.0.1391: "clear" macros are not always used (#32312)zeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | Problem: "clear" macros are not always used. Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more places. (Yegappan Lakshmanan, closes vim/vim#12104) https://github.com/vim/vim/commit/960dcbd098c761dd623bec9492d5391ff6e8dceb Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
| * vim-patch:8.2.4948: cannot use Perl heredoc in nested :def function (#32311)zeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | Problem: Cannot use Perl heredoc in nested :def function. (Virginia Senioria) Solution: Only concatenate heredoc lines when not in a nested function. (closes vim/vim#10415) https://github.com/vim/vim/commit/d881d1598467d88808bafd2fa86982ebbca7dcc1 Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:9.1.1071: args missing after failing to redefine a functionzeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | | | | | Problem: Arguments of a function are missing after failing to redefine it (after 8.2.2505), and heap-use-after-free with script-local function (after 9.1.1063). Solution: Don't clear arguments or free uf_name_exp when failing to redefine an existing function (zeertzjq) closes: vim/vim#16567 https://github.com/vim/vim/commit/04d2a3fdc051d6a419dc0ea4de7a9640cefccd31
| * vim-patch:9.1.1066: heap-use-after-free and stack-use-after-scope with ↵zeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | :14verbose Problem: heap-use-after-free and stack-use-after-scope with :14verbose when using :return and :try (after 9.1.1063). Solution: Move back the vim_free(tofree) and the scope of numbuf[]. (zeertzjq) closes: vim/vim#16563 https://github.com/vim/vim/commit/2101230f4013860dbafcb0cab3f4e6bc92fb6f35
| * vim-patch:9.1.1063: too many strlen() calls in userfunc.czeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: too many strlen() calls in userfunc.c Solution: refactor userfunc.c and remove calls to strlen(), drop set_ufunc_name() and roll it into alloc_ufunc(), check for out-of-memory condition in trans_function_name_ext() (John Marriott) closes: vim/vim#16537 https://github.com/vim/vim/commit/b32800f7c51c866dc0e87244eb4902540982309d Add missing change to call_user_func() from patch 8.1.1007. Consistently use PRIdSCID instead of PRId64 for script IDs. Co-authored-by: John Marriott <basilisk@internode.on.net>
| * vim-patch:9.0.1142: crash and/or memory leak when redefining functionzeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | Problem: Crash and/or memory leak when redefining function after error. Solution: Clear pointer after making a copy. Clear arrays on failure. (closes vim/vim#11774) https://github.com/vim/vim/commit/f057171d8b562c72334fd7c15c89ff787358ce3a Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:8.2.2505: Vim9: crash after defining function with invalid return typezeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | | | Problem: Vim9: crash after defining function with invalid return type. Solution: Clear function growarrays. Fix memory leak. https://github.com/vim/vim/commit/31842cd0772b557eb9584a13740430db29de8a51 Cherry-pick free_fp from patch 8.2.3812. Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:8.2.1445: Vim9: function expanded name is cleared when sourcing againzeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | | | | | Problem: Vim9: function expanded name is cleared when sourcing a script again. Solution: Only clear the expanded name when deleting the function. (closes vim/vim#6707) https://github.com/vim/vim/commit/c4ce36d48698669f81ec90f7c9dc9ab8c362e538 Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:8.2.0825: def_function() may return pointer that was freedzeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | Problem: def_function() may return pointer that was freed. Solution: Set "fp" to NULL after freeing it. https://github.com/vim/vim/commit/a14e6975478adeddcc2161edc1ec611016aa89f3 Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch: port some userfunc.c refactorings from Vim (#32292)zeertzjq2025-02-02
| | | | | | | | | | | | | | | | | | | | | | | | Port one_function_arg() and get_function_body() from Vim. vim-patch:8.2.2865: skipping over function body fails Problem: Skipping over function body fails. Solution: Do not define the function when skipping. https://github.com/vim/vim/commit/d87c21a918d8d611750f22d68fc638bf7a79b1d5 Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:9.1.1013: Vim9: Regression caused by patch v9.1.0646zeertzjq2025-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Vim9: Regression caused by patch v9.1.0646 Solution: Translate the function name before invoking it in call() (Yegappan Lakshmanan) fixes: vim/vim#16430 closes: vim/vim#16445 https://github.com/vim/vim/commit/6289f9159102e0855bedc566636b5e7ca6ced72c N/A patch: vim-patch:8.2.4176: Vim9: cannot use imported function with call() Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* | Merge remote-tracking branch 'upstream/master' into mix_20240309Josh Rahm2024-11-19
|\|
| * refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
| * fix(eval): handle wrong v:lua in expr option properly (#29953)zeertzjq2024-08-02
| |
| * refactor(eval): treat v:lua call as simple functionzeertzjq2024-08-02
| |
| * vim-patch:9.1.0649: Wrong comment for "len" argument of call_simple_func()zeertzjq2024-08-02
| | | | | | | | | | | | | | | | | | | | Problem: Wrong comment for "len" argument of call_simple_func(). Solution: Remove the "or -1 to use strlen()". Also change its type to size_t to remove one cast. (zeertzjq) closes: vim/vim#15410 https://github.com/vim/vim/commit/c1ed788c1b41db9b5f1ef548dc877f771f535bbe
| * vim-patch:9.0.0632: calling a function from an "expr" option has overheadzeertzjq2024-08-02
| | | | | | | | | | | | | | | | | | | | | | | | Problem: Calling a function from an "expr" option has too much overhead. Solution: Add call_simple_func() and use it for 'foldexpr' https://github.com/vim/vim/commit/87b4e5c5db9d1cfd6f2e79656e1a6cff3c69d15f Cherry-pick a call_func() change from patch 8.2.1343. Add expr-option-function docs to options.txt. Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:8.2.4416: Vim9: using a script-local function requires using "s:" ↵zeertzjq2024-08-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#29950) Problem: Vim9: using a script-local function requires using "s:" when setting 'completefunc'. Solution: Do not require "s:" in Vim9 script. (closes vim/vim#9796) https://github.com/vim/vim/commit/1fca5f3e86f08e696058fc7e86dfe41b415a78e6 vim-patch:8.2.4417: using NULL pointer Problem: Using NULL pointer. Solution: Set offset after checking for NULL pointer. https://github.com/vim/vim/commit/e89bfd212b21c227f026e467f882c62cdd6e642d Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * vim-patch:9.1.0547: No way to get the arity of a Vim function (#29638)zeertzjq2024-07-10
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: No way to get the arity of a Vim function (Austin Ziegler) Solution: Enhance get() Vim script function to return the function argument info using get(func, "arity") (LemonBoy) fixes: vim/vim#15097 closes: vim/vim#15109 https://github.com/vim/vim/commit/48b7d05a4f88c4326bd5d7a73a523f2d953b3e51 Co-authored-by: LemonBoy <thatlemon@gmail.com>
| * refactor(memory): use builtin strcat() instead of STRCAT()bfredl2024-06-11
| | | | | | | | | | | | | | | | The latter was mostly relevant with the past char_u madness. NOTE: STRCAT also functioned as a counterfeit "NOLINT" for clint apparently. But NOLINT-ing every usecase is just the same as disabling the check entirely.
| * refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
| |
* | Merge remote-tracking branch 'upstream/master' into mix_20240309Josh Rahm2024-05-24
|\|
| * docs: various fixes (#28208)dundargoc2024-04-30
| | | | | | | | | | | | | | | | | | | | Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Famiu Haque <famiuhaque@proton.me> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Guilherme Soares <guilhermesoares1970@gmail.com> Co-authored-by: Jannik Buhr <jannik.m.buhr@gmail.com> Co-authored-by: thomaswuhoileong <72001875+thomaswuhoileong@users.noreply.github.com> Co-authored-by: tom-anders <13141438+tom-anders@users.noreply.github.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
| * refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq2024-04-20
| | | | | | | | | | | | Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
| * vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308)zeertzjq2024-04-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: POSIX function name in exarg struct causes issues on OpenVMS Solution: Rename getline member in exarg struct to ea_getline, remove isinf() workaround for VMS There are compilers that do not treat well POSIX functions - like getline - usage in the structs. Older VMS compilers could digest this... but the newer OpenVMS compilers ( like VSI C x86-64 X7.4-843 (GEM 50XB9) ) cannot deal with these structs. This could be limited to getline() that is defined via getdelim() and might not affect all POSIX functions in general - but avoiding POSIX function names usage in the structs is a "safe side" practice without compromising the functionality or the code readability. The previous OpenVMS X86 port used a workaround limiting the compiler capabilities using __CRTL_VER_OVERRIDE=80400000 In order to make the OpenVMS port future proof, this pull request proposes a possible solution. closes: vim/vim#13704 https://github.com/vim/vim/commit/6fdb6280821a822768df5689a5d727e37d38306c Co-authored-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com>
| * vim-patch:9.1.0301: Vim9: heredoc start may be recognized in string (#28266)zeertzjq2024-04-11
| | | | | | | | | | | | | | | | | | Problem: Vim9: heredoc start may be recognized in string. Solution: Don't skip to closing bracket for invalid list assignment. (zeertzjq) closes: vim/vim#14472 https://github.com/vim/vim/commit/1817ccdb107ceeaf5c48fe193da5146682c15ca6
| * vim-patch:9.1.0287: Vim9: comment may be treated as heredoc start (#28257)zeertzjq2024-04-10
| | | | | | | | | | | | | | | | | | | | | | Problem: Vim9: comment may be treated as heredoc start. (Ernie Rael) Solution: Use skip_var_list() instead of find_name_end(). (zeertzjq) fixes: vim/vim#14444 closes: vim/vim#14446 https://github.com/vim/vim/commit/9a91d2b72c20f213bbf77f27b7edd01e0e43d5e0
| * vim-patch:9.1.0182: Can define function with invalid name inside ↵zeertzjq2024-03-16
| | | | | | | | | | | | | | | | | | | | | | 'formatexpr' (#27883) Problem: Can define function with invalid name inside 'formatexpr'. Solution: Use goto instead of checking for did_emsg later. (zeertzjq) closes: vim/vim#14209 https://github.com/vim/vim/commit/6a04bf5ee523b2d6d01d7290e356a30de219f465
| * vim-patch:8.2.3782: Vim9: no error if a function shadows a script variable ↵zeertzjq2024-03-16
| | | | | | | | | | | | | | | | | | | | | | | | (#27881) Problem: Vim9: no error if a function shadows a script variable. Solution: Check the function doesn't shadow a variable. (closes vim/vim#9310) https://github.com/vim/vim/commit/052ff291d72bc9c176f9562f021d7e8e030e74c0 Omit EVAL_VAR_NO_FUNC: Vim9 script only. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* | Merge remote-tracking branch 'origin/fix_repeatcmdline' into mix_20240309mix_20240309Josh Rahm2024-03-09
|\ \ | |/ |/|
| * Change from char_u to charfix_repeatcmdlineJosh Rahm2023-11-29
| |
| * Merge remote-tracking branch 'upstream/master' into fix_repeatcmdlineJosh Rahm2023-11-29
| |\
| * \ Merge remote-tracking branch 'upstream/master' into fix_repeatcmdlineJosh Rahm2023-01-25
| |\ \
| * | | eval/userfunc.c: save the repeat_cmdline along with the redo buffJosh Rahm2022-09-15
| | | | | | | | | | | | | | | | | | | | | | | | A user function can clobber the repeat_cmdline, which is used to build the redo buffer, thus, if the redo buffer is saved when calling a userfunc, so should the repeat_cmdline.
* | | | refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | | | | | | | | | | | | | | | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* | | | refactor: follow style guidedundargoc2023-12-30
| | | |
* | | | refactor: follow style guidedundargoc2023-12-24
| | | |
* | | | refactor: eliminate cyclic includesdundargoc2023-12-20
| | | |
* | | | refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
| | | |
* | | | docs: add style rule regarding initializationdundargoc2023-12-18
| | | | | | | | | | | | | | | | | | | | Specifically, specify that each initialization should be done on a separate line.
* | | | vim-patch:8.1.1583: set_ref_in_list() only sets ref in items (#26418)zeertzjq2023-12-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Set_ref_in_list() only sets ref in items. Solution: Rename to set_ref_in_list_items() to avoid confusion. https://github.com/vim/vim/commit/7be3ab25891fec711d8a2d9d242711a9155852b6 Omit set_ref_in_list() and set_ref_in_dict(): only used in popup window, if_pyth and if_lua. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* | | | build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| |_|/ |/| | | | | | | | | | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* | | refactor: fix headers with IWYUdundargoc2023-11-28
| | |
* | | refactor: move hashtab types to hashtab_defs.h (#26262)zeertzjq2023-11-28
| | |
* | | refactor: rename types.h to types_defs.hdundargoc2023-11-27
| | |
* | | build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
| | |
* | | refactor: move Arena and ArenaMem to memory_defs.h (#26240)zeertzjq2023-11-27
| | |
* | | refactor: move garray_T to garray_defs.h (#26227)zeertzjq2023-11-26
| | |