The environment variable USE_VALGRIND can be set to run tests with valgrind. If
VALGRIND_GDB is set, valgrind will start it's own gdbserver for remote
debugging with `target remote | vgdb`. USE_GDB can still be used, but it will
be ignored if USE_VALGRIND is set.
* reset_signals, vim_handle_signal:
signal handling was rewritten, not defined anywhere
* related to x clipboard handling, not defined anywhere:
* {setup,start,stop,clear}_xterm_clip
* stop_xterm_trace
* clip_xterm_{own_selection,lose_selection,request_selection,set_selection}
* related to XSMP (x session management protocol):
* xsmp_{handle_requests,init,close}
This removes `mch_call_shell` code for feeding programs interactively. The
removed code was supporting interactive programs in the old GUI, but right now
we only have a terminal UI.
The code is currently safe to remove because interactive programs will just
simply take control of the terminal in cooked mode.
This is mostly a revert of 477031c03b.
Now that we are not setting `CMAKE_C_FLAGS`, the check can work
correctly and it helps `pcc` (portable c compiler) make it further
along--though it still doesn't produce usable results (see #427 for the
details).
This removes all signal handling code from os_unix.c to os/signal.c. Now signal
handling is done like this:
- Watchers for signals are registered with libuv default event loop
- `event_poll` continuously calls `poll_uv_loop` to produce events until it
receives user input, SIGINT or a timeout
- Any signals received in `poll_uv_loop` will push events to a queue that is
drained and processed by `event_poll`
Signals aren't handled directly in the libuv callback to avoid recursion in the
event loop(which isn't supported by libuv).
The same principle will apply to other events in the future: Push to a queue
from a libuv callback and drain it from `event_poll`
The attributes in question are:
- nonnull: specify whether a function argument cannot/may not be null
- returns_nonnull: specify whether a function will not return a null
pointer (example: xmalloc can't return null, so it should be annotated as
such). Only available from gcc 4.9 onwards.
Currently these attributes are only supported by gcc.
The attribute was removed in commit c047507 in the clang repository as it
was never properly implemented anyway. This fixes compiling with clang 3.5.
Fixes issue #429
The SHELL_* defines are the bitflags that can be passed to `mch_call_shell`.
The enum is defined in 'os/shell.h', where all shell-related functions will
eventually be defined.
I'm debugging OOM behavior using http://www.nongnu.org/failmalloc/ on Linux.
gdb environment:
```
set env LD_PRELOAD=libfailmalloc.so
set env FAILMALLOC_SPACE=0xF00000
```
SEGV was happening like this:
```
Starting program: /home/felipe/code/neovim/build/bin/nvim
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Vim: Error: Out of memory.
Program received signal SIGSEGV, Segmentation fault.
0x00000000004d3719 in getout (exitval=1) at
/home/felipe/code/neovim/src/main.c:836
836 if (*p_viminfo != NUL)
(gdb)
```
After the fix it works as expected:
```
(gdb) set environment LD_PRELOAD=libfailmalloc.so
(gdb) set environment FAILMALLOC_SPACE=0xF00000
(gdb) r
Starting program: /home/felipe/code/neovim/build/bin/nvim
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Vim: Error: Out of memory.
Vim: Finished.
[Inferior 1 (process 21505) exited with code 01]
(gdb)
```
This feature was accidentally removed when doing the initial import from vim. It
makes vim use pipes instead of temporary files for filtering buffers through
shell commands.
I found that this was missing when looking for references of
SHELL_READ/SHELL_WRITE outside mch_call_shell`.
When `mch_call_shell` is reimplemented on top of libuv process management
facilities, pipes will always be used for communication with child processes so
it makes sense to enable the feature permanently.
The functions `mch_inchar`, `mch_breakcheck`, `mch_char_avail` were
reimplemented on top of libuv. Here's how it works:
- When Neovim needs to wait for characters, it will transfer control to libuv
event loop.
- When the libuv event loop gets user input, it will transfer control back to
Neovim
- Neovim uses the `input_read` function to get the actual data read by libuv.
With this scheme its possible to keep Neovim single-threaded while enjoying the
benefits provided by libuv.
This commit leaves SIGWINCH broken for now
Code around `#ifdef MEM_PROFILE` was used to profile vim's memory
comsumption. It's very likely broken as new code is using malloc() and free()
directly.
In this day and age, valgrind can solve in a much reliable way what
this code was trying to do.
- Change CMakeLists.txt to compile farsi.c normally
- Add const to global variables in farsi.h and define them in farsi.c (no need
to include farsi.h with DO_INIT defined in globals.h)
- Include farsi.h where necessary
- Include all necessary headers in farsi.c
- Move farsi function declarations from main.h to farsi.h
- Move arabic_shape() decl from main.h to arabic.h
- Move arabic_combine() and arabic_maycombine() from mbyte.c to
arabic.c as these functions use the #defines I moved.
- Remove the unnecessary include of arabic.h in globals.h
- Remove include of arabic.c (sic) in main.c (change CMakeLists.txt to compile
arabic.c normally)
Only provide the unittest target if busted was found. And only build
nvim-test if the unittest target exists by excluding nvim-test from all.
Note: this means nvim-test won't be built by default, but it will be
built when you try to run unittests.
Since libuv.pc is broken at the moment, try to determine libuv's
dependencies ourselves. This ports most of the checks from libuv into
our CMake build, and fixes the build on other unix platforms.
This achieves several goals:
* Less reliance on scripts so we have better portability to Windows
(though we still have a ways to go for proper Windows support).
Luajit, luarocks, moonscript, and busted are all installed via CMake
now.
* Trying to make use of pkg-config to get the correct libraries. The
latest libuv is still broken in this regard, but we'll at least be in
a position to use it.
* Allow the use of Ninja or make. The former runs faster in many
environments, and automatically makes use of parallel builds.
This also allows for system installed dependencies--though not through
the Makefile just yet--and adds support for FreeBSD.
This also make us build libuv and luajit as static libraries only, since
we're only concerned about having static libraries for our bundled
dependencies.
Here's the list of squashed commits (for more info, see PR #378).
- Define guicolor_T as a typedef in syntax.h
- Move a big chunk of code from structs.h to buffer_defs.h
- Move aco_save_T from structs.h to fileio.h
- Move option_table_T from structs.h to hardcopy.h
Aditionally:
- Move the printer_opts global to hardcopy.c
- Delete structs.h. Include buffer_defs.h where structs.h was included
before.
- Add header guards to option_defs.h
- Put mark types and constants in new mark_defs.h
- Move undo structs to undo_defs.h
- Move memfile structs to new memfile_defs.h
- Move expand_T and cmdmod_T to ex_cmds_defs.h
- Move memline_T to memline_defs.h
- Move many defs and types to ex_eval.h
- Move syntax related types to syntax_defs.h
- Move struct memfile to memfile_defs.h
- struct buffblock and struct buffheader moved back to buffer_defs.h
- Move some datatypes to hashtab.h and eval_defs.h
- Move the buffer_defs.h include and TODOs for remaining unrelated types in buffer_defs.h
As described in Google's style guide, the basis for Neovim's
> All of a project's header files should be listed as descendants of the
> project's source directory without use of UNIX directory shortcuts .
> (the current directory) or .. (the parent directory).
Add src as an include directory to facilitate this.
- Valgrind configuration removed
- Fix errors reported by the undefined behavior sanitizer
- Travis will now run two build steps:
- A normal build of a shared library for unit testing(in parallel with gcc)
- A clang build with some sanitizers enabled for integration testing.
After these changes travis will run much faster, while providing valgrind-like
error detection.
Testing the public interface mch_can_exe should suffice. Every former
test of is_executable has a counterpart in the tests of mch_can_exe.
Thus we can keep private things private.
Because of the '$' in `if(DEFINED $ENV{VALGRIND_CHECK})` EXITFREE wasn't being
defined, so the `free_all_mem` wasn't being included or called in the resulting
binary.
This commit fixes that, and also adds includes needed for `free_all_mem`
compilation.
Vim [documentation](http://vimdoc.sourceforge.net/htmldoc/hangulin.html), says
that hangul support is scheduled to be removed. I think it's safe to say we
don't want to support a feature even vim is considering removing.
Everything still compiles even after removing the header, so it's not being
used.
Before doing the initial import to neovim's repository, I had to tweak this
module to make it compile for terminal. It was a mistake that is now being
corrected.
- `foldinfo_T` to `fold.h`
- `context_sha256_T` to `sha256.h`
- `tagname_T` to `tag.h`
- `pumitem_T` to `popupmnu.h`
- `prt_*_T` to hardcopy.h`
- `CPT_*` consts to `edit.h`
- `vimmenu_T`, `MNU_HIDDEN_CHAR`, and `MENU_*` constants to `menu.h`
* removed a putenv() implementation which isn't needed anymore
* mch_getenv() and mch_setenv() are now functions in src/os/env.c
* removes direct calls to getenv() and setenv() outside of src/os/env.c
* refactored the logic of get_env_name into mch_getenvname_at_index
* added unittests for the functions in os/env.c
* Rename mch_full_name to mch_get_absolute_path.
* Rename mch_is_full_name to mch_is_absolute_path.
* Add a lot of missing parentheses.
* Remove yoda-conditions for consistency.
* Remove spaces in function declaration.
* Rename mch_FullName to mch_full_name to match the style guide.
* Add mch_full_dir_name, which saves the absolute path of a given
directory relative to cwd into a given buffer.
* Add function append_path, which glues together two given paths with a
slash.
* Adapt moonscript coding style to the tests.
Code under HAVE_STACK_LIMIT is not used.
The definition was commented out in rev 180 of the original
Mercurial repo, and then completely removed in rev 2520,
but the code guarded by it was left in.
This is a squash of all commits sent to #81.
- Remove unused undef of __ARGS.
- Fix mch_rename declaration.
- Follow changes related to moved & extracted files.
- Properly indent function declarations of getchar.h and quickfix.c.
Continue to split misc2.c in many other files (see #209).
The only changed I made to the moved code was adding
`vim_free(ff_expand_buffer)` to `free_finfile()`. This is was needed
because `ff_expand_buffer` was moved from `misc2.c` to `file_search.c`.
It seems clang 3.4 thinks the codebase is in fantastic shape and gcc 4.9.0
has only minor niggles, which I fixed:
- fix uninitialized member warning:
In DEBUG mode the expr member doesn't get properly initialized to NULL.
- fix warnings about directive inside of macro's:
On some platforms/compilers, sprintf is a macro. Putting macro directives
inside of a macro is unportable and gcc 4.9 warns about that.
- fix signed vs. unsigned comparison warning:
The in-memory table will luckily not even come close to the limits imposed
by ssize_t. If it ever reaches that, we've got bigger problems.
When building nvim as a shared library for testing, environ is not
exposed. In order to gain access to the environment variables, you must
get a pointer to them from _NSGetEnviron().
It appears that this may affect the FreeBSD platform too.
On a Mac using shared creates libnvim-test.dylib which cannot be found
by the hardcoded .so extension in helpers.moon, causing the unittests to
fail. However, using module creates libnvim-test.so, allowing the tests
to run. There will still be problems running the tests on windows,
because both shared and module create dll file which will not be found
by in helpers.moon.
Tests will be written using the [moonscript](http://moonscript.org/) language,
a lua 'dialect' that is whitespace-significant and has a syntax similar to
coffeescript. The test framework used is [busted](http://olivinelabs.com/busted/),
a bdd framework for lua/moonscript.
Luajit has a nice ffi module, which lets lua programs link shared libraries and
call it's functions without writing any C code.
To take advantage of this fact for testing C functions, a new target was added
to CMakeLists.txt, which compiles neovim as a shared library that is loaded by
the process running the tests.
This commit adds necessary code for downloading and installing a lua package
manager(luarocks) locally. It wasn't added as a subtree because there are quite
a few blobs in its source tree.
- Some systems have the FindCurses.cmake module to find
the curses/ncurses libraries using find_package(). And
in some CheckLibraries is not very reliable, so as
fallback FindCurses is now used if no other option
works.
As noted in #128, if clock_gettime is provided by librt then it does not
end up being linked into the static libuv.a binary. This might be
considered a bug in libuv but we can address it here.
Detect if librt provides the clock_gettime symbol and, if so, append it
to the list of libraries linked into nvim. On non-librt systems the
behaviour should be as before.
This commit removes a K&R promoted parameter error, the final warning
I have when building.
I realize that this creates only one function that is written in a
different style, but I thought it might be worth it to have a warning
free build.
See #137 for the issue.
Every header in the proto directory was:
* Given include guards in the form
#ifndef NEOVIM_FILENAME_H
#define NEOVIM_FILENAME_H
...
#endif /* NEOVIM_FILENAM_H */
* Renamed from *.pro -> *.h
* Moved from src/proto/ to src/
This would have caused conficts with some existing headers in src/;
rather than merge these conflicts now (which is a whole other can of
worms involving multiple and conditional inclusion), any header in src/
with a conflicting name was renamed from *.h -> *_defs.h (which may or
may not actually describe its purpose, the change is purely a
namespacing issue).
Once all of these changes were made a script was developed to determine
what #includes needed to be added to each source file to describe its
dependencies and allow it to compile; because the script is so short
and I'll just list it here:
#! /bin/bash
cd $(dirname $0)
# Scrapes `make` output for provided error messages and outputs #includes
# needed to resolve them.
# $1 : part of the clang error message between filename and identifier
list_missing_includes() {
for file_missing_pair in $(CC=clang make 2>&1 >/dev/null | sed -n "s/\/\(.*\.[hc]\).*$1.*'\(.*\)'.*/\1:\2/p"); do
fields=(${file_missing_pair//:/ })
source_file=${fields[0]}
missing_func=${fields[1]}
# Try to find the declaration of the missing function.
echo $(basename $source_file) \
\#include \"$(grep -r "\b$missing_func __ARGS" | sed -n "s/.*\/\(.*\)\:.*/\1/p")\"
# Remove duplicates
done | sort | uniq
}
echo "Finding missing function prototypes..."
list_missing_includes "implicit declaration of function"
echo "Finding missing identifier declarations..."
list_missing_includes "use of undeclared identifier"
Each list of required headers was added by hand in the following format:
#include "vim.h"
#include "*_defs.h"
#include "filename.h"
/* All other includes in same module here, in alphabetical order. */
/* All includes from other modules (e.g. "os/*.h") here in alphabetical
* order. */
CMake ships with a standard FindThreads module which can be used to a)
test for a threading library and b) confirm that it is pthread. It also
allows the hard-coding of the threading library name to be removed from
``src/CMakeLists.txt``.
Make it an error not to have a pthread library installed and indicate to
CMake that we strongly prefer pthread to any other platform threading
library.
cproto (http://invisible-island.net/cproto/) was used to do the bulk of
the work in batch; even the most recent version had some issues with
typedef'd parameters; a quick "patch" was to modify `lex.l` to
explicitly include all vim typedefs as known types. One example from
`vim.h` is
typedef unsigned char char_u;
which was added in `lex.l` as
<INITIAL>char_u { save_text_offset(); return T_CHAR; }
Even with these changes there were some problems:
* Two files (`mbyte.c` and `os_unix.c`) were not cleanly converted.
* Any function with the `UNUSED` macro in its parameter list was not converted.
Rather than spend more time fixing the automated approach, the two files
`mbyte.c` and `os_unix.c` were converted by hand.
The `UNUSED` macros were compiler specific, and the alternative, generic
version would require a different syntax, so in order to simplify the
conversion all uses of `UNUSED` were stripped, and then the sources were
run back through cproto. It is planned to reconsider each use of
`UNUSED` manually using a new macro definition.
- remove SELinux dependency for now
- OSX: find libintl.h
- OSX: fix compile errors
- OSX: use hack around gettext nonsense
- fix gettext on ubuntu
- work around Arch's lack of -ltermcap
- add README.md
- Cleanup source tree, leaving only files necessary for compilation/testing
- Process files through unifdef to remove tons of FEAT_* macros
- Process files through uncrustify to normalize source code formatting.
- Port the build system to cmake