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: refactor: adjust headers according to the style guide (#23934) System headers should be included first to prevent naming conflicts. --- src/nvim/undo_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/undo_defs.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" -- cgit From fcf3519c65a2d6736de437f686e788684a6c8564 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 17 Apr 2023 22:18:58 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/undo_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/undo_defs.h') diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index 7947bff6e6..9cc2e4a52b 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -56,7 +56,7 @@ struct u_header { u_entry_T *uh_entry; // pointer to first entry u_entry_T *uh_getbot_entry; // pointer to where ue_bot must be set pos_T uh_cursor; // cursor position before saving - long uh_cursor_vcol; + colnr_T uh_cursor_vcol; int uh_flags; // see below fmark_T uh_namedm[NMARKS]; // marks before undo/after redo extmark_undo_vec_t uh_extmark; // info to move extmarks -- cgit From e72b546354cd90bf0cd8ee6dd045538d713009ad Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/undo_defs.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/nvim/undo_defs.h') diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index 9cc2e4a52b..aa7d6e3355 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -26,7 +26,7 @@ struct u_entry { linenr_T ue_bot; // number of line below undo block linenr_T ue_lcount; // linecount when u_save called char **ue_array; // array of lines in undo block - long ue_size; // number of lines in ue_array + linenr_T ue_size; // number of lines in ue_array #ifdef U_DEBUG int ue_magic; // magic number to check allocation #endif @@ -51,19 +51,19 @@ struct u_header { u_header_T *ptr; // pointer to previous header for alt. redo long seq; } uh_alt_prev; - long uh_seq; // sequence number, higher == newer undo + int uh_seq; // sequence number, higher == newer undo int uh_walk; // used by undo_time() - u_entry_T *uh_entry; // pointer to first entry + u_entry_T *uh_entry; // pointer to first entry u_entry_T *uh_getbot_entry; // pointer to where ue_bot must be set pos_T uh_cursor; // cursor position before saving colnr_T uh_cursor_vcol; - int uh_flags; // see below - fmark_T uh_namedm[NMARKS]; // marks before undo/after redo + int uh_flags; // see below + fmark_T uh_namedm[NMARKS]; // marks before undo/after redo extmark_undo_vec_t uh_extmark; // info to move extmarks - visualinfo_T uh_visual; // Visual areas before undo/after redo - time_t uh_time; // timestamp when the change was made - long uh_save_nr; // set when the file was saved after the - // changes in this block + visualinfo_T uh_visual; // Visual areas before undo/after redo + time_t uh_time; // timestamp when the change was made + int uh_save_nr; // set when the file was saved after the + // changes in this block #ifdef U_DEBUG int uh_magic; // magic number to check allocation #endif -- cgit From 8e932480f61d6101bf8bea1abc07ed93826221fd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/undo_defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/undo_defs.h') diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index aa7d6e3355..7dd29d3ea4 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -37,19 +37,19 @@ struct u_header { // the undo file in u_read_undo() union { u_header_T *ptr; // pointer to next undo header in list - long seq; + int seq; } uh_next; union { u_header_T *ptr; // pointer to previous header in list - long seq; + int seq; } uh_prev; union { u_header_T *ptr; // pointer to next header for alt. redo - long seq; + int seq; } uh_alt_next; union { u_header_T *ptr; // pointer to previous header for alt. redo - long seq; + int seq; } uh_alt_prev; int uh_seq; // sequence number, higher == newer undo int uh_walk; // used by undo_time() -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/undo_defs.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/undo_defs.h') diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index 7dd29d3ea4..de925c3937 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -1,5 +1,4 @@ -#ifndef NVIM_UNDO_DEFS_H -#define NVIM_UNDO_DEFS_H +#pragma once #include @@ -73,5 +72,3 @@ struct u_header { #define UH_CHANGED 0x01 // b_changed flag before undo/after redo #define UH_EMPTYBUF 0x02 // buffer was empty #define UH_RELOAD 0x04 // buffer was reloaded - -#endif // NVIM_UNDO_DEFS_H -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/undo_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/undo_defs.h') diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index de925c3937..3e745ab4dc 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -4,7 +4,7 @@ #include "nvim/extmark_defs.h" #include "nvim/mark_defs.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" typedef struct u_header u_header_T; -- cgit From a6cba103cebce535279db197f9efeb34e9d1171f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 20:32:40 +0800 Subject: refactor: move some constants out of vim_defs.h (#26298) --- src/nvim/undo_defs.h | 71 ++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 33 deletions(-) (limited to 'src/nvim/undo_defs.h') diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index 3e745ab4dc..0b78ea543f 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -6,28 +6,31 @@ #include "nvim/mark_defs.h" #include "nvim/pos_defs.h" +/// Size in bytes of the hash used in the undo file. +enum { UNDO_HASH_SIZE = 32, }; + typedef struct u_header u_header_T; -// Structure to store info about the Visual area. +/// Structure to store info about the Visual area. typedef struct { - pos_T vi_start; // start pos of last VIsual - pos_T vi_end; // end position of last VIsual - int vi_mode; // VIsual_mode of last VIsual - colnr_T vi_curswant; // MAXCOL from w_curswant + pos_T vi_start; ///< start pos of last VIsual + pos_T vi_end; ///< end position of last VIsual + int vi_mode; ///< VIsual_mode of last VIsual + colnr_T vi_curswant; ///< MAXCOL from w_curswant } visualinfo_T; #include "nvim/buffer_defs.h" typedef struct u_entry u_entry_T; struct u_entry { - u_entry_T *ue_next; // pointer to next entry in list - linenr_T ue_top; // number of line above undo block - linenr_T ue_bot; // number of line below undo block - linenr_T ue_lcount; // linecount when u_save called - char **ue_array; // array of lines in undo block - linenr_T ue_size; // number of lines in ue_array + u_entry_T *ue_next; ///< pointer to next entry in list + linenr_T ue_top; ///< number of line above undo block + linenr_T ue_bot; ///< number of line below undo block + linenr_T ue_lcount; ///< linecount when u_save called + char **ue_array; ///< array of lines in undo block + linenr_T ue_size; ///< number of lines in ue_array #ifdef U_DEBUG - int ue_magic; // magic number to check allocation + int ue_magic; ///< magic number to check allocation #endif }; @@ -35,40 +38,42 @@ struct u_header { // The following have a pointer and a number. The number is used when reading // the undo file in u_read_undo() union { - u_header_T *ptr; // pointer to next undo header in list + u_header_T *ptr; ///< pointer to next undo header in list int seq; } uh_next; union { - u_header_T *ptr; // pointer to previous header in list + u_header_T *ptr; ///< pointer to previous header in list int seq; } uh_prev; union { - u_header_T *ptr; // pointer to next header for alt. redo + u_header_T *ptr; ///< pointer to next header for alt. redo int seq; } uh_alt_next; union { - u_header_T *ptr; // pointer to previous header for alt. redo + u_header_T *ptr; ///< pointer to previous header for alt. redo int seq; } uh_alt_prev; - int uh_seq; // sequence number, higher == newer undo - int uh_walk; // used by undo_time() - u_entry_T *uh_entry; // pointer to first entry - u_entry_T *uh_getbot_entry; // pointer to where ue_bot must be set - pos_T uh_cursor; // cursor position before saving + int uh_seq; ///< sequence number, higher == newer undo + int uh_walk; ///< used by undo_time() + u_entry_T *uh_entry; ///< pointer to first entry + u_entry_T *uh_getbot_entry; ///< pointer to where ue_bot must be set + pos_T uh_cursor; ///< cursor position before saving colnr_T uh_cursor_vcol; - int uh_flags; // see below - fmark_T uh_namedm[NMARKS]; // marks before undo/after redo - extmark_undo_vec_t uh_extmark; // info to move extmarks - visualinfo_T uh_visual; // Visual areas before undo/after redo - time_t uh_time; // timestamp when the change was made - int uh_save_nr; // set when the file was saved after the - // changes in this block + int uh_flags; ///< see below + fmark_T uh_namedm[NMARKS]; ///< marks before undo/after redo + extmark_undo_vec_t uh_extmark; ///< info to move extmarks + visualinfo_T uh_visual; ///< Visual areas before undo/after redo + time_t uh_time; ///< timestamp when the change was made + int uh_save_nr; ///< set when the file was saved after the + ///< changes in this block #ifdef U_DEBUG - int uh_magic; // magic number to check allocation + int uh_magic; ///< magic number to check allocation #endif }; -// values for uh_flags -#define UH_CHANGED 0x01 // b_changed flag before undo/after redo -#define UH_EMPTYBUF 0x02 // buffer was empty -#define UH_RELOAD 0x04 // buffer was reloaded +/// values for uh_flags +enum { + UH_CHANGED = 0x01, ///< b_changed flag before undo/after redo + UH_EMPTYBUF = 0x02, ///< buffer was empty + UH_RELOAD = 0x04, ///< buffer was reloaded +}; -- cgit