Commit Graph

304 Commits

Author SHA1 Message Date
Eliseo Martínez
7f7262e933 Cleanup: Rename getdigits() family functions. 2015-01-11 21:04:08 +01:00
Eliseo Martínez
04c0658024 Cleanup: Refactor getdigits().
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.
2015-01-11 17:18:39 +01:00
Florian Walch
ceb54c55ad vim-patch:7.4.559
Problem:    Appending a block in the middle of a tab does not work correctly
	    when virtualedit is set.
Solution:   Decrement spaces and count, don't reset them. (James McCoy)

https://code.google.com/p/vim/source/detail?r=v7-4-559
2015-01-03 16:08:51 +01:00
Florian Walch
0439e808cb vim-patch:7.4.521
Problem:    When using "vep" a mark is moved to the next line. (Maxi Padulo,
	    Issue 283)
Solution:   Decrement the line number. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-521
2014-12-24 23:28:59 +01:00
Eliseo Martínez
a97f9e9594 coverity/13696: Unchecked return value: RI.
Problem    : Unchecked return value (CHECKED_RETURN) @ 2644.
Diagnostic : Real issue.
Rationale  : Other `u_save` invocations are checked, and there's no
             reason to think this invocation could not fail.
Resolution : Check and return if failed (other previous checks in the
             same function just return, without reporting error, so
             we just do the same).
2014-12-16 21:01:22 +01:00
oni-link
bf4b85a5d4 Fix warning: ops.c: read_viminfo_register(): Dereference of null pointer: RI.
Problem    : Array access (via field 'y_array') results in a null pointer
             dereference @ 4487.
Diagnostic : Real issue.
Rationale  : If the array was previously freed and the size of the array
             (y_current->y_size) was not updated to zero, the loop @4486
             could be entered and a NULL pointer would be dereferenced.
Resolution : Use free_yank_all() to take care of the NULL check and
             to free the current yank register.
2014-12-15 20:11:18 +01:00
Joel Teichroeb
e10670ac3b vim-patch:? Fix memory leak in readviminfo
Patch provided by Christian Brabandt
Improved by oni-link
2014-12-13 11:43:48 -08:00
Justin M. Keyes
c729286604 Merge pull request #1635 from danthedeckie/master
replace copy_spaces and copy_chars functions with equivalent memset.
2014-12-12 10:21:21 -05:00
Daniel Fairhead
f8e3cfe220 strings.c: replace copy_spaces, copy_chars with equivalent memset. 2014-12-12 08:11:47 +00:00
Scott Prager
171445ef34 Refactor str_to_reg().
- Update the doxygen comments.
- Use more descriptive types.
- Localize variables.
- Find the '\n' with memchr instead of a for loop.
- Remove `if (size)` checks before memmove
  since memmove(dst,src,0) is a noop.
- Use memcpy instead since the pointers don't alias.
- Use xmemdupz instead of vim_strnsave.
- xrealloc instead of xmalloc/memcpy.
- Use memcnt/xmemscan/memchrsub.
2014-12-11 20:30:00 -05:00
Scott Prager
5fdca47962 vim-patch:7.4.243
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
2014-12-11 20:30:00 -05:00
Scott Prager
2f8cc3b9d5 Return void * from get_reg_contents. 2014-12-11 20:29:59 -05:00
Scott Prager
e18538f3ef vim-patch:7.4.242
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
2014-12-11 20:29:59 -05:00
Björn Linse
6ddbe6d9be clipboard: fix let @+ = ... and add test 2014-12-08 22:05:05 +01:00
Björn Linse
cccc46acd7 clipboard: better error messages when provider not available 2014-12-08 22:05:05 +01:00
Björn Linse
5476250ba3 options: change "unnamedclip" back to "clipboard=unnamed/unnamedplus"
This allows to configure which of '*' and '+' should be used for
the unnamed clipboard, and is consistent with vim.
2014-12-08 22:05:05 +01:00
Björn Linse
61aaf815db clipboard: clean up unnamedclip logic 2014-12-08 22:05:02 +01:00
Björn Linse
63efb9b1f1 clipboard: handle linewise/charwise selections correctly 2014-12-08 22:01:00 +01:00
Björn Linse
c1854d2433 clipboard: support separate '+' and '*' clipboards 2014-12-08 21:38:35 +01:00
Thiago de Arruda
bf6bb27e79 ui: Remove redundant ui.h includes
Also move read_error_exit to os/input.c
2014-11-27 15:00:30 -03:00
Thiago de Arruda
1865b8c1c1 ui: Remove ui_delay, ui_breakcheck and ui_set_shellsize
These functions only used to call another os_* function, so remove them and
replace all occurences in the project.
2014-11-27 14:27:18 -03:00
Thiago de Arruda
17a4bfe007 Remove os/provider.{c,h} and all of its references 2014-11-18 07:56:58 -03:00
Thiago de Arruda
375db3b19a eval/ex_cmds2/ops: Implement providers with eval_call_provider
Replace references to provider_call/provider_has with the new functions
eval_call_provider/eval_has_provider.
2014-11-18 07:56:58 -03:00
Scott Prager
f5aee19ac0 Use bool for flags in oparg_T.
Several opart_T members like use_reg_one, end_adjusted, empty,
is_VIsual, and block_mode, only ever store TRUE or FALSE, so make this
constraint explicit by changing them to bools, and TRUE to true and
FALSE to false in the context of their uses.

