Commit Graph

641 Commits

Author SHA1 Message Date
Wander Nauta
7732bec9b8 eval: Fix duplicate code in trig/math functions #3035
The same error checking/recovery code was duplicated among the f_acos,
f_asin, f_atan, f_ceil, f_cos, f_cosh, f_exp, f_floor, f_log, f_log10,
f_round, f_sin, f_sinh, f_sqrt, f_tan, f_tanh and f_trunc functions.
This commit moves that code into a wrapper function.

`trunc` is not in C90, but it is in C99, which is what neovim targets,
so we use it here.
2015-07-18 10:33:22 -04:00
Hettomei
3b06ce200b Macro cleanup: FEAT_SHORTCUT, replace with WIN32 2015-07-17 21:40:40 -04:00
Hettomei
848a5e2e87 Macro cleanup: USE_FILE_CHOOSER 2015-07-17 21:40:38 -04:00
Hettomei
6d937315b6 Macro cleanup: FEAT_GUI_MOTIF 2015-07-17 21:40:38 -04:00
Hettomei
031758ad5c Macro cleanup: FEAT_GUI_W32 2015-07-17 21:40:37 -04:00
Thiago de Arruda
aa9cb48bf0 job: Replace by a better process abstraction layer
- New libuv/pty process abstraction with simplified API and no globals.
- Remove nvim/os/job*. Jobs are now a concept that apply only to programs
  spawned by vimscript job* functions.
- Refactor shell.c/channel.c to use the new module, which brings a number of
  advantages:
  - Simplified API, less code
  - No slots in the user job table are used
  - Not possible to acidentally receive data from vimscript
- Implement job table in eval.c, which is now a hash table with unilimited job
  slots and unique job ids.
2015-07-17 00:32:07 -03:00
Thiago de Arruda
ac2bd02561 rstream/wstream: Unify structures and simplify API
- Simplify RStream/WStream API and make it more consistent with libuv.
- Move into the event loop layer(event subdirectory)
- Remove uv_helpers module.
- Simplify job/process internal modules/API.
- Unify RStream and WStream into a single structure. This is necessary because
  libuv streams can be readable and writable at the same time(and because the
  uv_helpers.c hack to associate multiple streams with libuv handle was removed)
- Make struct definition public, allowing more flexible/simple memory
  management by users of the module.
- Adapt channel/job modules to cope with the changes.
2015-07-17 00:19:55 -03:00
Thiago de Arruda
991d3ec1e6 event loop: New abstraction layer with refactored time/signal API
- Add event loop abstraction module under src/nvim/event. The
  src/nvim/event/loop module replaces src/nvim/os/event
- Remove direct dependency on libuv signal/timer API and use the new abstraction
  instead.
- Replace all references to uv_default_loop() by &loop.uv, a new global variable
  that wraps libuv main event loop but allows the event loop functions to be
  reused in other contexts.
2015-07-17 00:19:19 -03:00
Felipe Morales
59784b91db vim-patch:7.4.688 #2941
```
updated for version 7.4.668
Problem:    Can't use a glob pattern as a regexp pattern.
Solution:   Add glob2regpat(). (Christian Brabandt)
```

https://code.google.com/p/vim/source/detail?r=v7-4-668
2015-07-14 14:25:54 -04:00
Thiago de Arruda
0ef80b9c2b rbuffer: Reimplement as a ring buffer and decouple from rstream
Extract the RBuffer class from rstream.c and reimplement it as a ring buffer,
a more efficient version that doesn't need to relocate memory.

The old rbuffer_read/rbuffer_write interfaces are kept for simple
reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to
hide wrapping logic when more control is required(such as passing the buffer
pointer to a library function that writes directly to the pointer)

Also add a basic infrastructure for writing helper C files that are only
compiled in the unit test library, and use this to write unit tests for RBuffer
which contains some macros that can't be accessed directly by luajit.

