aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/buffer.h3
-rw-r--r--src/nvim/buffer_defs.h4
-rw-r--r--src/nvim/ex_cmds_defs.h1
-rw-r--r--src/nvim/ex_eval.h3
-rw-r--r--src/nvim/fileio.c1
-rw-r--r--src/nvim/globals.h1
-rw-r--r--src/nvim/hashtab.h4
-rw-r--r--src/nvim/lib/khash.h1
-rw-r--r--src/nvim/memfile_defs.h2
-rw-r--r--src/nvim/memory.h3
-rw-r--r--src/nvim/message.h1
-rw-r--r--src/nvim/normal.h1
-rw-r--r--src/nvim/os_unix.c1
-rw-r--r--src/nvim/os_unix.h1
-rw-r--r--src/nvim/pos.h6
-rw-r--r--src/nvim/syntax.c1
-rw-r--r--src/nvim/syntax_defs.h2
-rw-r--r--src/nvim/types.h8
-rw-r--r--src/nvim/undo.c1
-rw-r--r--src/nvim/undo_defs.h2
-rw-r--r--src/nvim/vim.h15
-rw-r--r--test/unit/helpers.moon12
-rw-r--r--test/unit/os/fs_spec.moon31
-rw-r--r--test/unit/path_spec.moon37
-rw-r--r--test/unit/preprocess.moon2
25 files changed, 95 insertions, 49 deletions
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h
index 9690d58e0b..a8220c65a0 100644
--- a/src/nvim/buffer.h
+++ b/src/nvim/buffer.h
@@ -1,6 +1,9 @@
#ifndef NVIM_BUFFER_H
#define NVIM_BUFFER_H
+#include "nvim/pos.h" // for linenr_T
+#include "nvim/ex_cmds_defs.h" // for exarg_T
+
/* Values for buflist_getfile() */
#define GETF_SETMARK 0x01 /* set pcmark before jumping */
#define GETF_ALT 0x02 /* jumping to alternate file (not buf num) */
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 9d81388a3c..e827642d8a 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -2,10 +2,12 @@
#define NVIM_BUFFER_DEFS_H
#include <stdbool.h>
+// for FILE
+#include <stdio.h>
// for garray_T
#include "nvim/garray.h"
-// for pos_T and lpos_T
+// for pos_T, lpos_T and linenr_T
#include "nvim/pos.h"
// for the number window-local and buffer-local options
#include "nvim/option_defs.h"
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 1edc1bb8c6..4eafa46c10 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -16,6 +16,7 @@
#include <stdbool.h>
+#include "nvim/pos.h" // for linenr_T
#include "nvim/normal.h"
/*
diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h
index 7523aff792..30871c7711 100644
--- a/src/nvim/ex_eval.h
+++ b/src/nvim/ex_eval.h
@@ -1,6 +1,9 @@
#ifndef NVIM_EX_EVAL_H
#define NVIM_EX_EVAL_H
+#include "nvim/pos.h" // for linenr_T
+#include "nvim/ex_cmds_defs.h" // for exarg_T
+
/*
* A list used for saving values of "emsg_silent". Used by ex_try() to save the
* value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index c867211a66..9b5df80a0c 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -51,6 +51,7 @@
#include "nvim/strings.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
+#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index cdfa882a3e..1f402f3ef9 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -13,6 +13,7 @@
#include "nvim/ex_eval.h"
#include "nvim/mbyte.h"
#include "nvim/menu.h"
+#include "nvim/syntax_defs.h"
/*
* definition of global variables
diff --git a/src/nvim/hashtab.h b/src/nvim/hashtab.h
index 172f5ca13e..7233d8c47c 100644
--- a/src/nvim/hashtab.h
+++ b/src/nvim/hashtab.h
@@ -1,7 +1,9 @@
#ifndef NVIM_HASHTAB_H
#define NVIM_HASHTAB_H
-#include "nvim/vim.h"
+#include <stddef.h>
+
+#include "nvim/types.h"
/// Type for hash number (hash calculation result).
typedef size_t hash_T;
diff --git a/src/nvim/lib/khash.h b/src/nvim/lib/khash.h
index f706e994d5..c9198e048c 100644
--- a/src/nvim/lib/khash.h
+++ b/src/nvim/lib/khash.h
@@ -128,6 +128,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
#include <limits.h>
+#include <stdint.h>
#include "nvim/memory.h"
diff --git a/src/nvim/memfile_defs.h b/src/nvim/memfile_defs.h
index 818246d6db..2e6e914b57 100644
--- a/src/nvim/memfile_defs.h
+++ b/src/nvim/memfile_defs.h
@@ -1,6 +1,8 @@
#ifndef NVIM_MEMFILE_DEFS_H
#define NVIM_MEMFILE_DEFS_H
+#include "nvim/types.h"
+
typedef struct block_hdr bhdr_T;
typedef long blocknr_T;
diff --git a/src/nvim/memory.h b/src/nvim/memory.h
index 3a05797e89..4ff31ff732 100644
--- a/src/nvim/memory.h
+++ b/src/nvim/memory.h
@@ -1,8 +1,7 @@
#ifndef NVIM_MEMORY_H
#define NVIM_MEMORY_H
-#include <stddef.h>
-#include "nvim/vim.h"
+#include <stddef.h> // for size_t
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "memory.h.generated.h"
diff --git a/src/nvim/message.h b/src/nvim/message.h
index f04005a7ad..c620597f33 100644
--- a/src/nvim/message.h
+++ b/src/nvim/message.h
@@ -2,6 +2,7 @@
#define NVIM_MESSAGE_H
#include <stdbool.h>
+#include "nvim/eval_defs.h" // for typval_T
/*
* Types of dialogs passed to do_dialog().
diff --git a/src/nvim/normal.h b/src/nvim/normal.h
index 341da6d473..599f4771b9 100644
--- a/src/nvim/normal.h
+++ b/src/nvim/normal.h
@@ -2,6 +2,7 @@
#define NVIM_NORMAL_H
#include "nvim/pos.h"
+#include "nvim/buffer_defs.h" // for win_T
/* Values for find_ident_under_cursor() */
#define FIND_IDENT 1 /* find identifier (word) */
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 4a0fbf5c18..9e7940bc2a 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -54,6 +54,7 @@
#include "nvim/syntax.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
+#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
diff --git a/src/nvim/os_unix.h b/src/nvim/os_unix.h
index 5610fe68eb..5a3eb84ba4 100644
--- a/src/nvim/os_unix.h
+++ b/src/nvim/os_unix.h
@@ -1,6 +1,7 @@
#ifndef NVIM_OS_UNIX_H
#define NVIM_OS_UNIX_H
+#include "nvim/types.h" // for vim_acl_T
#include "nvim/os/shell.h"
/* Values returned by mch_nodetype() */
diff --git a/src/nvim/pos.h b/src/nvim/pos.h
index 11f62ad480..7cfb52b283 100644
--- a/src/nvim/pos.h
+++ b/src/nvim/pos.h
@@ -1,6 +1,12 @@
#ifndef NVIM_POS_H
#define NVIM_POS_H
+typedef long linenr_T; // line number type
+typedef int colnr_T; // column number type
+
+#define MAXLNUM (0x7fffffffL) // maximum (invalid) line number
+#define MAXCOL (0x7fffffffL) // maximum column number, 31 bits
+
/*
* position in file or buffer
*/
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 51aeda7293..7dd3453d16 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -42,6 +42,7 @@
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
+#include "nvim/syntax_defs.h"
#include "nvim/term.h"
#include "nvim/ui.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h
index d8ef007ffc..11e342f870 100644
--- a/src/nvim/syntax_defs.h
+++ b/src/nvim/syntax_defs.h
@@ -9,6 +9,8 @@
# define SST_DIST 16 /* normal distance between entries */
# define SST_INVALID (synstate_T *)-1 /* invalid syn_state pointer */
+typedef unsigned short disptick_T; /* display tick type */
+
/* struct passed to in_id_list() */
struct sp_syn {
int inc_tag; /* ":syn include" unique tag */
diff --git a/src/nvim/types.h b/src/nvim/types.h
index 3bc6bfb9bf..ad905aa95b 100644
--- a/src/nvim/types.h
+++ b/src/nvim/types.h
@@ -10,6 +10,14 @@
#include <stdint.h>
+// dummy to pass an ACL to a function
+typedef void *vim_acl_T;
+
+// Make sure long_u is big enough to hold a pointer.
+// On Win64, longs are 32 bits and pointers are 64 bits.
+// For printf() and scanf(), we need to take care of long_u specifically.
+typedef unsigned long long_u;
+
/*
* Shorthand for unsigned variables. Many systems, but not all, have u_char
* already defined, so we use char_u to avoid trouble.
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index b9f3309cef..96b83a3e2d 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -107,6 +107,7 @@
#include "nvim/screen.h"
#include "nvim/sha256.h"
#include "nvim/strings.h"
+#include "nvim/types.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h
index 6263dd91d4..2579f13b93 100644
--- a/src/nvim/undo_defs.h
+++ b/src/nvim/undo_defs.h
@@ -1,6 +1,8 @@
#ifndef NVIM_UNDO_DEFS_H
#define NVIM_UNDO_DEFS_H
+#include <time.h> // for time_t
+
#include "nvim/pos.h"
/* Structure to store info about the Visual area. */
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 63b9436da7..e324a8bedc 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -9,6 +9,7 @@
# define NVIM_VIM_H
#include "nvim/types.h"
+#include "nvim/pos.h" // for linenr_T, MAXCOL, etc...
/* Some defines from the old feature.h */
#define SESSION_FILE "Session.vim"
@@ -58,11 +59,6 @@ Error: configure did not run properly.Check auto/config.log.
#define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */
-// Make sure long_u is big enough to hold a pointer.
-// On Win64, longs are 32 bits and pointers are 64 bits.
-// For printf() and scanf(), we need to take care of long_u specifically.
-typedef unsigned long long_u;
-
# define MAX_TYPENR 65535
/*
@@ -359,18 +355,9 @@ enum {
#define PERROR(msg) \
(void) emsg3((char_u *) "%s: %s", (char_u *)msg, (char_u *)strerror(errno))
-typedef long linenr_T; /* line number type */
-typedef int colnr_T; /* column number type */
-typedef unsigned short disptick_T; /* display tick type */
-
-#define MAXLNUM (0x7fffffffL) /* maximum (invalid) line number */
-#define MAXCOL (0x7fffffffL) /* maximum column number, 31 bits */
-
#define SHOWCMD_COLS 10 /* columns needed by shown command */
#define STL_MAX_ITEM 80 /* max nr of %<flag> in statusline */
-typedef void *vim_acl_T; /* dummy to pass an ACL to a function */
-
/*
* fnamecmp() is used to compare file names.
* On some systems case in a file name does not matter, on others it does.
diff --git a/test/unit/helpers.moon b/test/unit/helpers.moon
index 84dfeb20e9..438f36811c 100644
--- a/test/unit/helpers.moon
+++ b/test/unit/helpers.moon
@@ -97,6 +97,17 @@ cstr = ffi.typeof 'char[?]'
to_cstr = (string) ->
cstr (string.len string) + 1, string
+export vim_init_called
+-- initialize some global variables, this is still necessary to unit test
+-- functions that rely on global state.
+vim_init = ->
+ if vim_init_called ~= nil
+ return
+ -- import os_unix.h for mch_early_init(), which initializes some globals
+ os = cimport './src/nvim/os_unix.h'
+ os.mch_early_init!
+ vim_init_called = true
+
return {
cimport: cimport
cppimport: cppimport
@@ -107,4 +118,5 @@ return {
lib: libnvim
cstr: cstr
to_cstr: to_cstr
+ vim_init: vim_init
}
diff --git a/test/unit/os/fs_spec.moon b/test/unit/os/fs_spec.moon
index a1445aeb0c..6d87cb95df 100644
--- a/test/unit/os/fs_spec.moon
+++ b/test/unit/os/fs_spec.moon
@@ -57,37 +57,6 @@ describe 'fs function', ->
buf = cstr (len-1), ''
eq FAIL, (os_dirname buf, (len-1))
- describe 'path_full_dir_name', ->
- path_full_dir_name = (directory, buffer, len) ->
- directory = to_cstr directory
- fs.path_full_dir_name directory, buffer, len
-
- before_each ->
- -- Create empty string buffer which will contain the resulting path.
- export len = (string.len lfs.currentdir!) + 22
- export buffer = cstr len, ''
-
- it 'returns the absolute directory name of a given relative one', ->
- result = path_full_dir_name '..', buffer, len
- eq OK, result
- old_dir = lfs.currentdir!
- lfs.chdir '..'
- expected = lfs.currentdir!
- lfs.chdir old_dir
- eq expected, (ffi.string buffer)
-
- it 'returns the current directory name if the given string is empty', ->
- eq OK, (path_full_dir_name '', buffer, len)
- eq lfs.currentdir!, (ffi.string buffer)
-
- it 'fails if the given directory does not exist', ->
- eq FAIL, path_full_dir_name('does_not_exist', buffer, len)
-
- it 'works with a normal relative dir', ->
- result = path_full_dir_name('unit-test-directory', buffer, len)
- eq lfs.currentdir! .. '/unit-test-directory', (ffi.string buffer)
- eq OK, result
-
os_isdir = (name) ->
fs.os_isdir (to_cstr name)
diff --git a/test/unit/path_spec.moon b/test/unit/path_spec.moon
index 762bad09a2..4a4170e463 100644
--- a/test/unit/path_spec.moon
+++ b/test/unit/path_spec.moon
@@ -10,6 +10,43 @@ OK = 1
FAIL = 0
describe 'path function', ->
+ describe 'path_full_dir_name', ->
+ setup ->
+ lfs.mkdir 'unit-test-directory'
+
+ teardown ->
+ lfs.rmdir 'unit-test-directory'
+
+ path_full_dir_name = (directory, buffer, len) ->
+ directory = to_cstr directory
+ path.path_full_dir_name directory, buffer, len
+
+ before_each ->
+ -- Create empty string buffer which will contain the resulting path.
+ export len = (string.len lfs.currentdir!) + 22
+ export buffer = cstr len, ''
+
+ it 'returns the absolute directory name of a given relative one', ->
+ result = path_full_dir_name '..', buffer, len
+ eq OK, result
+ old_dir = lfs.currentdir!
+ lfs.chdir '..'
+ expected = lfs.currentdir!
+ lfs.chdir old_dir
+ eq expected, (ffi.string buffer)
+
+ it 'returns the current directory name if the given string is empty', ->
+ eq OK, (path_full_dir_name '', buffer, len)
+ eq lfs.currentdir!, (ffi.string buffer)
+
+ it 'fails if the given directory does not exist', ->
+ eq FAIL, path_full_dir_name('does_not_exist', buffer, len)
+
+ it 'works with a normal relative dir', ->
+ result = path_full_dir_name('unit-test-directory', buffer, len)
+ eq lfs.currentdir! .. '/unit-test-directory', (ffi.string buffer)
+ eq OK, result
+
describe 'path_full_compare', ->
path_full_compare = (s1, s2, cn) ->
diff --git a/test/unit/preprocess.moon b/test/unit/preprocess.moon
index aa74b8ce24..cb734da2f7 100644
--- a/test/unit/preprocess.moon
+++ b/test/unit/preprocess.moon
@@ -85,6 +85,8 @@ class Gcc
'-D "__asm(ARGS)="',
'-D "__asm__(ARGS)="',
'-D "__inline__="',
+ '-D "EXTERN=extern"',
+ '-D "INIT(...)="',
'-D_GNU_SOURCE',
'-DINCLUDE_GENERATED_DECLARATIONS'
}