The member, inclusive, has several other uses such as in arithmetic
equations and one inequality, but every single assignment (obtained with
'grep -r "inclusive \\="') sets it to either TRUE or FALSE.

This also implies that the inequality, "oap->end.coladd <
oap->inclusive", can only be true when coladd==0 and inclusive==true, so
test for that instead.

For consistency, change the first argument of findpar (which ends up
being inclusive) to bool.

Include stdbool.h for consistency with issue #918.

This commit shrinks the size of oparg_T from 128 bytes to 112 (-13%) on
my machine.
2014-11-11 11:34:58 -05:00
Eliseo Martínez
9de544c785 Fix warnings: ops.c: cursor_pos_info(): Various (2): MI.
Problems: Result of operation is garbage or undefined @ 5087.
          http://neovim.org/doc/reports/clang/report-2e3118.html#EndPath

          Result of operation is garbage or undefined @ 5149.

Diagnostic: Multithreading issues.
Rationale : All reported problems can only occur if accesed globals
            change state while executing function, which could only
            happen in a multithreaded environment.
Resolution: Use local variables (copy globals on entry).
            Note that this change alters function semantics, as now
            function only depends on global values at entry time.
            This shouldn't be a problem, though, as new semantics should
            be in fact better.
2014-11-06 09:51:44 +01:00
Eliseo Martínez
0c135a2ff4 Fix warnings: ops.c: do_join(): Nonnull violation: FP.
Problem: Argument with 'nonnull' attribute passed null @ 3540.
         http://neovim.org/doc/reports/clang/report-fc14e0.html#EndPath.

Diagnostic: False potitive.
Rationale : `count` should be >= 2 by function precondition.
Resolution: Assert precondition.
2014-11-06 09:51:44 +01:00
Scott Prager
d62545e5ba vim-patch:7.4.408
Problem:    Visual block insert breaks a multi-byte character.
Solution:   Calculate the position properly. (Yasuhiro Matsumoto)

https://code.google.com/p/vim/source/detail?r=v7-4-408
2014-10-10 15:21:40 -04:00
Justin M. Keyes
5e65e3eae0 Merge pull request #1208 from war1025/dev/remove_for_all_windows
Remove FOR_ALL_WINDOWS and replace with FOR_ALL_WINDOWS_IN_TAB(curtab)
2014-10-03 13:44:50 -04:00
Scott Prager
eff839b26d memory: xstrchrnul and xmemscan. 2014-09-30 19:33:48 -04:00
Wayne Rowcliffe
9b6f192693 Replace FOR_ALL_WINDOWS with FOR_ALL_WINDOWS_IN_TAB(curtab) 2014-09-24 19:00:50 -05:00
Thiago de Arruda
cac24cb06d api/msgpack-rpc: Refactor msgpack_rpc_helpers.{c,h}
- Move helpers that are specific to API types to api/private/helpers.{c,h}
- Include headers with generated declarations
- Delete unused macros
2014-09-12 13:25:28 -03:00
Wayne Rowcliffe
fe99930c46 Convert FOR_ALL_WINDOWS to use a locally declared pointer 2014-09-08 17:27:41 -05:00
Thiago de Arruda
a66d2d1538 msgpack-rpc: Always use arrays when sending events or calls
This is required by the msgpack-RPC specification. Also, the
send_call/send_event functions were refactored to accept a variable number of
arguments
2014-08-29 22:08:58 -03:00
Felipe Morales
47391b18e2 Port vim's patch 7.4.338 ('breakindent') 2014-08-20 05:19:49 -04:00
André Twupack
d730c5c57e vim-patch:7.4.331 #1017
Problem:    Relative numbering not updated after a linewise yank.  Issue 235.
Solution:   Redraw after the yank. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=6d984caa0409fd284722c44cb09a0a2b5360bd4f
2014-08-13 13:45:54 -04:00
Pavel Platto
e1dd98512f Remove EBCDIC: Clean up comments 2014-08-02 09:16:59 +03:00
Thiago de Arruda
fba1d3b50f provider: Add support for clipboard registers.
This reimplements the '+'/'*' clipboard registers(both are aliases to the same
register, no dedicated storage for the X11 selection) on top of the provider
infrastructure.

