Commit Graph

1291 Commits

Author SHA1 Message Date
Nicolas Hillegeer
06ca70b191 test/fs: move tests of path_full_dir_name to path
Move tests of path_full_dir_name to path_spec. It is only defined in path.h.
Not sure why this works most of the time (I can only trigger a failure when
running under lldb).

It's a more logical place to have the test as well.
2014-07-16 19:05:35 +02:00
Nicolas Hillegeer
c376cf46bf test/helpers: add 'vim_init' helper
- Initializes some global variables.
- Necessary for the buffer tests in PR #904.
2014-07-16 19:05:35 +02:00
Nicolas Hillegeer
32ddfec84f memory.h: don't include vim.h in header files
Also include stdint.h in khash.h. It was transitively included by vim.h via
memory.h before. khash.h accidentally relied on that.
2014-07-16 19:05:35 +02:00
Nicolas Hillegeer
1710fa4337 vim: move vim_acl_T to types.h
Also include "types.h" in os_unix.h because it declares functions that
return vim_acl_T.
2014-07-16 19:05:35 +02:00
Nicolas Hillegeer
109c70dc60 test/preprocess: always declare EXTERN
Unit tests never need to declare globals, only access them. In the main code
base this is handled by including "vim.h". If a file wants to declare
globals (in the case of neovim that's only main.c), it #define's EXTERN and
includes "vim.h". Otherwise, a file just includes "vim.h" (that's the
majority case). Since we want to be able to run unit tests without including
"vim.h", we predefine "EXTERN" to mean extern. That way, we don't have to
include "vim.h".
2014-07-16 19:05:35 +02:00
Nicolas Hillegeer
0564f781ab vim: move disptick_T from vim.h to syntax_defs.h
Make vim.h smaller, bit by bit.
2014-07-16 19:05:34 +02:00
Nicolas Hillegeer
e288ddaee7 vim: move linenr_T and colnr_T to pos.h
Try to cut down vim.h's size. It's keeping us from testing more things.
2014-07-16 19:05:34 +02:00
Nicolas Hillegeer
fb72f1ee37 vim: move long_u from vim.h to types.h
Seems to make no difference to the main binary, but it helps the tests a bit
further along.
2014-07-16 19:05:34 +02:00
Nicolas Hillegeer
08fad0f8f6 hashtab.h: don't include vim.h
Including vim.h in another header filer is asking for trouble. Test code
that includes separate header files (e.g.: cimport './src/nvim/buffer.h'),
has a really bad time with this. This is just one piece of the puzzle
though.
2014-07-16 19:05:34 +02:00
Justin M. Keyes
90a206d332 doc: add clang analysis badge to README.md 2014-07-16 12:53:38 -04:00
Justin M. Keyes
0412c17a65 Merge pull request #839 from aktau/platform-abstract-time-fn
viml: impl profiling on top of uv_hrtime()
2014-07-16 12:46:07 -04:00
Nicolas Hillegeer
6d0f9417ec profiling: add tests
Some functions are missing:

- profile_self
- profile_get_wait
- profile_set_wait
- profile_sub_wait
2014-07-16 17:12:35 +02:00
Nicolas Hillegeer
9386f5d41e profiling: move static to function scope
It wasn't used anywhere else, our coding guidelines mandate the tightest
scope possible.
2014-07-16 17:12:35 +02:00
Nicolas Hillegeer
db7cd61f62 profiling: implement on top of os_hrtime()
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/...
2014-07-16 17:12:34 +02:00
Nicolas Hillegeer
f172b19f43 os: implement os_hrtime
Just an alias to uv_hrtime. Provides a high-resolution timer.
2014-07-16 17:12:34 +02:00
Nicolas Hillegeer
095b4479c0 assert: add STATIC_ASSERT macro
Can be quite handy, attempt to provide fallbacks for compilers that don't
support _Static_assert (which is technically a C11 feature). Suppress
warnings as best we can (Clang and GCC warn that we're using a C11 feature
while in C99 mode).

Needs to be tested for MSVC still.
2014-07-16 17:12:34 +02:00
John Szakmeister
e1075ffff9 Merge #947 'Remove Clang 3.4 installation in travis.sh.' 2014-07-16 06:01:15 -04:00
Florian Walch
5433694db3 travis.sh: Simplify clang/asan build.
* Clang 3.4 now default on Travis CI.
* Introduce config variable to download & use different clang version.
2014-07-16 06:01:02 -04:00
Florian Walch
2cae6919dc travis.sh: Use dependencies from neovim/deps. 2014-07-16 06:01:02 -04:00
Florian Walch
58e85fca02 travis.sh: Fix mixed tabs/whitespace formatting. 2014-07-16 06:01:02 -04:00
Nicolas Hillegeer
25f3cedfe6 Merge #813 'Add platform checks to replace config.h.in hardcoded values' 2014-07-15 10:44:31 +02:00
Rui Abreu Ferreira
99e60f6242 Clean up DEBUG check in config.h.in 2014-07-15 10:43:21 +02:00
Rui Abreu Ferreira
feffc65270 Add cmake platform checks
- Defined CMake checks for all headers in config.h.in
- Removed headers checks that are not used anymore:
  sgtty.h sys/statfs.h libintl.h poll.h
- Added UNIX check
- Add some fatal checks
  + Check for setenv() and fail if it does not exist
    since our os layer just assumes it does
  + lstat is required by os_unix.c
  + sys/wait.h is required in UNIX
- Removed entries for functions that are not being used: getcwd,
  getrlimit, getwd, nanosleep, sigaltstack, getwd, sigstack, fseeko
- Replaced nearly all defines in config.h.in for functions with
  compile time checks
- Add check for symbol FD_CLOEXEC
- Add check for langinfo CODESET
- HAVE_ICONV_H and HAVE_ICONV hold the expected checks but Neovim uses
  USE_ICONV define to actually decide whether to enable it
- Removed checks that are no longer needed
  + USEMEMMOVE
  + _FILE_OFFSET_BITS
  + HAVE_ST_BLKSIZE
  + dlfcn.h
2014-07-15 10:43:21 +02:00
oni-link
510db30376 Add more commented patch numbers to version.c (3) #940
This should help reduce conflicts when merging patches from upstream.
2014-07-14 17:39:50 -04:00
Nicolas Hillegeer
2b62dcddf8 Merge #850 'impl mkdtemp for windows, refactor vim_tempname' 2014-07-14 21:17:39 +02:00
Pavel Platto
14239ae331 Create os/os_defs.h for os specific definitions 2014-07-14 21:14:40 +02:00
Pavel Platto
8e2b570d6f tempfile.c: refactor vim_settempdir
- return result of setting and remove directory if the setting was not
  successful.
- don't do `STRCPY` in case of `vim_FullName` failure because
  `vim_FullName` already did it.
2014-07-14 21:14:40 +02:00
Pavel Platto
0e49e16c4e tempfile.c: fix style issues and comments 2014-07-14 21:14:40 +02:00
Pavel Platto
820694adb4 tempfile.c: enable -Wconversion 2014-07-14 21:14:40 +02:00
Pavel Platto
34330cf697 tempfile.c: add to clint-files and fix warnings 2014-07-14 21:14:40 +02:00
Pavel Platto
790d81582c tempfile.c: add tests 2014-07-14 21:14:40 +02:00
Pavel Platto
286ce271e7 Extract tempfile module from fileio
Though this module is relatively small it has very clear boundaries.
The last argument for extracting `tempfile` was the errors which I got
when I was writing unittests for it: `cimport './src/nvim/fileio.h'`
does not work for some reason.
2014-07-14 21:14:40 +02:00
Pavel Platto
8cfa7b3d15 Add vim_gettempdir(), remove global vim_tempdir
vim_gettempdir() and vim_maketempdir() was extracted from
vim_tempname().
2014-07-14 21:14:40 +02:00
Pavel Platto
29e0cd1571 Refactor vim_tempname
- temp_count is uint32_t now instead of long because it supposed to be
  at most 999999999 (comment on line 5227) temporary files. The most
  probably it was a long for compatibility with systems where int is
  16-bit.
- Use "nvim" as prefix for temp folder name instead of "v"
- Remove unused parameter from vim_tempname
2014-07-14 21:14:40 +02:00
Pavel Platto
edd7a8c5dd Remove #ifdefs TEMPDIRNAMES and add TEMPDIRNAMES for Windows
Vim does not define TEMPDIRNAMES for all systems, but it is defined for
all systems supported by Neovim.
Temporary directory names for Windows was obtained from GetTempPath()
function documentation at MSDN.
Additionally small renamings were performed.
2014-07-14 21:14:39 +02:00
Pavel Platto
ed10eb6fa9 Remove USE_TMPNAM
tmpnam() is deprecated.
2014-07-14 21:14:39 +02:00
Pavel Platto
f9710fba52 Remove HAVE_MKDTEMP
For now we provide simple `mkdtemp` for Windows, in the future we will
use libuv for that.
2014-07-14 21:14:39 +02:00
Pavel Platto
8b91ba929b Temporary os_mkdtemp implementation. Use it instead of mkdtemp. 2014-07-14 21:14:39 +02:00
Pavel Platto
47084ea765 Use strict function prototypes #945
`-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.
2014-07-14 20:28:40 +02:00
Pavel Platto
2dc69700ec Use default busted pattern for unittests #943
- Unittest should contain substring '_spec' in filename.
- This is the simplest way to use both lua and moonscript tests.
- This prevents running of non-test scripts from test folder.
2014-07-14 20:08:39 +02:00
Justin M. Keyes
f693b4043d Merge #846 'impl mch_open with libuv' 2014-07-14 09:06:36 -04:00
Justin M. Keyes
0ceebc2c91 os_open: add unit tests 2014-07-14 09:05:52 -04:00
Justin M. Keyes
180c84ed37 os_open: impl mch_open with libuv. ref #133
- use return value instead of open_req.result
- libuv uv_fs_open() returns `-errno` instead of always -1
- libuv always sets open_req.result to the return value, _except_ for OOM
  where it only sets the return value. So always use the return value.
- replace calls to mch_open macro.
- update call sites expecting -1 error
2014-07-14 09:04:54 -04:00
Nicolas Hillegeer
bf6b0e3c0a Merge #874 'fix TCP connection (issue #870)' 2014-07-13 14:20:46 +02:00
André Twupack
f44e908c11 os/server: Fix possible port overflow
- add documentation about port being optional
- parse port into long and check for valid value
2014-07-13 14:20:18 +02:00
André Twupack
fa5615022c os/server: Fix TCP connection
- remove unused errno
- remove unused port_end
- correct calculation of addr_len
- use correct string length during IP copy
2014-07-13 14:20:18 +02:00
André Twupack
7c473dc0a2 os/server: Fix indentation 2014-07-13 14:20:18 +02:00
Nicolas Hillegeer
5d53c51fae Merge #837 'Move defines from vim.h - phase2' 2014-07-12 14:28:58 +02:00
Brandon Coleman
a32df5e734 move defines from vim.h
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.
2014-07-12 14:26:55 +02:00
John Szakmeister
77db0b2bba Merge #932 'Check lua dependencies for all lua interpreters' 2014-07-11 19:29:26 -04:00