Commit Graph

1187 Commits

Author SHA1 Message Date
Nicolas Hillegeer
70f28d938c coverity/13685: silence NUL-termnation fp
It was a false positive, but it can't hurt to "fix" it.

Original warning:
CID 13685 (#1 of 1): Buffer not null terminated (BUFFER_SIZE)
6. buffer_size: Calling strncpy with a source string whose length (4 chars)
is greater than or equal to the size argument (4) will fail to
null-terminate b0p->b0_version.
2014-06-12 01:41:03 -04:00
Nicolas Hillegeer
1a031af233 coverity/13770: add_keyword(), mark as false pos.
Also cleaned up the function a little bit.
2014-06-12 01:41:03 -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
Nicolas Hillegeer
731761715a coverity/62617: fix leak in set_string_default
Also constified the arguments. The double casts for the `xstrdup` are ugly
but `vim_strsave` doesn't take `const` arguments for now so I couldn't keep
that.
2014-06-12 01:41:03 -04:00
Felipe Oliveira Carvalho
f39fd5b4c4 Declare garray iterators in the for() scope where possible #819 2014-06-10 14:15:21 -04:00
Wesley Wiser
a321480342 Add function attributes to functions in memory.h #811
Add missing function attributes in memory.h. Fixes #806
2014-06-10 02:46:43 -04:00
Andrew Chin
785b16d905 Prevent null-pointer deference during vim_eval #785
If the eval_expr call in vim_eval returns NULL, a null-pointer deference
would happen a few frames down, in vim_to_object_rec
2014-06-10 02:39:39 -04:00
Brandon Coleman
d2dfa8523e deleted unused defines in vim.h #772 2014-06-10 01:42:48 -04:00
Justin M. Keyes
39cdb5f214 Merge #783 'Nul terminate pascal strings' 2014-06-08 16:32:31 -04:00
Nicolas Hillegeer
54ca93465c api: unify string conversions, simplify interop
- The data member of String's can now be passed directly to functions
  expecting C strings, as we now guarantee that they are NUL-terminated.
  This obviates the need to use xstrndup and free, simplifying code and
  enhancing performance.
- Use xmemdupz instead of xstrndup for converting String's into C strings.
  It's faster because it doesn't calculate strlen(string.data) (which is
  unnecesary as that information is already provided in string.size anyway).
- Use cstr_to_string to convert from C strings to String, it is both shorter
  and faster than the usual strlen/xstrndup combo, which calls strlen twice.
  cstr_to_string internally calls strlen and then xmemdupz.
2014-06-08 19:21:35 +02:00
Nicolas Hillegeer
563698b2dc api: also NUL-terminate Strings made from cstrs
I believe we can now mostly assume that all encountered String's data
members are safe to pass into functions that accept C strings. That should
simplify interop with C string code.
2014-06-08 19:21:35 +02:00
Nicolas Hillegeer
e1793949ab api: remove some redundant string copies
Now that incoming Pascal strings are NULL-terminated by default, we can skip
some spurious copies.
2014-06-08 19:21:30 +02:00
Nicolas Hillegeer
b5640b136c msgpack: NULL terminate incoming strings
It's a 1-byte loss of memory but it allows us to skip copying and
NULL-terminating strings when interacting with vim functions that accept C
strings. This lowers the pressure on the allocator and saves lines of code
(no more dup/free pairs).
2014-06-08 19:15:16 +02:00
Justin M. Keyes
0d91b067ac Merge #777 'Constify text enc args fix mb_string2cells' 2014-06-08 12:48:53 -04:00
Nicolas Hillegeer
46e4bc0481 text: remove useless arg from mb_string2cells
mb_string2cells was always called like mb_string2cells(..., -1) so that was
the only codepath that was tested. @tarruda was the first to try to input an
actual length, after which valgrind detected that funny business was going
on.

It's not even possible to do the right thing with the current text codec
infrastructure: they all assume to be working with C strings. Meaning that
if there is no NUL-terminator, they will happily keep on reading past the
end of Pascal strings. Ergo, passing the length parameter is moot. The
condition in the for-loop was wrong as well (but that's no longer relevant).

Also change the return value to size_t, by analogy with strlen.

ref:
677d30d796
2014-06-08 12:48:22 -04:00
Nicolas Hillegeer
63a956112a text/encoding: constify arguments
Most of these functions don't modify their strings, let's make the contract
a bit clearer. In some cases I've tried to get rid of C89-style variable
declarations at the start of functions, now that I was there.
2014-06-07 13:14:13 +02:00
oni-link
057e36ea19 vim-patch:7.4.290 #753
Problem:    A non-greedy match followed by a branch is too greedy. (Ingo
            Karkat)
Solution:   Add NFA_MATCH when it is already in the state list if the position
            differs.

https://code.google.com/p/vim/source/detail?r=b871734bf54ea185dbd2cc759d86dbfbe21cde26
2014-06-06 19:38:06 -04:00
oni-link
37fe5aa444 vim-patch:7.4.292 #754
Problem:    Searching for "a" does not match accented "a" with new regexp
            engine, does match with old engine. (David Bürgin)
            "ca" does not match "ca" with accented "a" with either engine.
Solution:   Change the old engine, check for following composing character
            also for single-byte patterns.

https://code.google.com/p/vim/source/detail?r=60cdaa05a6ad31cef55eb6b3dc1f57ecac6fcf79
2014-06-06 18:39:31 -04:00
Justin M. Keyes
01ca4600ba Remove USE_CR and tag_fgets. #808
These features are only used by legacy Mac OS.
2014-06-06 18:04:37 -04:00
oni-link
1e54b04bc0 Add more commented patch numbers to version.c (2) #763
This should help reduce conflicts when merging patches from upstream.
2014-06-05 19:20:51 -04:00
oni-link
2085acf478 vim-patch:7.4.289 #752
Problem:    Pattern with repeated backreference does not match with new regexp
            engine. (Urtica Dioica)
Solution:   Also check the end of a submatch when deciding to put a state in
            the state list.

https://code.google.com/p/vim/source/detail?r=99374096a76b96d1128f5e6aa1fa92b4ba70fee9
2014-06-05 18:42:15 -04:00
oni-link
8638578bf3 vim-patch:7.4.288 #751
Problem:    When 'spellfile' is set the screen is not redrawn.
Solution:   Redraw when updating the spelling info. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=7965cb6a435ae1ea331c7c2f8740d3d4c3625f3b
2014-06-05 18:40:02 -04:00
oni-link
82d11c0772 vim-patch:7.4.286 #750
Problem:    Error messages are inconsistant. (ZyX)
Solution:   Change "Lists" to "list".

https://code.google.com/p/vim/source/detail?r=be19015ef43cc17825929206790696c2e716035d
2014-06-05 18:32:00 -04:00
oni-link
f68bf38547 vim-patch:7.4.284 #748
Problem:    Setting 'langmap' in the modeline can cause trouble.  E.g. mapping
            ":" breaks many commands. (Jens-Wolfhard Schicke-Uffmann)
Solution:   Disallow setting 'langmap' from the modeline.

https://code.google.com/p/vim/source/detail?r=3c35ca9666e88a8024af6dab585b8e79ab295f83
2014-06-05 18:27:10 -04:00
oni-link
1057b29c8c vim-patch:7.4.282 #747
Problem:    Test 97 fails on Mac.
Solution:   Do not ignore case in file names. (Jun Takimoto)

https://code.google.com/p/vim/source/detail?r=6d0a1132dd71c7f55f7ed53fe99e97c79bfd05a4
2014-06-05 18:23:21 -04:00
oni-link
29eb651a92 vim-patch:7.4.281 #746
Problem:    When a session file has more than one tabpage and 'showtabline' is
            one the positions may be slightly off.
Solution:   Set 'showtabline' to two while positioning windows.

https://code.google.com/p/vim/source/detail?r=24c90f1fec859b54cf2b854b98c4c9e614c46061
2014-06-05 18:16:59 -04:00
oni-link
fee0e2d977 vim-patch:7.4.280 #745
Problem:    When using a session file the relative position of the cursor is
            not restored if there is another tab. (Nobuhiro Takasaki)
Solution:   Update w_wrow before calculating the fraction.

https://code.google.com/p/vim/source/detail?r=daf7e98675cf395e1ef96f8040567affb2782a11
2014-06-05 18:13:17 -04:00
Justin M. Keyes
862a25f96e Merge #738 'vim-patch:7.4.275' 2014-06-04 07:13:05 +00:00
Douglas Schneider
e8b4fc53fc vim-patch:7.4.275
Problem:  When changing the type of a sign that hasn't been
          placed ther is no error message.
Solution: Add an error message. (Christian Brabandt)

Author: Bram Moolenaar

https://code.google.com/p/vim/source/detail?r=8a3117a4887c1e12a1165c9719491f96753
2014-06-04 07:12:46 +00:00
Justin M. Keyes
d5c2cee1b7 Merge #744 'vim-patch:7.4.277' 2014-06-04 06:57:59 +00:00
oni-link
b09334d571 vim-patch:7.4.277
Problem:    Using ":sign unplace *" may leave the cursor in the wrong position
            (Christian Brabandt)
Solution:   Update the cursor position when removing all signs.

https://code.google.com/p/vim/source/detail?r=373204662d82e894b27ee76bc3319bc62c91f6ae
2014-06-04 06:57:37 +00:00
Justin M. Keyes
1fb20575f1 Fix diagrams in ex_cmds.c #798 2014-06-02 18:56:06 -04:00
Thiago de Arruda
8d92494c7c Merge branch 'make-gendeclarations-friendly-to-incremental-builds' 2014-06-02 16:00:00 -03:00
Thiago de Arruda
4b787fb7d1 Make gendeclarations.lua more friendly to incremental builds
Modify gendeclarations.lua to check if the generated non-static declaration
header changed before rewriting it with a new version. This is to prevent
unnecessary rebuilds of modules that depend on modules that had private changes.
2014-06-02 15:53:55 -03:00
Thiago de Arruda
cab8cf970c Merge pull request #710 'Automatically generate declarations' 2014-06-02 11:24:02 -03:00
ZyX
4aecb71b0e Use generated static declarations in cursor.c 2014-06-02 11:04:18 -03:00
ZyX
1747d3d940 Use generated headers in os.h 2014-06-02 11:04:18 -03:00
ZyX
4cf17ad632 Add REAL_FATTR_ macros to func_attr.h, use them in lib/k*
Otherwise FUNC_ATTR_* macros may appear empty
2014-06-02 11:04:18 -03:00
ZyX
f0be78506f Move memory.h include above func_attr.h include 2014-06-02 11:04:18 -03:00
ZyX
d906708a43 Remove unneeded klist include in channel.c 2014-06-02 11:04:18 -03:00
ZyX
a7e3c4f6f6 Remove a number of unneeded func_attr includes 2014-06-02 11:04:18 -03:00
ZyX
6140f35eae Add missing include to mbyte.c 2014-06-02 11:04:18 -03:00
ZyX
dca28e55c7 Fix some styles 2014-06-02 11:04:18 -03:00
ZyX
bf4fb30121 Add include guard to ex_cmds_defs 2014-06-02 11:04:18 -03:00
ZyX
7dd0d9d2ab Make nvim/lib/k*.h headers be the last one in the list
So that they do the last nvim/func_attr.h include
2014-06-02 11:04:18 -03:00
ZyX
8c0ca573e5 Surround nvim/func_attr.h includes with define/undef DEFINE_FUNC_ATTRIBUTES
Required for FUNC_ATTR_UNUSED to work in lib/k*
2014-06-02 11:04:18 -03:00
ZyX
6498b281fa Remove remaining declarations with new script: finddeclarations.pl 2014-06-02 11:04:18 -03: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
ZyX
880957ad4e Move documentation from function declarations to definitions
Uses a perl script to move it (scripts/movedocs.pl)
2014-06-02 11:04:04 -03:00
Thiago de Arruda
52a9a5b0b0 Merge pull request #779 'Add --api-msgpack-metadata command line option' 2014-06-02 10:36:36 -03:00