This adds two new 'unnamedclip' option, has the same effect of setting
'clipboard' to 'unnamed/unnamedplus' in vim

The 'clipboard' option was not reused because all values(except 'unnamedplus')
seem to be useless for Neovim, and the code to parse the option was relatively
big. The option remains for vim compatibility but it's silently ignored.
2014-07-17 11:37:41 -03:00
Brandon Coleman
bf219e1442 move <inttypes.h> include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
82b71a3056 move ascii.h include out of vim.h 2014-07-09 00:18:18 +02:00
Brandon Coleman
a4f441e547 remove stdbool.h include from vim.h and globals.h 2014-07-09 00:18:17 +02:00
Felipe Oliveira Carvalho
3a9a76c996 No OOM in vim_strsave_escape_csi() 2014-06-16 01:36:32 -03:00
Felipe Oliveira Carvalho
8234f2839f No OOM in vim_strsave_escaped[_ext]() 2014-06-16 01:36:31 -03:00
Douglas Schneider
4a8ac58596 Replace vim_strncpy calls: ops.c 2014-06-13 18:08:21 -04:00
Will Stamper
5b3b3fd3ed spelling fixes #827 2014-06-12 20:26:35 -04:00
Nicolas Hillegeer
ebbd87b0be coverity/62615: fix leak in write_reg_contents_ex
Coverity detected a memory leak caused by not free'ing the value returned by
get_expr_line_src (basically vim_strsave(expr_line)). Replaced the copying
with direct manipulation of expr_line, since that also happens in other
parts of the codebase.

NOTE: I'm aware that this has different behaviour than vim_strnsave, namely
vim_strnsave always allocates `len` bytes, even if the string is shorter. I
don't see how that behaviour is helpful here though.
2014-06-12 01:41:03 -04:00
ZyX
70929f7e16 Add automatic generation of headers
- The 'stripdecls.py' script replaces declarations in all headers by includes to
  generated headers.
  `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'`
  was used for this.
- Add and integrate gendeclarations.lua into the build system to generate the
  required includes.
- Add -Wno-unused-function
- Made a bunch of old-style definitions ANSI

This adds a requirement: all type and structure definitions must be present
before INCLUDE_GENERATED_DECLARATIONS-protected include.

Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is
the only exception.
2014-06-02 11:04:17 -03:00
Pavel Platto
baaa428785 Remove ml_ prefix from cursor.h functions
s/ml_get_curline/get_cursor_line_ptr
s/ml_get_cursor/get_cursor_pos_ptr
2014-05-28 10:42:06 -04:00
Hinidu
e62722922b Extract cursor.h from misc{1,2}.h and memline.h 2014-05-28 10:42:06 -04:00
oni-link
753401ab4c vim-patch:7.4.267
Problem:    The '[ mark is in the wrong position after "gq". (Ingo Karkat)
Solution:   Add the setmark argument to do_join(). (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=75f222d67cea335efbe0274de6340dba174c1e7e
2014-05-27 16:51:10 -04:00
Felipe Oliveira Carvalho
21784aeb00 Replace alloc() with xmalloc() and remove immediate OOM checks 2014-05-19 14:50:23 -03:00