aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
Commit message (Collapse)AuthorAge
...
* Fix warnings: ex_getln.c: init_history(): Nonnull attr passed null: HI.Eliseo Martínez2015-04-27
| | | | | | | | | | | Problem : Argument with 'nonnull' attribute passed null @ 4227. Diagnostic : Harmless issue. Rationale : It's true we're calling memset with NULL pointer, but it's also true we're doing it with zero size. We just thought that would work and do nothing (it was a way of avoiding to add a guard). It doesn't work, though, as memset requires nonnull arguments. Resolution : Add guard to avoid null argument.
* ex_getln: Fixes for some problems with getexmodeline()oni-link2015-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problems with line-input editing commands in Ex mode ('nvim -e' or 'Q' in normal mode): CTRL_U: Only after the next keystroke the complete line change is shown if the indentation was not 0. : asdfCTRL_U CTRL_T: Memory reallocation with ga_grows() before a memmove(), but pointers into the memory are not updated. :set sw=40 :CTRL_T ... Should complain about a memory error. CTRL_D: Trying to reduce an indentation of 0. :set sw=1 :CTRL_D Segfault Helped-by: Scott Prager <splinterofchaos@gmail.com>
* Replace vim_isspace() with ascii_isspace() defined in ascii.hFelipe Oliveira Carvalho2015-04-24
|
* Replace VIM_ISDIGIT() and vim_isdigit() with ascii_isdigit() defined in ascii.hFelipe Oliveira Carvalho2015-04-24
|
* Merge #2491: Fix xfree of static value from vim_getenv() refactor.Eliseo Martínez2015-04-23
|\ | | | | | | Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
| * Fix xfree of static value in expand_shellcmd()Mark Bainter2015-04-23
| | | | | | | | | | | | | | | | The refactoring of vim_getenv() to remove the mustfree arg included reworking calling functions. expand_shellcmd was also using that to track its usage of the variable within the function, resulting in #2487. This change addresses that scenario and cleans up some of the function for style.
* | Fix warnings: ex_getln.c: init_history(): NP dereference: FP.Eliseo Martínez2015-04-23
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem : Dereference of null pointer @ 4199. Diagnostic : False positive. Rationale : Suggested error path implies that newlen == 0 and newlen > hislen, which implies hislen < 0, which is impossible (hislen is always between 0 and 10000). Resolution : Refactor code. Asserting oldlen >= 0 should have sufficed, but for some reason analyzer doesn't follow implications in that case. Asserting newlen != 0 || newlen <= hislen works. But the chance has been taken to do extensive refactoring of this function, as it was difficult to understand as it was. As a result of refactoring, assert is not needed anymore, as we don't call clear_hist_entry() in refactored version. Refactor : - Rework algorithm: * Drop guard for OOM case, which can't happen now. * Drop empty/growing/shrinking cases. Simplify to always doing the same. * Perform circular array reordering in all cases (before, it only did when shrinking). * Work in batches through memcpy/memset, instead of one entry at a time, as it did before. - Inline variable declarations. - Replace `ssize_t` by `int`. - Introduce oldlen as entry value of hislen. - Add a lot of comments. Helped-by: Scott Prager <splinterofchaos@gmail.com> Helped-by: oni-link <knil.ino@gmail.com>
* Merge #2418: Remove char_u (4)Eliseo Martínez2015-04-19
|\ | | | | | | | | | | Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com> Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
| * Refactor get_env() to respect const qualifierMark Bainter2015-04-18
| | | | | | | | | | | | Without the casts*, the compiler rightly warns about the os_getenv losing the qualifier. This refactor adds a variable to manage this properly, and renames the original variables to increase clarity.
| * Remove char_u: vim_getenv()Mark Bainter2015-04-17
| |
* | clipboard: cleanup `valid_yank_reg` and use it for `:redir`Björn Linse2015-04-17
|/ | | | | | | This fixes missing clipboard support for `:redir` Helped-By: Michael Reed <m.reed@mykolab.com> Helped-By: Scott Prager <splinterofchaos@gmail.com>
* memory: Add `free` wrapper and refactor project to use itThiago de Arruda2015-04-13
| | | | | | We already use wrappers for allocation, the new `xfree` function is the equivalent for deallocation and provides a way to fully replace the malloc implementation used by Neovim.
* Enable -Wconversion: fold.c.Eliseo Martínez2015-04-07
| | | | | | | | | | | | Refactor summary: - foldinfo_T.fi_lnum: int --> linenr_T Reorder field for optimal packing. - foldAddMarker(..., markerlen): int --> size_t * foldstartmarkerlen: int --> size_t - foldDelMarker(..., markerlen): int --> size_t * foldendmarkerlen: int --> size_t Helped-by: oni-link <knil.ino@gmail.com>
* Fix problem with coverity/105568 fix.oni-link2015-04-05
| | | | | | | | | | | | | | | The original fix 3db0a40d691c103a26ef3df74528f12d89b0fa61 does not work for more than one loop iteration, because memory allocated in the previous iteration could be reused in the current iteration. Because expand_wildcards() never reads the variables *num_file and *file before the first assignment to them, the initial values for these variables can be anything. So instead of calling expand_shellcmd() with *file = "" we set *file = NULL. That should help coverity see, that not a array-typed value is freed. Helped-by: Eliseo Martínez <eliseomarmol@gmail.com>
* Update comments for expand_wildcards functions.oni-link2015-04-05
| | | | | | | | | | | | | | | | | Be more specific in the description of mch_expand_wildcards(): This function will never free memory pointed to by its arguments. If OK is returned, *file will always point to allocated memory. *num_file is set to the number of pointers in *file. If FAIL is returned *file is set to NULL and *num_file to 0. If gen_expand_wildcards() returns FAIL, no memory allocation in this function needs to be undone. If expand_wildcards() returns FAIL, no memory allocation in this function needs to be undone. Helped-by: Eliseo Martínez <eliseomarmol@gmail.com> Helped-by: Michael Reed <m.reed@mykolab.com>
* vim-patch:7.4.324David Bürgin2015-03-30
| | | | | | | Problem: In Ex mode, cyrillic characters are not handled. (Stas Malavin) Solution: Support multi-byte characters in Ex mode. (Yukihiro Nakadaira) https://github.com/vim/vim/releases/tag/v7-4-324
* refactor: split some more functions from misc1.cbobtwinkles2015-03-24
| | | | | | | | | | | This commit pulls the some environment-variable handling functions out of misc1.c and in to os/env.c. Previously submited as #1231, this is the start of a patch series that does that work based on a more up-to-date master branch. Major tasks accomplished: - move functions and fix includes - fix clint/clang analysis warnings - correct documentation comments
* coverity/105568: Free of array-typed value: FP.Eliseo Martínez2015-03-22
| | | | | | | | | | | | | | Problem : Free of array-typed value @ 3628. Diagnostic : False positive. Rationale : expand_shell_cmd() is called with a mock value for file (*file = (char_u **)""). That means we want file to be filled with a new value. We can't use *file = NULL because that means we don't want file to be filled. Now, coverity incorrectly thinks that sentinel value is the one we are freeing up at some other later point, which is not the case. Resolution : Assert that, when we are freeing *file, its value is different than the sentinel one.
* ui: Refactor so that busy state won't be the defaultThiago de Arruda2015-03-18
| | | | | | | | | | | Even though assuming nvim is busy most times is simpler, it has a problem: A lot of unnecessary busy_start/busy_stop notifications are sent to the UI. That's because in the majority of scenarios almost no time is spent between `event_poll` calls. This restores the normal behavior which is to call busy_start only when nvim is going to perform some task that can take a significant amount of time. Also improve the usage of buffering in the TUI when changing the cursor state.
* ui: Replace cursor_{on,off} by busy_{stop,start}Thiago de Arruda2015-03-15
| | | | | | | | | | | | | | | | | | | | | | | | Switching cursor off is only necessary in two occasions: - When redrawing to avoid terminal flickering - When the editor is busy The first can now be handled by the TUI, so most calls to ui_cursor_off can be removed from the core. So, before this commit it was only necessary to switch the cursor off to notify the user that nvim was running some long operation. Now the cursor_{on,off} functions have been replaced by busy_{stop,start} which can be handled in a UI-specific way(turning the cursor off or showing a busy indicator, for example). To make things even more simpler, nvim is always busy except when waiting for user input or other asynchronous events: It automatically switches to a non-busy state when the event loop is about to be entered for more than 100 milliseconds. `ui_busy_start` can be called when its not desired to change the busy state in the event loop (As its now done by functions that perform blocking shell invocations).
* Macro cleanup: USE_ON_FLY_SCROLLMichael Reed2015-03-05
|
* refactor: Remove term modules and termcap optionsThiago de Arruda2015-02-21
| | | | | | | | | | | | | | | - Removed term.c, term.h and term_defs.h - Tests for T_* values were removed. screen.c was simplified as a consequence(the best strategy for drawing is implemented in the UI layer) - Redraw functions now call ui.c functions directly. Updates are flushed with `ui_flush()` - Removed all termcap options(they now return empty strings for compatibility) - &term/&ttybuiltin options return a constant value(nvim) - &t_Co is still available, but it mirrors t_colors directly - Remove cursor tracking from screen.c and the `screen_start` function. Now the UI is expected to maintain cursor state across any call, and reset it when resized. - Remove unused code
* ui: Remove/adapt some old code for a big UI refactorThiago de Arruda2015-02-16
| | | | | | | | | | | | | - Remove abstract_ui global, now it is always active - Remove some terminal handling code - Remove unused functions - Remove HAVE_TGETENT/TERMINFO/TERMIOS/IOCTL #ifdefs - Remove tgetent/terminfo from version.c - Remove curses/terminfo dependencies - Only start/stop termcap when starting/exiting the program - msg_use_printf will return true if there are no attached UIs( messages will be written to stdout) - Remove `ex_winpos`(implement `:winpos` with `ex_ni`)
* FEAT_SIGNS: restore :signs wildmenu, and add test.Justin M. Keyes2015-02-15
|
* Remove nonnullret deadcode: home_replace_save.Eliseo Martínez2015-01-27
|
* Remove nonnullret deadcode: addstar.Eliseo Martínez2015-01-27
|
* Remove nonnullret deadcode: Mark new nonnullret functions.Eliseo Martínez2015-01-27
|
* Macro cleanup: PROTOMichael Reed2015-01-14
| | | | | | Regarding dict_lookup() in eval.c: both definitions are the same, the only difference being the spacing between the indirection operator and the indentation level.
* vim-patch:7.4.441Florian Walch2014-12-23
| | | | | | | | Problem: Endless loop and other problems when 'cedit' is set to CTRL-C. Solution: Do not call ex_window() when ex_normal_busy or got_int was set. (Yasuhiro Matsumoto) https://code.google.com/p/vim/source/detail?r=v7-4-441
* 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
* strings.c: replace copy_spaces, copy_chars with equivalent memset.Daniel Fairhead2014-12-12
|
* ui: Add abstract_ui termcap and split UI layerThiago de Arruda2014-12-08
| | | | | | | | | | | | | | | | | | This is how Nvim behaves when the "abstract_ui" termcap is activated: - No data is written/read to stdout/stdin by default. - Instead of sending data to stdout, ui_write will parse the termcap codes and invoke dispatch functions in the ui.c module. - The dispatch functions will forward the calls to all attached UI instances(each UI instance is an implementation of the UI layer and is registered with ui_attach). - Like with the "builtin_gui" termcap, "abstract_ui" does not contain any key sequences. Instead, vim key strings(<cr>, <esc>, etc) are parsed directly by input_enqueue and the translated strings are pushed to the input buffer. With this new input model, its not possible to send mouse events yet. Thats because mouse sequence parsing happens in term.c/check_termcodes which must return early when "abstract_ui" is activated.
* term: Move more mouse functions to mouse.cThiago de Arruda2014-12-02
|
* term: Remove most calls to settmodeThiago de Arruda2014-12-02
| | | | | | Nvim now relies much less on setting terminal mode to cooked mode, remove most calls to settmode, except for those that happen on startup or when suspending. Eventually even those will be handled by the UI layer.
* Remove code defined under USE_IM_CONTROL #ifdefsThiago de Arruda2014-11-27
| | | | This is not being used and should not be part of the core anyway.
* 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.
* event: No longer process K_EVENT automaticallyThiago de Arruda2014-11-21
| | | | | | | Two new functions, `event_enable_deferred()`/`event_disable_deferred()` have to be called by code that is capable of handling asynchronicity. User-dialog states like "press ENTER to continue" or the swap file confirmation no longer will generate K_EVENT.
* Fix warnings: ex_getln.c: init_history(): Double free: FP.Eliseo Martínez2014-11-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem : Double free @ 4249. Diagnostic : False positive. Rationale : Codepath leading to error contains two consecutive iterations in which `if (--j < 0)` is true. That executes `free` two consecutive times with the same value (hislen - 1) for j, with leads to double free. Now, that can only happen with j == 0 && hislen == 1. And that would imply j == hisidx[type] too, which would take the following break. So, the error codepath cannot really happen, but the compiler cannot deduce the last implication. Resolution : We have two possible solutions for this: 1.- Comparing value of j before and after updating it, and breaking out of iteration if equal. That changes nothing in functionality, but teaches the compiler his proposed error codepath is impossible. 2.- Nullify pointer after freeing. This way, the compiler still thinks his error codepath is possible, but it's not an error anymore, as free(NULL) is a no-op. We opt for solution 2, as solution 1 requires adding logic that adds nothing (and having to explain that clearly in aside comments) just for the purpose of silencing warning. On the other hand, solution 2 improves the code, adding something considered good practice in any case, and therefore doesn't require further explanation.
* vim-patch:7.4.410Shougo Matsushita2014-09-19
| | | | | | | | Problem: Fold does not open after search when there is a CmdwinLeave autocommand. Solution: Restore KeyTyped. (Jacob Niehus) https://code.google.com/p/vim/source/detail?r=v7-4-410
* vim-patch:7.4.337André Twupack2014-09-10
| | | | | | | | Problem: When there is an error preparing to edit the command line, the command won't be executed. (Hirohito Higashi) Solution: Reset did_emsg before editing. https://code.google.com/p/vim/source/detail?r=v7-4-337
* api: Implement '--embedded-mode' command-line optionThiago de Arruda2014-08-28
| | | | | This option makes nvim run in "embedded mode", which creates an API channel via stdin/stdout and disables all terminal-related code
* Port vim's patch 7.4.338 ('breakindent')Felipe Morales2014-08-20
|
* vim-patch:7.4.279Scott Prager2014-08-04
| | | | | | | | Problem: globpath() returns a string, making it difficult to get a list of matches. (Greg Novack) Solution: Add an optional argument like with glob(). (Adnan Zafar) https://code.google.com/p/vim/source/detail?r=8e9db1f27a0063df023cc05a760fce73255dad24
* events: Refactor how event deferral is handledThiago de Arruda2014-07-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove all *_set_defer methods and the 'defer' flag from rstream/jobs - Added {signal,rstream,job}_event_source functions. Each return a pointer that represent the event source for the object in question(For signals, a static pointer is returned) - Added a 'source' field to the Event struct, which is set to the appropriate value by the code that created the event. - Added a 'sources' parameter to `event_poll`. It should point to a NULL-terminated array of event sources that will be used to decide which events should be processed immediately - Added a 'source_override' parameter to `rstream_new`. This was required to use jobs as event sources of RStream instances(When "focusing" on a job, for example). - Extracted `process_from` static function from `event_process`. - Remove 'defer' parameter from `event_process`, which now operates only on deferred events. - Refactor `channel_send_call` to use the new lock mechanism What changed in a single sentence: Code that calls `event_poll` have to specify which event sources should NOT be deferred. This change was necessary for a number of reasons: - To fix a bug where due to race conditions, a client request could end in the deferred queue in the middle of a `channel_send_call` invocation, resulting in a deadlock since the client process would never receive a response, and channel_send_call would never return because the client would still be waiting for the response. - To handle "event locking" correctly in recursive `channel_send_call` invocations when the frames are waiting for responses from different clients. Not much of an issue now since there's only a python client, but could break things later. - To simplify the process of implementing synchronous functions that depend on asynchronous events.
* profiling: implement on top of os_hrtime()Nicolas Hillegeer2014-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | Should be better than gettimeofday() since libuv uses higher resolution clocks on most UNIX platforms. Libuv also tries to use monotonic clocks, kernel bugs notwithstanding, which is another win over gettimeofday(). Necessary for Windows, which doesn't have gettimeofday(). In vanilla vim, Windows uses QueryPerformanceCounter, which is the correct primitive for this sort of things, but that was removed when slimming up the codebase. Libuv uses QueryPerformanceCounter to implement uv_hrtime() on Windows so the behaviour of vim profiling on Windows should now be the same. The behaviour on Linux should be different (better) though, libuv uses more accurate primitives than gettimeofday(). Other misc. changes: - Added function attributes where relevant (const, pure, ...) - Convert functions to receive scalars: Now that proftime_T is always a (uint64_t) scalar (and not a struct), it's clearer to convert the functions to receive it as such instead of a pointer to a scalar. - Extract profiling funcs to profile.c: make everything clearer and reduces the size of the "catch-all" ex_cmds2.c - Add profile.{c,h} to clint and -Wconv: - Don't use sprintf, use snprintf - Don't use long, use int16_t/int32_t/...
* Use strict function prototypes #945Pavel Platto2014-07-14
| | | | | | | | | | | | | | | | | | | `-Wstrict-prototypes` warn if a function is declared or defined without specifying the argument types. This warning disallow function prototypes with empty parameter list. In C, a function declared with an empty parameter list accepts an arbitrary number of arguments when being called. This is for historic reasons; originally, C functions didn't have prototypes, as C evolved from B, a typeless language. When prototypes were added, the original typeless declarations were left in the language for backwards compatibility. Instead we should provide `void` in argument list to state that function doesn't have arguments. Also this warning disallow declaring type of the parameters after the parentheses because Neovim header generator produce no declarations for old-stlyle prototypes: it expects to find `{` after prototype.
* move defines from vim.hBrandon Coleman2014-07-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | buffer.h: buflist_getfile() flags buflist_new() flags buf_freeall() flags do_buffer() flags charset.h: chartab[] flags edit.h: in_cinkeys() flags change_indent() flags beginline() flags insertchar() flags nv_mousescroll() flags eval.c AUTOLOAD_CHAR eval.h: enum for vimvars[] ex_cmds.h: do_ecmd read_viminfo flags ex_cmds2.h: check_changed() flags do_source() flags ex_cmds_defs.h: BAD_* flags ex_docmd.h: VALID_PATH VALID_HEAD EXMODE_* do_cmdline() flags added include ex_getln.c *_ESC_CHARS definitions ex_getln.h: history table flags - used by add_to_history() fileio.h: readfile() flags event_T definition getchar.h: ins_typebuf() flags KEYLEN_* globals.h: NO_SCREEN NO_BUFFERS SEA_* defines current_SID flags hlf_T enum HL_FLAGS do_profiling() flags schar_T sattr_T indent.h: set_indent() flags macros.h: BINARY_FILE_IO flags mbyte.h: MB_BYTE2LEN* ENC_* memfile.h: mf_sync() flags misc1.h: open_line() flags message.h: do_dialog() flags vim_dialogyesno() flags DLG_BUTTON_* normal.h: find_ident_under_cursor() flags ops.h: do_put() flags operator ID's option.h: buf_copy_options() flags OPT_* flags os_unix.h: mch_nodetype() flags quickfix.h: skip_vimgrep_pat() flags regexp.h: vim_regcomp() flags values for reg_do_extmatch search.h: do_search() flags search_regcomp() flags findmatchlimit() flags syntax.h: HL_* flags HL_FOLD is used in buffer_defs.h but nvim compiles just fine with the defines in syntax.h tag.h: do_tag() flags find_tags() flags term.h: TBUFSZ flags MOUSE flags ui.h: jump_to_mouse() flags window.h: file_name_in_line() flags win_split() flags MIN_LINES MIN_COLUMNS Remove VimClipboard which should have been removed with PR #921.
* Include stdbool.h in some files which use itPavel Platto2014-07-11
| | | | | | | Done by manual inspection of the output of this script: grep -r -l -w "bool\|true\|false" * | grep 'c$\|h$' > has_bool grep -r -l "stdbool.h" * | grep 'c$\|h$' > has_include grep -F -x -v -f has_include has_bool
* move errno.h include out of vim.hBrandon Coleman2014-07-09
|
* move <inttypes.h> include out of vim.hBrandon Coleman2014-07-09
|