Helped-by: oni-link <knil.ino@gmail.com>
Reviewed-by: oni-link <knil.ino@gmail.com>
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Reviewed-by: Justin M. Keyes <justinkz@gmail.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
2015-07-01 05:40:53 -03:00
Shougo Matsushita
8b200f904f completion: Initialize v:completed_item #2839
v:completed_item should always be a dict (not empty string), even before
the first completion.
2015-06-20 11:53:13 -04:00
Shougo Matsushita
d9f97e3026 completion: Add v:completed_item feature #2563
Reviewed-by: Michael Reed <m.reed@mykolab.com>
Reviewed-by: Luke Andrew <luke.github@la.id.au>
Reviewed-by: Justin M. Keyes <justinkz@gmail.com>
Reviewed-by: Florian Walch <florian@fwalch.com>
2015-05-24 17:05:12 -04:00
Michael Reed
c50c831b85 Cleanup 'ttym[ouse]', FEAT_MOUSE, mouse_(dec|gpm|etc.)
Because of 3baba1e7bc, it's dead code.

Helped-by: Justin M. Keyes <justinkz@gmail.com>
2015-05-18 11:06:54 -04:00
David Bürgin
b1403e7d44 vim-patch:7.4.597 #2658
Problem:    Cannot change the result of systemlist().
Solution:   Initialize v_lock. (Yukihiro Nakadaira)

https://github.com/vim/vim/commit/v7-4-597

See https://groups.google.com/d/msg/vim_dev/WXCfHMeqjfk/n2PjNwZ2bzIJ
2015-05-17 15:11:10 -04:00
Justin M. Keyes
85c51baf06 passing-by: get_vim_var_str: mark non-null return 2015-05-17 02:17:34 -04:00
Justin M. Keyes
84443f176e doc: v:servername, serverstart() 2015-05-17 02:17:34 -04:00
Michael Reed
3c5864772f Remove char_u: message:smsg() 2015-05-13 15:29:50 -04:00
Chris Hall
7fc7147ad6 coverity/62618: fixing "Wrong sizeof argument"
suspicious_sizeof: Passing argument 168UL /* sizeof (ufunc_T) */ * todo
to function xmalloc and then casting the return value to ufunc_T ** is
suspicious.
2015-05-08 10:08:53 +12:00
Eliseo Martínez
f88cec8021 Merge #2470: Remove char_u (5)
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
2015-05-07 08:08:31 +02:00
Mark Bainter
80180bf94e Remove char_u: FullName_save() 2015-05-06 21:25:04 -05:00
Mark Bainter
789c448d19 Remove char_u: path_with_url() 2015-05-06 21:25:04 -05:00
Mark Bainter
f813fdce38 Remove char_u: add_pathsep() 2015-05-06 21:25:04 -05:00
Bastian Winkler
115f137b12 vim-patch:7.4.574 #2539
Problem:    No error for eval('$').
Solution:   Check for empty name. (Yasuhiro Matsumoto)

https://github.com/vim/vim/commit/v7-4-574
2015-05-03 19:39:56 -04:00
Scott Prager
1eb3396922 unify jobstart, termopen, and system interfaces
For any of these functions, if {cmd} is a string, execute
"&shell &shellcmdflag '{cmd}'", or simply {cmd} if it's a list.

In termopen(), if the 'name' option is not supplied, try to guess using
'{cmd}' (string) or {cmd}[0] (list).  Simplify ex_terminal to use the
string form of termopen().

termopen: get name from argument

Convert list_to_argv to tv_to_argv.

Helped-by: Björn Linse <@bfredl>
Helped-by: oni-link <knil.ino@gmail.com>
Helped-by: Thiago de Arruda <@tarruda>
2015-05-02 09:47:30 -04:00
Scott Prager
74aef89720 term: use an argument vector for termopen().
Old behaviour: termopen('cmd') would run `&shell &shcf "cmd"`, which
caused the functional tests to fail on some systems due to the process
not "owning" the terminal. Also, it is inconsistent with jobstart().

