aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-08 11:35:44 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-08 20:03:40 +0800
commitbc8fbb7c1de0e5cbc8650be883a675bdc3e9d7d8 (patch)
tree6585857c6d9ca3b4903ef23bfce5676aa1bdee4a
parenta46e6afb8b95229478c5c1fb75e3f1c55991def0 (diff)
downloadrneovim-bc8fbb7c1de0e5cbc8650be883a675bdc3e9d7d8.tar.gz
rneovim-bc8fbb7c1de0e5cbc8650be883a675bdc3e9d7d8.tar.bz2
rneovim-bc8fbb7c1de0e5cbc8650be883a675bdc3e9d7d8.zip
refactor: move non-symbols in mbyte.h to mbyte_defs.h
This just avoids including mbyte.h in eval/typval.h, so that mbyte.h can include eval/typval.h in Vim patch 8.2.1535.
-rw-r--r--src/nvim/eval/typval.h2
-rw-r--r--src/nvim/grid.h1
-rw-r--r--src/nvim/mbyte.h48
-rw-r--r--src/nvim/mbyte_defs.h56
4 files changed, 59 insertions, 48 deletions
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index c02351947b..2a4dd7b146 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -13,7 +13,7 @@
#include "nvim/hashtab.h"
#include "nvim/lib/queue.h"
#include "nvim/macros.h"
-#include "nvim/mbyte.h"
+#include "nvim/mbyte_defs.h"
#include "nvim/message.h"
#include "nvim/pos.h" // for linenr_T
#include "nvim/profile.h" // for proftime_T
diff --git a/src/nvim/grid.h b/src/nvim/grid.h
index c38748940d..4a8072bd96 100644
--- a/src/nvim/grid.h
+++ b/src/nvim/grid.h
@@ -6,6 +6,7 @@
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/grid_defs.h"
+#include "nvim/mbyte.h"
/// By default, all windows are drawn on a single rectangular grid, represented by
/// this ScreenGrid instance. In multigrid mode each window will have its own
diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h
index 1e5e332ad9..ffa8411675 100644
--- a/src/nvim/mbyte.h
+++ b/src/nvim/mbyte.h
@@ -6,7 +6,7 @@
#include <string.h>
#include "nvim/func_attr.h"
-#include "nvim/iconv.h"
+#include "nvim/mbyte_defs.h"
#include "nvim/os/os_defs.h" // For indirect
#include "nvim/types.h" // for char_u
@@ -19,52 +19,6 @@
#define MB_BYTE2LEN(b) utf8len_tab[b]
#define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : utf8len_tab[b])
-// max length of an unicode char
-#define MB_MAXCHAR 6
-
-// properties used in enc_canon_table[] (first three mutually exclusive)
-#define ENC_8BIT 0x01
-#define ENC_DBCS 0x02
-#define ENC_UNICODE 0x04
-
-#define ENC_ENDIAN_B 0x10 // Unicode: Big endian
-#define ENC_ENDIAN_L 0x20 // Unicode: Little endian
-
-#define ENC_2BYTE 0x40 // Unicode: UCS-2
-#define ENC_4BYTE 0x80 // Unicode: UCS-4
-#define ENC_2WORD 0x100 // Unicode: UTF-16
-
-#define ENC_LATIN1 0x200 // Latin1
-#define ENC_LATIN9 0x400 // Latin9
-#define ENC_MACROMAN 0x800 // Mac Roman (not Macro Man! :-)
-
-/// Flags for vimconv_T
-typedef enum {
- CONV_NONE = 0,
- CONV_TO_UTF8 = 1,
- CONV_9_TO_UTF8 = 2,
- CONV_TO_LATIN1 = 3,
- CONV_TO_LATIN9 = 4,
- CONV_ICONV = 5,
-} ConvFlags;
-
-#define MBYTE_NONE_CONV { \
- .vc_type = CONV_NONE, \
- .vc_factor = 1, \
- .vc_fail = false, \
-}
-
-/// Structure used for string conversions
-typedef struct {
- int vc_type; ///< Zero or more ConvFlags.
- int vc_factor; ///< Maximal expansion factor.
-#ifdef HAVE_ICONV
- iconv_t vc_fd; ///< Value for CONV_ICONV.
-#endif
- bool vc_fail; ///< What to do with invalid characters: if true, fail,
- ///< otherwise use '?'.
-} vimconv_T;
-
extern const uint8_t utf8len_tab_zero[256];
extern const uint8_t utf8len_tab[256];
diff --git a/src/nvim/mbyte_defs.h b/src/nvim/mbyte_defs.h
new file mode 100644
index 0000000000..53b01a211f
--- /dev/null
+++ b/src/nvim/mbyte_defs.h
@@ -0,0 +1,56 @@
+#ifndef NVIM_MBYTE_DEFS_H
+#define NVIM_MBYTE_DEFS_H
+
+#include <stdbool.h>
+
+#include "nvim/iconv.h"
+
+/// max length of an unicode char
+enum { MB_MAXCHAR = 6, };
+
+/// properties used in enc_canon_table[] (first three mutually exclusive)
+enum {
+ ENC_8BIT = 0x01,
+ ENC_DBCS = 0x02,
+ ENC_UNICODE = 0x04,
+
+ ENC_ENDIAN_B = 0x10, ///< Unicode: Big endian
+ ENC_ENDIAN_L = 0x20, ///< Unicode: Little endian
+
+ ENC_2BYTE = 0x40, ///< Unicode: UCS-2
+ ENC_4BYTE = 0x80, ///< Unicode: UCS-4
+ ENC_2WORD = 0x100, ///< Unicode: UTF-16
+
+ ENC_LATIN1 = 0x200, ///< Latin1
+ ENC_LATIN9 = 0x400, ///< Latin9
+ ENC_MACROMAN = 0x800, ///< Mac Roman (not Macro Man! :-)
+};
+
+/// Flags for vimconv_T
+typedef enum {
+ CONV_NONE = 0,
+ CONV_TO_UTF8 = 1,
+ CONV_9_TO_UTF8 = 2,
+ CONV_TO_LATIN1 = 3,
+ CONV_TO_LATIN9 = 4,
+ CONV_ICONV = 5,
+} ConvFlags;
+
+#define MBYTE_NONE_CONV { \
+ .vc_type = CONV_NONE, \
+ .vc_factor = 1, \
+ .vc_fail = false, \
+}
+
+/// Structure used for string conversions
+typedef struct {
+ int vc_type; ///< Zero or more ConvFlags.
+ int vc_factor; ///< Maximal expansion factor.
+#ifdef HAVE_ICONV
+ iconv_t vc_fd; ///< Value for CONV_ICONV.
+#endif
+ bool vc_fail; ///< What to do with invalid characters: if true, fail,
+ ///< otherwise use '?'.
+} vimconv_T;
+
+#endif // NVIM_MBYTE_DEFS_H