aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
Commit message (Collapse)AuthorAge
...
* | Cleanup: Refactor getdigits().Eliseo Martínez2015-01-11
|/ | | | | | | | | | | | | | | | Problem : getdigits() currently returns a long, but at most places, return value is casted (unsafely) into an int. Making casts safe would introduce a lot of fuss in the form of assertions checking for limits. Note : We cannot just change return type to int, because, at some places, legitimate long values are used. For example, in diff.c, for line numbers. Solution : Introduce new functions: - get_digits() : Gets an intmax_t from a string. - get_int_digits() : Wrapper for ints. - get_long_digits() : Wrapper for longs. And replace getdigits() invocations by the appropiate wrapper invocations.
* Merge pull request #1761 from oni-link/speed.up.gcJustin M. Keyes2015-01-10
|\ | | | | Speed up garbage collection (Issue 1687).
| * Speed up garbage collection.oni-link2014-12-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For garbage collection all lists are kept in first_list, a list of all lists. free_unref_items() searches through first_list and removes unreferenced lists from it (by calling list_free(..., FALSE)). But after a list was removed, the search continues from the beginning of first_list (not sure how many lists were really removed and where to continue in first_list). This is not necessary anymore since vim-patch 7.0.135, because a call to list_free(...,FALSE) makes sure, that no other lists (and dictionaries) are freed. So we always know, that the next list in first_list is still valid (allocated or NULL) and can be used to continue the search. Likewise for dictionaries. Original patch by Ariya Mizutani https://groups.google.com/forum/#!searchin/vim_dev/GC/vim_dev/DBYOdHQWvqY/1WH04_dwETIJ
* | Remove long_u: term: Enable -Wconversion.Eliseo Martínez2015-01-10
| |
* | eval: fix incorrect refcount in list_append_listBjörn Linse2015-01-07
|/
* Merge pull request #1738 from fwalch/vim-7.4.549Justin M. Keyes2014-12-30
|\ | | | | vim-patch:7.4.549
| * vim-patch:7.4.549Florian Walch2014-12-27
| | | | | | | | | | | | | | Problem: Function name not recognized correctly when inside a function. Solution: Don't check for an alpha character. https://code.google.com/p/vim/source/detail?r=v7-4-549
* | vim-patch:7.4.541Florian Walch2014-12-25
|/ | | | | | | Problem: Crash when doing a range assign. Solution: Check for NULL poiter. (Yukihiro Nakadaira) https://code.google.com/p/vim/source/detail?r=v7-4-541
* vim-patch:7.4.516Florian Walch2014-12-24
| | | | | | | | Problem: Completing a function name containing a # does not work. Issue 253. Solution: Recognize the # character. (Christian Brabandt) https://code.google.com/p/vim/source/detail?r=v7-4-516
* vim-patch:7.4.513Florian Walch2014-12-23
| | | | | | | | Problem: Crash because reference count is wrong for list returned by getreg(). Solution: Increment the reference count. (Kimmy Lindvall) https://code.google.com/p/vim/source/detail?r=v7-4-513
* vim-patch:7.4.491Florian Walch2014-12-23
| | | | | | | | Problem: When winrestview() has a negative "topline" value there are display errors. Solution: Correct a negative value to 1. (Hirohito Higashi) https://code.google.com/p/vim/source/detail?r=v7-4-491
* vim-patch:7.4.499Florian Walch2014-12-23
| | | | | | | | Problem: substitute() can be slow with long strings. Solution: Store a pointer to the end, instead of calling strlen() every time. (Ozaki Kiichi) https://code.google.com/p/vim/source/detail?r=v7-4-499
* vim-patch:7.4.311David Rodriguez2014-12-23
| | | | | | | Problem: Can't use winrestview to only restore part of the view. Solution: Handle missing items in the dict. (Christian Brabandt) https://code.google.com/p/vim/source/detail?r=v7-4-311
* Merge pull request #1663 from philix/array_sizeJustin M. Keyes2014-12-19
|\ | | | | Define and use the ARRAY_SIZE macro
| * Define and use the ARRAY_SIZE macroFelipe Oliveira Carvalho2014-12-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A similar macro is defined in the Linux kernel [1]. To refactor the code I used a slightly modified Coccinelle script I found in [2]. ```diff // Use the macro ARRAY_SIZE when possible // // Confidence: High // Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2. // URL: http://www.emn.fr/x-info/coccinelle/rules/array.html // Options: -I ... -all_includes can give more complete results @@ type T; T[] E; @@ - (sizeof(E)/sizeof(*E)) + ARRAY_SIZE(E) @@ type T; T[] E; @@ - (sizeof(E)/sizeof(E[...])) + ARRAY_SIZE(E) @@ type T; T[] E; @@ - (sizeof(E)/sizeof(T)) + ARRAY_SIZE(E) @n@ identifier AS,E; @@ - #define AS(E) ARRAY_SIZE(E) @@ expression E; identifier n.AS; @@ - AS(E) + ARRAY_SIZE(E) ``` `spatch --in-place --sp-file array_size.cocci -I src/ -I build/include/ -I build/src/nvim/auto/ src/nvim/*.c` [1] http://lxr.free-electrons.com/source/include/linux/kernel.h#L54 [2] http://www.emn.fr/z-info/coccinelle/rules/#macros
* | vim-patch:7.4.442Florian Walch2014-12-18
| | | | | | | | | | | | | | Problem: Using unitinialized variable. Solution: Pass the first window of the tabpage. https://code.google.com/p/vim/source/detail?r=v7-4-442
* | vim-patch:7.4.434Florian Walch2014-12-18
|/ | | | | | | | Problem: gettabvar() is not consistent with getwinvar() and getbufvar(). Solution: Return a dict with all variables when the varname is empty. (Yasuhiro Matsumoto) https://code.google.com/p/vim/source/detail?r=v7-4-434
* Reduce indentation level by early returning or continuing loopFelipe Oliveira Carvalho2014-12-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace code like this ```c func() { if (cond) { ... ... ... } return ret; } ``` ```c for (...) { if (cond) { ... ... ... } } ``` with ```c func() { if (!cond) { return ret; } ... ... ... } ``` ```c for (...) { if (!cond) { continue; } ... ... ... } ```
* Merge pull request #1134 from splinterofchaos/getreg-nlJustin M. Keyes2014-12-11
|\ | | | | vim-patch:7.4.242 + vim-patch:7.4.243
| * Attribute/constify get_tv_string(_buf(_chk)).Scott Prager2014-12-11
| |
| * vim-patch:7.4.249Scott Prager2014-12-11
| | | | | | | | | | | | | | Problem: Using setreg() with a list of numbers does not work. Solution: Use a separate buffer for numbers. (ZyX) https://code.google.com/p/vim/source/detail?r=v7-4-249
| * vim-patch:7.4.243Scott Prager2014-12-11
| | | | | | | | | | | | | | Problem: Cannot use setreg() to add text that includes a NUL. Solution: Make setreg() accept a list. https://code.google.com/p/vim/source/detail?r=v7-4-243
| * Return void * from get_reg_contents.Scott Prager2014-12-11
| |
| * vim-patch:7.4.242Scott Prager2014-12-11
| | | | | | | | | | | | | | | | Problem: getreg() does not distinguish between a NL used for a line break and a NL used for a NUL character. Solution: Add another argument to return a list. (ZyX) https://code.google.com/p/vim/source/detail?r=v7-4-242
* | Use GA_DEEP_CLEAR where appropriateFelipe Oliveira Carvalho2014-12-11
|/
* eval_has_provider: search autoload scripts same order as call_funcBjörn Linse2014-12-08
|
* clipboard: support separate '+' and '*' clipboardsBjörn Linse2014-12-08
|
* systemlist: add `keepempty` option to preserve final newlineBjörn Linse2014-12-02
|
* eval: Fix coverity false positive.Scott Prager2014-11-27
| | | | | | | | | | ** CID 74786: Resource leak (RESOURCE_LEAK) /src/nvim/eval.c: 10614 in f_jobsend() /src/nvim/eval.c: 10616 in f_jobsend() save_tv_as_string() should return NULL and input_len <= 0 for an empty string or error. Callers should check that input != NULL instead of input_len > 0 and assert(input == NULL) when the length must be checked.
* ui: Remove redundant ui.h includesThiago de Arruda2014-11-27
| | | | Also move read_error_exit to os/input.c
* ui: Extract mouse.c/mouse.hThiago de Arruda2014-11-27
|
* ui: Remove ui_delay, ui_breakcheck and ui_set_shellsizeThiago de Arruda2014-11-27
| | | | | These functions only used to call another os_* function, so remove them and replace all occurences in the project.
* ui: Remove ui_inchar/ui_char_availThiago de Arruda2014-11-27
| | | | | | | | | Also: - Remove NO_CONSOLE_INPUT/NO_CONSULE preprocessor conditionals - Remove ctrl_c_interrupts variable, check for mapped_ctrl_c directly in process_interrupts() - Move ui_inchar profiling to input_poll which is where Nvim blocks for input.
* Add Boolean argument escape_csi to vim_feedkeysRui Abreu Ferreira2014-11-27
| | | | | | | | | - By default vim_feedkeys escaped all input for CSI/K_SPECIAL bytes before using it. However since vim_replace_termcodes() also escapes the input string chaining these functions together escapes input twice - vim_feedkeys() now takes a third Boolean argument to enable/disable escaping - Breaks API compatibility
* Add missing refcount increment for systemlist()Rui Abreu Ferreira2014-11-25
| | | | | | | - get_system_output_as_rettv() was missing a refcount increment when returning an empty list, i.e. when there was no output - we now use rettv_list_aloc() instead of list_alloc() - issue #1530
* Fix warnings: eval.c: f_rpcrequest(): Garbage value: MI.Eliseo Martínez2014-11-18
| | | | | | | | Problem : Assigned value is garbage or undefined @ 12578. Diagnostic : Multithreading issue. Rationale : Error can only occur if global `provider_call_nesting` is changed while function is executing. Resolution : Use local copy of global.
* Fix warnings: eval.c: do_return(): Np dereference: FP.Eliseo Martínez2014-11-18
| | | | | | | | | | | Problem : Dereference of null pointer @ 18841. Diagnostic : False positive. Rationale : Suggested error path takes `reanimate` branch at 18827, assigning `rettv = current_funccal->rettv`. Then, inmediately after, it supposes rettv is null, which cannot happen, since current_funccal->rettv should always be non null. Resolution : Assert current_funccal->rettv non null.
* Fix warnings: eval.c: add_nr_var(): Out of bounds: FP.Eliseo Martínez2014-11-18
| | | | | | | | | | | | | | Problem : Out-of-bound array access @ 18737. Diagnostic : False positive. Rationale : Situation is intentional. `dictitem_T` is a prefix all dict items whill share, but actual size of each item will be different depending on its key length. `di_key` array field is declared of size 1 just to have a field name, but real size will vary for each item. Resolution : Make analyzer ignore it. This could be refactored to use C99-allowed variable length arrays, but eval.c is bound to dissappear, so no effort is done in that sense.
* Fix warnings: eval.c: call_user_func(): Out of bounds: FP.Eliseo Martínez2014-11-18
| | | | | | | | | | | | | | Problem : Out-of-bound array access @ 18429. Diagnostic : False positive. Rationale : Situation is intentional. `dictitem_T` is a prefix all dict items whill share, but actual size of each item will be different depending on its key length. `di_key` array field is declared of size 1 just to have a field name, but real size will vary for each item. Resolution : Make analyzer ignore it. This could be refactored to use C99-allowed variable length arrays, but eval.c is bound to dissappear, so no effort is done in that sense.
* Fix warnings: eval.c: get_user_func_name(): Np dereference: FP.Eliseo Martínez2014-11-18
| | | | | | | | Problem : Dereference of null pointer @ 18216. Diagnostic : False positive. Rationale : `hi` and `done` are static. Intended usage is for the first call to have idx == 0, so that they are initialized. Resolution : Assert hi after (optional) initialization.
* Fix warnings: eval.c: clear_tv(): Bad free: RI.Eliseo Martínez2014-11-18
| | | | | | | | | | | | | | Problem : Bad free @ 16076. Diagnostic : Real issue. Rationale : A non-allocated string is set at 4127, which later on can be tried to be freed if aborting. Resolution : Detect particular case (func with empty name) and don't free in that case. Another solution (use allocated string) was tried before, but it produced a leak difficult to solve. Finally applied solution works, but it produces a new false positive warning (Np dereference at 13763), deactivated by `assert(ptrs[i].item->li_next)`.
* Fix warnings: eval.c: item_compare(): Garbage value: MI.Eliseo Martínez2014-11-18
| | | | | | | | | | | | | | | | | Problem : Result of operation is garbage or undefined @ 13565. Diagnostic : Multithreading issue. Rationale : Problem occurs only if global (static) variable `item_compare_keep_zero` changes after being used by `do_sort_uniq` but before being used by `item_compare` or `item_compare2`. Resolution : This is not an intra-function problem, as other MI's before, but rather an inter-function one. Thus, it can't be solved by using local copy of global. Therefore, we are forced to do a bit refactoring. We can't simply add a bool param to item_compare/item_compare2, as they couldn't be passed to qsort() that way. So, item_compare/item_compare2 are added a bool param and curried versions of them are added and used in their place.
* Fix warnings: eval.c: dictitem_alloc(): Out-of-bounds access: FP.Eliseo Martínez2014-11-18
| | | | | | | | | | | | | | Problem : Out-of-bound array access @ 5737. Diagnostic : False positive. Rationale : Situation is intentional. `dictitem_T` is a prefix all dict items whill share, but actual size of each item will be different depending on its key length. `di_key` array field is declared of size 1 just to have a field name, but real size will vary for each item. Resolution : Make analyzer ignore it. This could be refactored to use C99-allowed variable length arrays, but eval.c is bound to dissappear, so no effort is done in that sense.
* Fix warnings: eval.c: set_var_lval(): Np dereference: FP.Eliseo Martínez2014-11-18
| | | | | | | | | | | | | | | | | | | Problem : Dereference of null pointer @ 2273. Diagnostic : False positive. Rationale : Suggested error would happen when assigning an rvalue with more items than the lvalue. Then we would enter conditional at: ``` if (lp->ll_li->li_next == NULL) { /* Need to add an empty item. */ list_append_number(lp->ll_list, 0); } lp->ll_li = lp->ll_li->li_next; ``` Analyzer thinks the value assigned to lp->ll_li is still NULL and is hit on the next iteration. Resolution : Assert lp->ll_li->li_next is not null anymore after list_append_number().
* Remove os/provider.{c,h} and all of its referencesThiago de Arruda2014-11-18
|
* eval/ex_cmds2/ops: Implement providers with eval_call_providerThiago de Arruda2014-11-18
| | | | | Replace references to provider_call/provider_has with the new functions eval_call_provider/eval_has_provider.
* eval: Add eval_call_provider/eval_has_provider functionsThiago de Arruda2014-11-18
| | | | | | | | | | | These use autoloaded vimscript to replace the provider_call/provider_has functions, moving the implementation of providers to pure vimscript(we lose nothing since vimscript can also call msgpack-rpc functions). When calling the rpcrequest function from a provider, temporarily switch to the caller scope. This is required for compatibility with legacy plugins, because they may depend on scope information that changes when "leaving" the C stack to enter the vimscript stack.
* Merge pull request #1471 from splinterofchaos/fix-jobstartJustin M. Keyes2014-11-15
|\ | | | | jobstart: Check prg arguments for NULL.
| * jobstart: Check prg arguments for NULL.Scott Prager2014-11-13
| |
* | vim-patch:7.4.419Scott Prager2014-11-11
|/ | | | | | | | Problem: Whan part of a list is locked it's possible to make changes. Solution: Check if any of the list items is locked before make a change. (ZyX) https://code.google.com/p/vim/source/detail?r=v7-4-419