From f5d12889e80d3369359b8248806694cf6d21f820 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 6 Jun 2023 14:00:32 +0200 Subject: [PATCH] refactor: adjust headers according to the style guide (#23934) System headers should be included first to prevent naming conflicts. --- src/nvim/buffer.h | 2 +- src/nvim/buffer_defs.h | 4 +--- src/nvim/os/fs.c | 24 +++++++++++++----------- src/nvim/os/os_defs.h | 12 ++++++------ src/nvim/os/process.c | 14 ++++++++------ src/nvim/os/pty_process_unix.c | 3 +-- src/nvim/os/pty_process_win.c | 2 +- src/nvim/os/signal.c | 2 +- src/nvim/undo_defs.h | 2 +- 9 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 610d9e37ec..1bca08e357 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -10,7 +10,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" -#include "nvim/grid_defs.h" // for StlClickRecord +#include "nvim/grid_defs.h" #include "nvim/macros.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index e3e457cea6..d92d425ed5 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -18,6 +18,7 @@ typedef struct { #include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/eval/typval_defs.h" +#include "nvim/extmark_defs.h" #include "nvim/garray.h" #include "nvim/grid_defs.h" #include "nvim/hashtab.h" @@ -25,9 +26,6 @@ typedef struct { #include "nvim/map.h" #include "nvim/mark_defs.h" #include "nvim/marktree.h" -// for float window title -#include "nvim/extmark_defs.h" -// for click definitions #include "nvim/option_defs.h" #include "nvim/pos.h" #include "nvim/statusline_defs.h" diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index d270f8767e..6c3eca8961 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -14,6 +14,19 @@ #include #include +#ifdef MSWIN +# include +#endif + +#if defined(HAVE_ACL) +# ifdef HAVE_SYS_ACL_H +# include +# endif +# ifdef HAVE_SYS_ACCESS_H +# include +# endif +#endif + #include "auto/config.h" #include "nvim/ascii.h" #include "nvim/gettext.h" @@ -731,15 +744,6 @@ int os_setperm(const char *const name, int perm) return (r == kLibuvSuccess ? OK : FAIL); } -#if defined(HAVE_ACL) -# ifdef HAVE_SYS_ACL_H -# include -# endif -# ifdef HAVE_SYS_ACCESS_H -# include -# endif -#endif - // Return a pointer to the ACL of file "fname" in allocated memory. // Return NULL if the ACL is not available for whatever reason. vim_acl_T os_get_acl(const char *fname) @@ -1225,8 +1229,6 @@ char *os_realpath(const char *name, char *buf) } #ifdef MSWIN -# include - /// When "fname" is the name of a shortcut (*.lnk) resolve the file it points /// to and return that name in allocated memory. /// Otherwise NULL is returned. diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index c595013a21..1e0f5b77f8 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -7,6 +7,12 @@ #include #include +// Note: Some systems need both string.h and strings.h (Savage). +#include +#ifdef HAVE_STRINGS_H +# include +#endif + #ifdef MSWIN # include "nvim/os/win_defs.h" #else @@ -36,12 +42,6 @@ // Command-processing buffer. Use large buffers for all platforms. #define CMDBUFFSIZE 1024 -// Note: Some systems need both string.h and strings.h (Savage). -#include -#ifdef HAVE_STRINGS_H -# include -#endif - /// Converts libuv error (negative int) to error description string. #define os_strerror uv_strerror diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index 98ae251e2b..a636689f97 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -13,14 +13,8 @@ #include #include -#include "nvim/log.h" -#include "nvim/memory.h" -#include "nvim/os/process.h" - #ifdef MSWIN # include - -# include "nvim/api/private/helpers.h" #endif #if defined(__FreeBSD__) // XXX: OpenBSD ? @@ -38,6 +32,14 @@ # include #endif +#include "nvim/log.h" +#include "nvim/memory.h" +#include "nvim/os/process.h" + +#ifdef MSWIN +# include "nvim/api/private/helpers.h" +#endif + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/process.c.generated.h" // IWYU pragma: export #endif diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index 2413f0339b..b5423c59d7 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -11,6 +11,7 @@ #include #include #include +#include // forkpty is not in POSIX, so headers are platform-specific #if defined(__FreeBSD__) || defined(__DragonFly__) @@ -31,8 +32,6 @@ # include #endif -#include - #include "auto/config.h" #include "klib/klist.h" #include "nvim/eval/typval.h" diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index a8330acd54..abeb020645 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -7,7 +7,7 @@ #include "nvim/ascii.h" #include "nvim/eval/typval.h" -#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8 +#include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/os/os.h" #include "nvim/os/pty_conpty_win.h" diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index e7b745fb7e..56fd2125c2 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -5,7 +5,7 @@ #include #include #ifndef MSWIN -# include // for sigset_t +# include #endif #include "nvim/autocmd.h" diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index 7c065c540b..7947bff6e6 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -1,7 +1,7 @@ #ifndef NVIM_UNDO_DEFS_H #define NVIM_UNDO_DEFS_H -#include // for time_t +#include #include "nvim/extmark_defs.h" #include "nvim/mark_defs.h"