From 08fad0f8f6601e93b325990b4d3bba8533f34c2f Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sun, 6 Jul 2014 16:54:59 +0200 Subject: 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. --- src/nvim/hashtab.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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 + +#include "nvim/types.h" /// Type for hash number (hash calculation result). typedef size_t hash_T; -- cgit From fb72f1ee37872137c19297268e3cc2a05f27c357 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sun, 6 Jul 2014 17:13:28 +0200 Subject: 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. --- src/nvim/memfile_defs.h | 2 ++ src/nvim/types.h | 5 +++++ src/nvim/vim.h | 5 ----- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') 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/types.h b/src/nvim/types.h index 3bc6bfb9bf..a3c4509756 100644 --- a/src/nvim/types.h +++ b/src/nvim/types.h @@ -10,6 +10,11 @@ #include +// 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/vim.h b/src/nvim/vim.h index 63b9436da7..1ff49c8011 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -58,11 +58,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 /* -- cgit From e288ddaee7d9c186c5829178691dbfac507d757d Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sun, 6 Jul 2014 17:27:09 +0200 Subject: 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. --- src/nvim/buffer.h | 2 ++ src/nvim/ex_cmds_defs.h | 1 + src/nvim/ex_eval.h | 2 ++ src/nvim/pos.h | 6 ++++++ src/nvim/vim.h | 6 +----- 5 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 9690d58e0b..493ebffc63 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -1,6 +1,8 @@ #ifndef NVIM_BUFFER_H #define NVIM_BUFFER_H +#include "nvim/pos.h" // for linenr_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/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 +#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..3f5e295c18 100644 --- a/src/nvim/ex_eval.h +++ b/src/nvim/ex_eval.h @@ -1,6 +1,8 @@ #ifndef NVIM_EX_EVAL_H #define NVIM_EX_EVAL_H +#include "nvim/pos.h" // for linenr_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/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/vim.h b/src/nvim/vim.h index 1ff49c8011..5cde6e7989 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" @@ -354,13 +355,8 @@ 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 % in statusline */ -- cgit From 0564f781ab27aa7b419543f7867da6e761e179c5 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sun, 6 Jul 2014 17:36:31 +0200 Subject: vim: move disptick_T from vim.h to syntax_defs.h Make vim.h smaller, bit by bit. --- src/nvim/globals.h | 1 + src/nvim/syntax.c | 1 + src/nvim/syntax_defs.h | 2 ++ src/nvim/vim.h | 2 -- 4 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') 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/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/vim.h b/src/nvim/vim.h index 5cde6e7989..6bdc58c54a 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -355,8 +355,6 @@ enum { #define PERROR(msg) \ (void) emsg3((char_u *) "%s: %s", (char_u *)msg, (char_u *)strerror(errno)) -typedef unsigned short disptick_T; /* display tick type */ - #define SHOWCMD_COLS 10 /* columns needed by shown command */ #define STL_MAX_ITEM 80 /* max nr of % in statusline */ -- cgit From 1710fa43376f4844abe056b3f87aece1845ff89a Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sat, 12 Jul 2014 19:16:41 +0200 Subject: 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. --- src/nvim/fileio.c | 1 + src/nvim/os_unix.c | 1 + src/nvim/os_unix.h | 1 + src/nvim/types.h | 3 +++ src/nvim/undo.c | 1 + src/nvim/vim.h | 2 -- 6 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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/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/types.h b/src/nvim/types.h index a3c4509756..ad905aa95b 100644 --- a/src/nvim/types.h +++ b/src/nvim/types.h @@ -10,6 +10,9 @@ #include +// 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. 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/vim.h b/src/nvim/vim.h index 6bdc58c54a..e324a8bedc 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -358,8 +358,6 @@ enum { #define SHOWCMD_COLS 10 /* columns needed by shown command */ #define STL_MAX_ITEM 80 /* max nr of % 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. -- cgit From 32ddfec84f9335673e38b31950544a24304697f8 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sat, 12 Jul 2014 19:35:57 +0200 Subject: 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. --- src/nvim/lib/khash.h | 1 + src/nvim/memory.h | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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 #include #include +#include #include "nvim/memory.h" 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 -#include "nvim/vim.h" +#include // for size_t #ifdef INCLUDE_GENERATED_DECLARATIONS # include "memory.h.generated.h" -- cgit From 7c6079f6f0d0fc59dd747c2ecd9e1e1ca1e0e66d Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Sat, 12 Jul 2014 20:13:56 +0200 Subject: vim: include used definitions in headers This is not an exhaustive commit, it merely ameliorates the situations a bit. There are quite a few header files that don't include all the types they use in their function/struct/... definitions. This throws of the testing infrastructure (but is not such a problem for the main binary that has the "tumbleweed of includes"-phenomenon). --- src/nvim/buffer.h | 1 + src/nvim/buffer_defs.h | 4 +++- src/nvim/ex_eval.h | 1 + src/nvim/message.h | 1 + src/nvim/normal.h | 1 + src/nvim/undo_defs.h | 2 ++ 6 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 493ebffc63..a8220c65a0 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -2,6 +2,7 @@ #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 */ 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 +// for FILE +#include // 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_eval.h b/src/nvim/ex_eval.h index 3f5e295c18..30871c7711 100644 --- a/src/nvim/ex_eval.h +++ b/src/nvim/ex_eval.h @@ -2,6 +2,7 @@ #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 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 +#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/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 // for time_t + #include "nvim/pos.h" /* Structure to store info about the Visual area. */ -- cgit