Modify termopen() so that &shell is not invoked, but maintain the old
behaviour with :terminal. Factor the common code for building the
argument vector from jobstart() and modify the functional tests to call
termopen() instead of :terminal (fixes #2354).

Also:
 * Add a 'name' option for termopen() so that `:terminal {cmd}` produces
   a buffer named "term//{cwd}/{cmd}" and termopen() users can customize
   the name.
 * Update the documentation.
 * Add functional tests for `:terminal` sinse its behaviour now differs
   from termopen(). Add "test/functional/fixtures/shell-test.c" and move
   "test/functional/job/tty-test.c" there, too.

Helped-by: Justin M. Keyes <@justinmk>
2015-05-02 09:47:29 -04:00
Florian Walch
6a8862ded4 vim-patch:7.4.633 #2526
Problem:    After 7.4.630 the problem persists.
Solution:   Also skip redo when calling a user function.

https://github.com/vim/vim/commit/v7-4-633
2015-04-28 21:03:00 -04:00
Eliseo Martínez
7c956dcbe8 Enable -Wconversion: normal.c.
Refactor summary:
- extern int opcount --> extern long opcount
- bool find_decl(..., int len, ...) --> bool find_decl(..., size_t len, ...)
  * int find_ident_under_cursor(...) --> size_t find_ident_under_cursor(...)
    - int find_ident_at_pos(...) --> size_t find_ident_at_pos(...)
    - int modify_fname(..., int *usedlen, ..., int *fnamelen) --> int modify_fname(..., size_t *usedlen, ..., size_t *fnamelen)
      * char_u *eval_vars(..., int *usedlen, ...) --> char_u *eval_vars(..., size_t *usedlen, ...)
        - int find_cmdline_var(..., int *usedlen) --> ssize_t find_cmdline_var(..., size_t *usedlen)
        - static char_u *repl_cmdline(..., int srclen, ...) --> static char_u *repl_cmdline(..., size_t srclen, ...)
    - bool get_visual_text(..., int *lenp) --> bool get_visual_text(..., size_t *lenp)
      * char_u *find_file_name_in_path(..., int len, ...) --> char_u *find_file_name_in_path(..., size_t len, ...)
        - static char_u *eval_includeexpr(..., int len) --> static char_u *eval_includeexpr(..., size_t len)
        - char_u *find_file_in_path(..., int len, ...) --> char_u *find_file_in_path(..., size_t len, ...)
          * char_u *find_file_in_path_option(..., int len, ...) --> char_u *find_file_in_path_option(..., size_t len, ...)
            - char_u *find_directory_in_path(..., int len, ...) --> char_u *find_directory_in_path(..., size_t len, ...)
      * int spell_move_to(...) --> size_t spell_move_to(...)
        - int spell_check(...) --> size_t spell_check(...)
        - static int spell_bad_len --> static size_t spell_bad_len
    - void find_pattern_in_path(..., int len, ...) --> void find_pattern_in_path(..., size_t len, ...)

Helped-by: Justin M. Keyes <justinkz@gmail.com>
2015-04-27 19:27:07 +02:00
Felipe Oliveira Carvalho
2ca8afc74e Replace vim_isxdigit() with to ascii_isxdigit() defined in ascii.h 2015-04-24 20:37:13 -03:00
Felipe Oliveira Carvalho
caabcae0b7 Replace VIM_ISDIGIT() and vim_isdigit() with ascii_isdigit() defined in ascii.h 2015-04-24 20:37:13 -03:00
Felipe Oliveira Carvalho
93bf201119 Replace vim_iswhite with ascii_iswhite() defined in ascii.h 2015-04-24 20:37:13 -03:00
Scott Prager
d350d12a00 rpcstart: check argvars, /then/ alloc argv #2462
fixes #2458
2015-04-23 18:27:32 -04:00
Shougo Matsushita
42de617974 Add if_python3 support
Reviewed-by: Michael Reed <m.reed@mykolab.com>, Daniel Hahler <github@thequod.de>
Helped-by: Daniel Hahler <github@thequod.de>
2015-04-21 06:20:23 +09:00
Eliseo Martínez
7086d435e0 Merge #2418: Remove char_u (4)
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
2015-04-19 21:10:21 +02:00
Mark Bainter
a7e17de048 Refactor get_env() to respect const qualifier
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.
2015-04-18 21:37:10 +00:00
John Szakmeister
6395048946 Merge pull request #2443 from jszakmeister/fix-more-release-warnings
Fix a few uninitialized variable warnings.
2015-04-18 16:52:43 -04:00
Eliseo Martínez
f03780c1b8 Fix an uninitialized variable warning for call_start. 2015-04-18 04:37:09 -04:00
Mark Bainter
a4e51f72ab Remove char_u: vim_setenv() 2015-04-18 04:50:12 +00:00
Mark Bainter
4848158cc1 Remove char_u: vim_getenv() 2015-04-17 14:46:58 +00:00
Mark Bainter
9a5e87ac83 Remove char_u: after_pathstep()
See: #459
2015-04-17 14:46:58 +00:00
Björn Linse
84b7a9ac34 ops.c: eliminate unneccesary static variable y_append 2015-04-17 11:34:05 +02:00
Marco Hinz
c1a3d289d6 Eval: do not join a list if it's empty anyway #2441
This spares some work and also prevents list_join() from calling ga_init()
with a growsize of 0 which would lead to the nvimlog being littered with:

  [warning @ ga_set_growsize:64] 17675 - trying to set an invalid ga_growsize: 0

Also in Vim 7.4.702
  5216f767d4
2015-04-16 20:15:31 -04:00
Scott Prager
296719428a eval: learn serverstart, list, and close().
Implement functions for spawning, destroying, and listing active
servers, and add server_address_list() to msgpack_rpc/server.c for the
serverlist() vimL function.
2015-04-14 15:31:04 -04:00
Thiago de Arruda
34c48aaf12 memory: Add free wrapper and refactor project to use it
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.
2015-04-13 08:22:44 -03:00
Thiago de Arruda
ba10e311bd memory: Replace klib memory pools by malloc/free
Klib pools were used to improve allocation efficiency for some small objects,
but it is not a thread-safe approach. Thread safety in allocations will be
required for implementing #2371).
2015-04-12 17:20:24 -03:00
Thiago de Arruda
27b5ef3975 eval: Fix memory deallocation of JobEvent
This causes a "read after free" error when kmp_free is replaced by `free`.
2015-04-12 17:20:24 -03:00
Thiago de Arruda
ccd42e81c8 eval: Fix jobwait()
- Properly save job event deferring state for recursive calls
- Disable breakcheck while running. Breakcheck can invoke job callbacks
  in unexpected places.
2015-04-11 08:46:59 -03:00
Thiago de Arruda
17db7f1e14 eval: Fix segfault caused by passing invalid callback to jobstart 2015-04-11 08:46:59 -03:00
Michael Reed
5bc151c2a4 Remove unused 'if_[language].txt': Clean up
Regarding |script-here|: despite being a language agnostic piece of
advice, it was in `if_perl.txt`. Regardless, we now only have one
support for one legacy plugin interface, so put it in `if_pyth.txt`
2015-04-10 16:38:11 -04:00
Scott Prager
edbc9e6538 eval: do not assume a vval.v_string is nonnull.
In the fallowing functions, use get_tv_string() to safely avoid a NULL
pointer dereference.
  * rpcstart
  * rpcrequest
  * rpcnotify
  * jobstart

fixes #2321
2015-04-08 23:18:16 -04:00
Scott Prager
41ce69811a system(): Return an empty string if no output.
fixes #2286
2015-04-08 23:18:16 -04:00