From c8c930ea785aa393ebc819139913a9e05f0ccd45 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:24:46 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22206) --- src/nvim/mbyte.c | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 8b50ba719a..1cc3198216 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -449,18 +449,16 @@ int mb_get_class_tab(const char *p, const uint64_t *const chartab) static bool intable(const struct interval *table, size_t n_items, int c) FUNC_ATTR_PURE { - int mid, bot, top; - // first quick check for Latin1 etc. characters if (c < table[0].first) { return false; } // binary search in table - bot = 0; - top = (int)(n_items - 1); + int bot = 0; + int top = (int)(n_items - 1); while (top >= bot) { - mid = (bot + top) / 2; + int mid = (bot + top) / 2; if (table[mid].last < c) { bot = mid + 1; } else if (table[mid].first > c) { @@ -518,11 +516,9 @@ int utf_char2cells(int c) /// This doesn't take care of unprintable characters, use ptr2cells() for that. int utf_ptr2cells(const char *p) { - int c; - // Need to convert to a character number. if ((uint8_t)(*p) >= 0x80) { - c = utf_ptr2char(p); + int c = utf_ptr2char(p); // An illegal byte is displayed as . if (utf_ptr2len(p) == 1 || c == NUL) { return 4; @@ -540,14 +536,12 @@ int utf_ptr2cells(const char *p) /// For an empty string or truncated character returns 1. int utf_ptr2cells_len(const char *p, int size) { - int c; - // Need to convert to a wide character. if (size > 0 && (uint8_t)(*p) >= 0x80) { if (utf_ptr2len_len(p, size) < utf8len_tab[(uint8_t)(*p)]) { return 1; // truncated } - c = utf_ptr2char((char *)p); + int c = utf_ptr2char((char *)p); // An illegal byte is displayed as . if (utf_ptr2len((char *)p) == 1 || c == NUL) { return 4; @@ -664,8 +658,6 @@ int utf_ptr2char(const char *const p_in) // "s". static int utf_safe_read_char_adv(const char_u **s, size_t *n) { - int c; - if (*n == 0) { // end of buffer return 0; } @@ -682,7 +674,7 @@ static int utf_safe_read_char_adv(const char_u **s, size_t *n) // We have a multibyte sequence and it isn't truncated by buffer // limits so utf_ptr2char() is safe to use. Or the first byte is // illegal (k=0), and it's also safe to use utf_ptr2char(). - c = utf_ptr2char((char *)(*s)); + int c = utf_ptr2char((char *)(*s)); // On failure, utf_ptr2char() returns the first byte, so here we // check equality with the first byte. The only non-ASCII character @@ -1141,7 +1133,6 @@ int utf_class_tab(const int c, const uint64_t *const chartab) }; int bot = 0; int top = ARRAY_SIZE(classes) - 1; - int mid; // First quick check for Latin1 characters, use 'iskeyword'. if (c < 0x100) { @@ -1161,7 +1152,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab) // binary search in table while (top >= bot) { - mid = (bot + top) / 2; + int mid = (bot + top) / 2; if (classes[mid].last < (unsigned int)c) { bot = mid + 1; } else if (classes[mid].first > (unsigned int)c) { @@ -1186,13 +1177,12 @@ bool utf_ambiguous_width(int c) // the given conversion "table". Uses binary search on "table". static int utf_convert(int a, const convertStruct *const table, size_t n_items) { - size_t start, mid, end; // indices into table - - start = 0; - end = n_items; + // indices into table + size_t start = 0; + size_t end = n_items; while (start < end) { // need to search further - mid = (end + start) / 2; + size_t mid = (end + start) / 2; if (table[mid].rangeEnd < a) { start = mid + 1; } else { @@ -1579,9 +1569,6 @@ void show_utf8(void) /// Returns 0 when already at the first byte of a character. int utf_head_off(const char *base_in, const char *p_in) { - int c; - int len; - if ((uint8_t)(*p_in) < 0x80) { // be quick for ASCII return 0; } @@ -1603,7 +1590,7 @@ int utf_head_off(const char *base_in, const char *p_in) } // Check for illegal sequence. Do allow an illegal byte after where we // started. - len = utf8len_tab[*q]; + int len = utf8len_tab[*q]; if (len != (int)(s - q + 1) && len != (int)(p - q + 1)) { return 0; } @@ -1612,7 +1599,7 @@ int utf_head_off(const char *base_in, const char *p_in) break; } - c = utf_ptr2char((char *)q); + int c = utf_ptr2char((char *)q); if (utf_iscomposing(c)) { continue; } @@ -1795,7 +1782,6 @@ int mb_off_next(const char *base, const char *p_in) { const uint8_t *p = (uint8_t *)p_in; int i; - int j; if (*p < 0x80) { // be quick for ASCII return 0; @@ -1804,6 +1790,7 @@ int mb_off_next(const char *base, const char *p_in) // Find the next character that isn't 10xx.xxxx for (i = 0; (p[i] & 0xc0) == 0x80; i++) {} if (i > 0) { + int j; // Check for illegal sequence. for (j = 0; p - j > (uint8_t *)base; j++) { if ((p[-j] & 0xc0) != 0x80) { @@ -2479,7 +2466,6 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si { char_u *retval = NULL; char_u *d; - int l; int c; size_t len; @@ -2547,7 +2533,7 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si retval = xmalloc(len + 1); d = retval; for (size_t i = 0; i < len; i++) { - l = utf_ptr2len_len(ptr + i, (int)(len - i)); + int l = utf_ptr2len_len(ptr + i, (int)(len - i)); if (l == 0) { *d++ = NUL; } else if (l == 1) { -- cgit From 7224c889e0d5d70b99ae377036baa6377c33a568 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:25:24 +0100 Subject: build: enable MSVC level 3 warnings (#21934) MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag. --- src/nvim/mbyte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 1cc3198216..2f1724369c 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2613,8 +2613,8 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si /// Table set by setcellwidths(). typedef struct { - long first; - long last; + int64_t first; + int64_t last; char width; } cw_interval_T; -- cgit From 4be6c6cf0ddf5e31d4103cb5df06651ba6f4897b Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:05:57 +0100 Subject: refactor: replace char_u with char (#21901) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/mbyte.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 2f1724369c..c2bde53b32 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1842,7 +1842,7 @@ int utf_cp_tail_off(const char *base, const char *p_in) /// @param[in] p Pointer to byte for which to return the offset to the previous codepoint // /// @return 0 if invalid sequence, else offset to previous codepoint -int utf_cp_head_off(const char_u *base, const char_u *p) +int utf_cp_head_off(const char *base, const char *p) { int i; int j; @@ -1853,16 +1853,16 @@ int utf_cp_head_off(const char_u *base, const char_u *p) // Find the first character that is not 10xx.xxxx for (i = 0; p - i > base; i--) { - if ((p[i] & 0xc0) != 0x80) { + if (((uint8_t)p[i] & 0xc0) != 0x80) { break; } } // Find the last character that is 10xx.xxxx - for (j = 0; (p[j + 1] & 0xc0) == 0x80; j++) {} + for (j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {} // Check for illegal sequence. - if (utf8len_tab[p[i]] == 1) { + if (utf8len_tab[(uint8_t)p[i]] == 1) { return 0; } return i; -- cgit From 5f72ab77bff1f1224be5cbbf9423bdddbc25635c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:48:49 +0100 Subject: refactor: reduce scope of locals as per the style guide 3 (#22221) refactor: reduce scope of locals as per the style guide --- src/nvim/mbyte.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c2bde53b32..e27bb003e7 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -847,7 +847,6 @@ int utf_byte2len(int b) int utf_ptr2len_len(const char *p, int size) { int len; - int i; int m; len = utf8len_tab[(uint8_t)(*p)]; @@ -859,7 +858,7 @@ int utf_ptr2len_len(const char *p, int size) } else { m = len; } - for (i = 1; i < m; i++) { + for (int i = 1; i < m; i++) { if ((p[i] & 0xc0) != 0x80) { return 1; } @@ -1530,7 +1529,6 @@ void show_utf8(void) int rlen = 0; char *line; int clen; - int i; // Get the byte length of the char under the cursor, including composing // characters. @@ -1542,7 +1540,7 @@ void show_utf8(void) } clen = 0; - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { if (clen == 0) { // start of (composing) character, get its length if (i > 0) { @@ -2171,9 +2169,7 @@ char *enc_canonize(char *enc) /// Returns -1 when not found. static int enc_alias_search(const char *name) { - int i; - - for (i = 0; enc_alias_table[i].name != NULL; i++) { + for (int i = 0; enc_alias_table[i].name != NULL; i++) { if (strcmp(name, enc_alias_table[i].name) == 0) { return enc_alias_table[i].canon; } -- cgit From 1b3c1f6c06d73e881bfc2a46e5ee3e0b24ba96d8 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 27 Feb 2023 19:37:43 +0100 Subject: refactor(build): graduate HAVE_LOCALE_H feature Merge locale.h into os/lang.h Having a source file with the same name as a system header we use is considered an anti-pattern. --- src/nvim/mbyte.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index e27bb003e7..d8be4f4997 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -67,10 +68,6 @@ #include "nvim/types.h" #include "nvim/vim.h" -#ifdef HAVE_LOCALE_H -# include -#endif - typedef struct { int rangeStart; int rangeEnd; @@ -2193,10 +2190,7 @@ char *enc_locale(void) if (!(s = nl_langinfo(CODESET)) || *s == NUL) #endif { -#if defined(HAVE_LOCALE_H) - if (!(s = setlocale(LC_CTYPE, NULL)) || *s == NUL) -#endif - { + if (!(s = setlocale(LC_CTYPE, NULL)) || *s == NUL) { if ((s = os_getenv("LC_ALL"))) { if ((s = os_getenv("LC_CTYPE"))) { s = os_getenv("LANG"); -- cgit From 6cab36e5b7b0d741abe6c5a7c0e20bad30361034 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 4 Mar 2023 13:10:00 +0100 Subject: refactor: replace char_u with char or uint8_t (#22400) Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/mbyte.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index d8be4f4997..35af7479b0 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1930,16 +1930,16 @@ theend: /// @return true if string "s" is a valid utf-8 string. /// When "end" is NULL stop at the first NUL. Otherwise stop at "end". -bool utf_valid_string(const char_u *s, const char_u *end) +bool utf_valid_string(const char *s, const char *end) { - const char_u *p = s; + const uint8_t *p = (uint8_t *)s; - while (end == NULL ? *p != NUL : p < end) { + while (end == NULL ? *p != NUL : p < (uint8_t *)end) { int l = utf8len_tab_zero[*p]; if (l == 0) { return false; // invalid lead byte } - if (end != NULL && p + l > end) { + if (end != NULL && p + l > (uint8_t *)end) { return false; // incomplete byte sequence } p++; @@ -2454,8 +2454,8 @@ char *string_convert(const vimconv_T *const vcp, char *ptr, size_t *lenp) // set to the number of remaining bytes. char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, size_t *unconvlenp) { - char_u *retval = NULL; - char_u *d; + uint8_t *retval = NULL; + uint8_t *d; int c; size_t len; @@ -2475,10 +2475,10 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si for (size_t i = 0; i < len; i++) { c = (uint8_t)ptr[i]; if (c < 0x80) { - *d++ = (char_u)c; + *d++ = (uint8_t)c; } else { - *d++ = (char_u)(0xc0 + (char_u)((unsigned)c >> 6)); - *d++ = (char_u)(0x80 + (c & 0x3f)); + *d++ = (uint8_t)(0xc0 + (uint8_t)((unsigned)c >> 6)); + *d++ = (uint8_t)(0x80 + (c & 0x3f)); } } *d = NUL; @@ -2573,7 +2573,7 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si } if (!utf_iscomposing(c)) { // skip composing chars if (c < 0x100) { - *d++ = (char_u)c; + *d++ = (uint8_t)c; } else if (vcp->vc_fail) { xfree(retval); return NULL; @@ -2594,7 +2594,7 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si break; case CONV_ICONV: // conversion with vcp->vc_fd - retval = (char_u *)iconv_string(vcp, ptr, len, unconvlenp, lenp); + retval = (uint8_t *)iconv_string(vcp, ptr, len, unconvlenp, lenp); break; } -- cgit From d6ecead36406233cc56353dd05f3380f0497630f Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 14 Mar 2023 11:49:46 +0100 Subject: refactor(screen): screen.c delenda est drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now. --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 35af7479b0..fb52a11025 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -60,10 +60,10 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_defs.h" +#include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" #include "nvim/pos.h" -#include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/types.h" #include "nvim/vim.h" -- cgit From d510bfbc8e447b1a60d5ec7faaa8f440eb4ef56f Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:11:42 +0200 Subject: refactor: remove char_u (#22829) Closes https://github.com/neovim/neovim/issues/459 --- src/nvim/mbyte.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index fb52a11025..c580dc29e6 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -653,32 +653,32 @@ int utf_ptr2char(const char *const p_in) // // If byte sequence is illegal or incomplete, returns -1 and does not advance // "s". -static int utf_safe_read_char_adv(const char_u **s, size_t *n) +static int utf_safe_read_char_adv(const char **s, size_t *n) { if (*n == 0) { // end of buffer return 0; } - uint8_t k = utf8len_tab_zero[**s]; + uint8_t k = utf8len_tab_zero[(uint8_t)(**s)]; if (k == 1) { // ASCII character or NUL (*n)--; - return *(*s)++; + return (uint8_t)(*(*s)++); } if (k <= *n) { // We have a multibyte sequence and it isn't truncated by buffer // limits so utf_ptr2char() is safe to use. Or the first byte is // illegal (k=0), and it's also safe to use utf_ptr2char(). - int c = utf_ptr2char((char *)(*s)); + int c = utf_ptr2char(*s); // On failure, utf_ptr2char() returns the first byte, so here we // check equality with the first byte. The only non-ASCII character // which equals the first byte of its own UTF-8 representation is // U+00C3 (UTF-8: 0xC3 0x83), so need to check that special case too. // It's safe even if n=1, else we would have k=2 > n. - if (c != (int)(**s) || (c == 0xC3 && (*s)[1] == 0x83)) { + if (c != (int)((uint8_t)(**s)) || (c == 0xC3 && (uint8_t)(*s)[1] == 0x83)) { // byte sequence was successfully decoded *s += k; *n -= k; @@ -1271,7 +1271,7 @@ bool mb_isalpha(int a) return mb_islower(a) || mb_isupper(a); } -static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2) +static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) { int c1, c2, cdiff; char buffer[6]; @@ -1313,14 +1313,14 @@ static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2 if (c1 != -1 && c2 == -1) { n1 = (size_t)utf_char2bytes(utf_fold(c1), (char *)buffer); - s1 = (char_u *)buffer; + s1 = buffer; } else if (c2 != -1 && c1 == -1) { n2 = (size_t)utf_char2bytes(utf_fold(c2), (char *)buffer); - s2 = (char_u *)buffer; + s2 = buffer; } while (n1 > 0 && n2 > 0 && *s1 != NUL && *s2 != NUL) { - cdiff = (int)(*s1) - (int)(*s2); + cdiff = (int)((uint8_t)(*s1)) - (int)((uint8_t)(*s2)); if (cdiff != 0) { return cdiff; } @@ -1498,7 +1498,7 @@ ssize_t mb_utf_index_to_bytes(const char *s, size_t len, size_t index, bool use_ /// two characters otherwise. int mb_strnicmp(const char *s1, const char *s2, const size_t nn) { - return utf_strnicmp((char_u *)s1, (char_u *)s2, nn, nn); + return utf_strnicmp(s1, s2, nn, nn); } /// Compare strings case-insensitively -- cgit From 371823d407d7d7519735131bcad4670c62a731a7 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 5 Apr 2023 21:13:53 +0200 Subject: refactor: make error message definitions const message.c functions now take const char * as a format. Error message definitions can be made const. --- src/nvim/mbyte.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c580dc29e6..340a05f29d 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -87,17 +87,17 @@ struct interval { #endif // uncrustify:on -static char e_list_item_nr_is_not_list[] +static const char e_list_item_nr_is_not_list[] = N_("E1109: List item %d is not a List"); -static char e_list_item_nr_does_not_contain_3_numbers[] +static const char e_list_item_nr_does_not_contain_3_numbers[] = N_("E1110: List item %d does not contain 3 numbers"); -static char e_list_item_nr_range_invalid[] +static const char e_list_item_nr_range_invalid[] = N_("E1111: List item %d range invalid"); -static char e_list_item_nr_cell_width_invalid[] +static const char e_list_item_nr_cell_width_invalid[] = N_("E1112: List item %d cell width invalid"); -static char e_overlapping_ranges_for_nr[] +static const char e_overlapping_ranges_for_nr[] = N_("E1113: Overlapping ranges for 0x%lx"); -static char e_only_values_of_0x80_and_higher_supported[] +static const char e_only_values_of_0x80_and_higher_supported[] = N_("E1114: Only values of 0x80 and higher supported"); // To speed up BYTELEN(); keep a lookup table to quickly get the length in -- cgit From 7190dba017e3aac0409c73ff1c954d18858cb3c9 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Thu, 6 Apr 2023 22:39:50 +0200 Subject: refactor: remove use of reserved c++ keywords libnvim couldn't be easily used in C++ due to the use of reserved keywords. Additionally, add explicit casts to *alloc function calls used in inline functions, as C++ doesn't allow implicit casts from void pointers. --- src/nvim/mbyte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 340a05f29d..6ab7aee29d 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1053,7 +1053,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab) static struct clinterval { unsigned int first; unsigned int last; - unsigned int class; + unsigned int cls; } classes[] = { { 0x037e, 0x037e, 1 }, // Greek question mark { 0x0387, 0x0387, 1 }, // Greek ano teleia @@ -1154,7 +1154,7 @@ int utf_class_tab(const int c, const uint64_t *const chartab) } else if (classes[mid].first > (unsigned int)c) { top = mid - 1; } else { - return (int)classes[mid].class; + return (int)classes[mid].cls; } } -- cgit From 04933b1ea968f958d2541dd65fd33ebb503caac3 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:08:16 +0200 Subject: refactor: remove redundant casts --- src/nvim/mbyte.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 6ab7aee29d..b44c3e52cb 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -367,7 +367,7 @@ static int enc_canon_search(const char *name) int enc_canon_props(const char *name) FUNC_ATTR_PURE { - int i = enc_canon_search((char *)name); + int i = enc_canon_search(name); if (i >= 0) { return enc_canon_table[i].prop; } else if (strncmp(name, "2byte-", 6) == 0) { @@ -538,9 +538,9 @@ int utf_ptr2cells_len(const char *p, int size) if (utf_ptr2len_len(p, size) < utf8len_tab[(uint8_t)(*p)]) { return 1; // truncated } - int c = utf_ptr2char((char *)p); + int c = utf_ptr2char(p); // An illegal byte is displayed as . - if (utf_ptr2len((char *)p) == 1 || c == NUL) { + if (utf_ptr2len(p) == 1 || c == NUL) { return 4; } // If the char is ASCII it must be an overlong sequence. @@ -719,7 +719,7 @@ bool utf_composinglike(const char *p1, const char *p2) { int c2; - c2 = utf_ptr2char((char *)p2); + c2 = utf_ptr2char(p2); if (utf_iscomposing(c2)) { return true; } -- cgit From 2d78e656b715119ca11d131a1a932f22f1b4ad36 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:43:00 +0200 Subject: refactor: remove redundant casts --- src/nvim/mbyte.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index b44c3e52cb..ab787524a9 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -726,7 +726,7 @@ bool utf_composinglike(const char *p1, const char *p2) if (!arabic_maycombine(c2)) { return false; } - return arabic_combine(utf_ptr2char((char *)p1), c2); + return arabic_combine(utf_ptr2char(p1), c2); } /// Convert a UTF-8 string to a wide character @@ -1312,10 +1312,10 @@ static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) // to fold just one character to determine the result of comparison. if (c1 != -1 && c2 == -1) { - n1 = (size_t)utf_char2bytes(utf_fold(c1), (char *)buffer); + n1 = (size_t)utf_char2bytes(utf_fold(c1), buffer); s1 = buffer; } else if (c2 != -1 && c1 == -1) { - n2 = (size_t)utf_char2bytes(utf_fold(c2), (char *)buffer); + n2 = (size_t)utf_char2bytes(utf_fold(c2), buffer); s2 = buffer; } -- cgit From 907018e547c9b989781667d2cf951e1abf99ab9d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Apr 2023 00:23:11 +0800 Subject: vim-patch:8.2.3139: functions for string manipulation are spread out (#23316) Problem: Functions for string manipulation are spread out. Solution: Move string related functions to a new source file. (Yegappan Lakshmanan, closes vim/vim#8470) https://github.com/vim/vim/commit/a2438132a675be4dde3acbdf03ba1fdb2f09427c Co-authored-by: Yegappan Lakshmanan --- src/nvim/mbyte.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index ab787524a9..78204b22a8 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2361,6 +2361,34 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl return result; } +/// iconv() function +void f_iconv(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) +{ + vimconv_T vimconv; + + rettv->v_type = VAR_STRING; + rettv->vval.v_string = NULL; + + const char *const str = tv_get_string(&argvars[0]); + char buf1[NUMBUFLEN]; + char *const from = enc_canonize(enc_skip((char *)tv_get_string_buf(&argvars[1], buf1))); + char buf2[NUMBUFLEN]; + char *const to = enc_canonize(enc_skip((char *)tv_get_string_buf(&argvars[2], buf2))); + vimconv.vc_type = CONV_NONE; + convert_setup(&vimconv, from, to); + + // If the encodings are equal, no conversion needed. + if (vimconv.vc_type == CONV_NONE) { + rettv->vval.v_string = xstrdup(str); + } else { + rettv->vval.v_string = string_convert(&vimconv, (char *)str, NULL); + } + + convert_setup(&vimconv, NULL, NULL); + xfree(from); + xfree(to); +} + /// Setup "vcp" for conversion from "from" to "to". /// The names must have been made canonical with enc_canonize(). /// vcp->vc_type must have been initialized to CONV_NONE. -- cgit From 3b0df1780e2c8526bda5dead18ee7cc45925caba Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:23:44 +0200 Subject: refactor: uncrustify Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`. --- src/nvim/mbyte.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 78204b22a8..7d61b918d2 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -749,7 +749,7 @@ int utfc_ptr2char(const char *p, int *pcc) && (uint8_t)p[len] >= 0x80 && utf_composinglike(p, p + len)) { int cc = utf_ptr2char(p + len); - for (;;) { + while (true) { pcc[i++] = cc; if (i == MAX_MCO) { break; @@ -889,7 +889,7 @@ int utfc_ptr2len(const char *const p) // Check for composing characters. We can handle only the first six, but // skip all of them (otherwise the cursor would get stuck). int prevlen = 0; - for (;;) { + while (true) { if ((uint8_t)p[len] < 0x80 || !utf_composinglike(p + prevlen, p + len)) { return len; } @@ -1051,9 +1051,9 @@ int utf_class_tab(const int c, const uint64_t *const chartab) { // sorted list of non-overlapping intervals static struct clinterval { - unsigned int first; - unsigned int last; - unsigned int cls; + unsigned first; + unsigned last; + unsigned cls; } classes[] = { { 0x037e, 0x037e, 1 }, // Greek question mark { 0x0387, 0x0387, 1 }, // Greek ano teleia @@ -1149,9 +1149,9 @@ int utf_class_tab(const int c, const uint64_t *const chartab) // binary search in table while (top >= bot) { int mid = (bot + top) / 2; - if (classes[mid].last < (unsigned int)c) { + if (classes[mid].last < (unsigned)c) { bot = mid + 1; - } else if (classes[mid].first > (unsigned int)c) { + } else if (classes[mid].first > (unsigned)c) { top = mid - 1; } else { return (int)classes[mid].cls; @@ -1276,7 +1276,7 @@ static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) int c1, c2, cdiff; char buffer[6]; - for (;;) { + while (true) { c1 = utf_safe_read_char_adv(&s1, &n1); c2 = utf_safe_read_char_adv(&s2, &n2); @@ -1881,7 +1881,7 @@ void utf_find_illegal(void) } curwin->w_cursor.coladd = 0; - for (;;) { + while (true) { p = get_cursor_pos_ptr(); if (vimconv.vc_type != CONV_NONE) { xfree(tofree); @@ -2299,7 +2299,7 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl from = str; fromlen = slen; - for (;;) { + while (true) { if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) { // Allocate enough room for most conversions. When re-allocating // increase the buffer size. -- cgit From 5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:21:46 +1000 Subject: fix(ui): fix tabs not being spaced properly after virtual text with no wrap also fixes incorrect skipping of multibyte characters --- src/nvim/mbyte.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 7d61b918d2..66c26275f1 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2024,6 +2024,24 @@ int mb_charlen(const char *str) return count; } +int mb_charlen2bytelen(const char *str, int charlen) +{ + const char *p = str; + int count = 0; + + if (p == NULL) { + return 0; + } + + for (int i = 0; *p != NUL && i < charlen; i++) { + int b = utfc_ptr2len(p); + p += b; + count += b; + } + + return count; +} + /// Like mb_charlen() but for a string with specified length. int mb_charlen_len(const char *str, int len) { -- cgit From cefd774fac76b91f5368833555818c80c992c3b1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 24 Aug 2023 15:14:23 +0200 Subject: refactor(memline): distinguish mutating uses of ml_get_buf() ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline. --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 66c26275f1..92e70350bb 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1970,7 +1970,7 @@ void mb_check_adjust_col(void *win_) // Column 0 is always valid. if (oldcol != 0) { - char *p = ml_get_buf(win->w_buffer, win->w_cursor.lnum, false); + char *p = ml_get_buf(win->w_buffer, win->w_cursor.lnum); colnr_T len = (colnr_T)strlen(p); // Empty line or invalid column? -- cgit From a1bec02c1e105eb9f49d577e04bdbeadd5a05e38 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sun, 13 Aug 2023 10:29:43 +0100 Subject: fix: use snprintf instead of sprintf Clang 14 now reports sprintf as deprecated. --- src/nvim/mbyte.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 92e70350bb..fd9efb1387 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1522,21 +1522,17 @@ int mb_stricmp(const char *s1, const char *s2) // 'encoding' has been set to. void show_utf8(void) { - int len; - int rlen = 0; - char *line; - int clen; - // Get the byte length of the char under the cursor, including composing // characters. - line = get_cursor_pos_ptr(); - len = utfc_ptr2len(line); + char *line = get_cursor_pos_ptr(); + int len = utfc_ptr2len(line); if (len == 0) { msg("NUL"); return; } - clen = 0; + size_t rlen = 0; + int clen = 0; for (int i = 0; i < len; i++) { if (clen == 0) { // start of (composing) character, get its length @@ -1546,10 +1542,11 @@ void show_utf8(void) } clen = utf_ptr2len(line + i); } - sprintf(IObuff + rlen, "%02x ", // NOLINT(runtime/printf) - (line[i] == NL) ? NUL : (uint8_t)line[i]); // NUL is stored as NL + assert(IOSIZE > rlen); + snprintf(IObuff + rlen, IOSIZE - rlen, "%02x ", + (line[i] == NL) ? NUL : (uint8_t)line[i]); // NUL is stored as NL clen--; - rlen += (int)strlen(IObuff + rlen); + rlen += strlen(IObuff + rlen); if (rlen > IOSIZE - 20) { break; } -- cgit From b9d9cd77421a7906d6e0a968a3c0ddd86e9923fe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Sep 2023 17:47:28 +0800 Subject: vim-patch:partial:9.0.1886: Various Typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Various Typos Solution: Fix Typos This is a collection of typo related commits. closes: vim/vim#12753 closes: vim/vim#13016 https://github.com/vim/vim/commit/ee17b6f70d382ec6c5d8d27b56c4e84106ac8c55 Co-authored-by: Christian Brabandt Co-authored-by: Adri Verhoef Co-authored-by: Viktor Szépe Co-authored-by: nuid64 Co-authored-by: Meng Xiangzhuo Co-authored-by: Dominique Pellé --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index fd9efb1387..6182646fe7 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1648,7 +1648,7 @@ bool utf_allow_break_before(int cc) 0x2021, // ‡ double dagger 0x2026, // … horizontal ellipsis 0x2030, // ‰ per mille sign - 0x2031, // ‱ per then thousand sign + 0x2031, // ‱ per the thousand sign 0x203c, // ‼ double exclamation mark 0x2047, // ⁇ double question mark 0x2048, // ⁈ question exclamation mark -- cgit From b85f1dafc7c0a19704135617454f1c66f41202c1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 22:21:17 +0200 Subject: refactor(messages): fold msg_attr into msg problem: there are too many different functions in message.c solution: fold some of the functions into themselves --- src/nvim/mbyte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 6182646fe7..3f035974a1 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1527,7 +1527,7 @@ void show_utf8(void) char *line = get_cursor_pos_ptr(); int len = utfc_ptr2len(line); if (len == 0) { - msg("NUL"); + msg("NUL", 0); return; } @@ -1552,7 +1552,7 @@ void show_utf8(void) } } - msg(IObuff); + msg(IObuff, 0); } /// Return offset from "p" to the start of a character, including composing characters. -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/mbyte.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 3f035974a1..e65652e81f 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index e65652e81f..7b7c822b3b 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -60,7 +60,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" -- cgit From f06af5e66981095f3244f67d1587ce7e9853eb4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 08:13:58 +0800 Subject: vim-patch:9.0.1958: cannot complete option values Problem: cannot complete option values Solution: Add completion functions for several options Add cmdline tab-completion for setting string options Add tab-completion for setting string options on the cmdline using `:set=` (along with `:set+=` and `:set-=`). The existing tab completion for setting options currently only works when nothing is typed yet, and it only fills in with the existing value, e.g. when the user does `:set diffopt=` it will be completed to `set diffopt=internal,filler,closeoff` and nothing else. This isn't too useful as a user usually wants auto-complete to suggest all the possible values, such as 'iblank', or 'algorithm:patience'. For set= and set+=, this adds a new optional callback function for each option that can be invoked when doing completion. This allows for each option to have control over how completion works. For example, in 'diffopt', it will suggest the default enumeration, but if `algorithm:` is selected, it will further suggest different algorithm types like 'meyers' and 'patience'. When using set=, the existing option value will be filled in as the first choice to preserve the existing behavior. When using set+= this won't happen as it doesn't make sense. For flag list options (e.g. 'mouse' and 'guioptions'), completion will take into account existing typed values (and in the case of set+=, the existing option value) to make sure it doesn't suggest duplicates. For set-=, there is a new `ExpandSettingSubtract` function which will handle flag list and comma-separated options smartly, by only suggesting values that currently exist in the option. Note that Vim has some existing code that adds special handling for 'filetype', 'syntax', and misc dir options like 'backupdir'. This change preserves them as they already work, instead of converting to the new callback API for each option. closes: vim/vim#13182 https://github.com/vim/vim/commit/900894b09a95398dfc75599e9f0aa2ea25723384 Co-authored-by: Yee Cheng Chin --- src/nvim/mbyte.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 7b7c822b3b..124855fd08 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2830,3 +2830,14 @@ void f_charclass(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } rettv->vval.v_number = mb_get_class(argvars[0].vval.v_string); } + +/// Function given to ExpandGeneric() to obtain the possible arguments of the +/// encoding options. +char *get_encoding_name(expand_T *xp FUNC_ATTR_UNUSED, int idx) +{ + if (idx >= (int)ARRAY_SIZE(enc_canon_table)) { + return NULL; + } + + return (char *)enc_canon_table[idx].name; +} -- cgit From 09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 2 Oct 2023 10:45:33 +0800 Subject: refactor: move cmdline completion types to cmdexpand_defs.h (#25465) --- src/nvim/mbyte.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 124855fd08..4191b4dcc5 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -43,6 +43,7 @@ #include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/eval/typval.h" -- 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/mbyte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 4191b4dcc5..a3cd569846 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -78,8 +78,8 @@ typedef struct { } convertStruct; struct interval { - long first; - long last; + int first; + int last; }; // uncrustify:off -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd 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/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index a3cd569846..6f830d3efd 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2774,7 +2774,7 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) const listitem_T *lili = tv_list_first(li_l); const varnumber_T n1 = TV_LIST_ITEM_TV(lili)->vval.v_number; if (item > 0 && n1 <= table[item - 1].last) { - semsg(_(e_overlapping_ranges_for_nr), (long)n1); + semsg(_(e_overlapping_ranges_for_nr), (size_t)n1); xfree((void *)ptrs); xfree(table); return; -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/mbyte.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 6f830d3efd..39ee65d9d3 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// mbyte.c: Code specifically for handling multi-byte characters. /// Multibyte extensions partly by Sung-Hoon Baek /// -- cgit From 28f4f3c48498086307ed825d1761edb5789ca0e8 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 15:54:54 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values --- src/nvim/mbyte.c | 64 ++++++++++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 44 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 39ee65d9d3..0d468889a4 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -693,9 +693,7 @@ static int utf_safe_read_char_adv(const char **s, size_t *n) // Note: composing characters are skipped! int mb_ptr2char_adv(const char **const pp) { - int c; - - c = utf_ptr2char(*pp); + int c = utf_ptr2char(*pp); *pp += utfc_ptr2len(*pp); return c; } @@ -704,9 +702,7 @@ int mb_ptr2char_adv(const char **const pp) // Note: composing characters are returned as separate characters. int mb_cptr2char_adv(const char **pp) { - int c; - - c = utf_ptr2char(*pp); + int c = utf_ptr2char(*pp); *pp += utf_ptr2len(*pp); return c; } @@ -716,9 +712,7 @@ int mb_cptr2char_adv(const char **pp) /// behaves like a composing character. bool utf_composinglike(const char *p1, const char *p2) { - int c2; - - c2 = utf_ptr2char(p2); + int c2 = utf_ptr2char(p2); if (utf_iscomposing(c2)) { return true; } @@ -842,10 +836,9 @@ int utf_byte2len(int b) // Never returns zero. int utf_ptr2len_len(const char *p, int size) { - int len; int m; - len = utf8len_tab[(uint8_t)(*p)]; + int len = utf8len_tab[(uint8_t)(*p)]; if (len == 1) { return 1; // NUL, ascii or illegal lead byte } @@ -905,9 +898,6 @@ int utfc_ptr2len(const char *const p) /// Returns 1 for an illegal char or an incomplete byte sequence. int utfc_ptr2len_len(const char *p, int size) { - int len; - int prevlen; - if (size < 1 || *p == NUL) { return 0; } @@ -916,7 +906,7 @@ int utfc_ptr2len_len(const char *p, int size) } // Skip over first UTF-8 char, stopping at a NUL byte. - len = utf_ptr2len_len(p, size); + int len = utf_ptr2len_len(p, size); // Check for illegal byte and incomplete byte sequence. if ((len == 1 && (uint8_t)p[0] >= 0x80) || len > size) { @@ -925,17 +915,15 @@ int utfc_ptr2len_len(const char *p, int size) // Check for composing characters. We can handle only the first six, but // skip all of them (otherwise the cursor would get stuck). - prevlen = 0; + int prevlen = 0; while (len < size) { - int len_next_char; - if ((uint8_t)p[len] < 0x80) { break; } // Next character length should not go beyond size to ensure that // utf_composinglike(...) does not read beyond size. - len_next_char = utf_ptr2len_len(p + len, size - len); + int len_next_char = utf_ptr2len_len(p + len, size - len); if (len_next_char > size - len) { break; } @@ -1836,7 +1824,6 @@ int utf_cp_tail_off(const char *base, const char *p_in) int utf_cp_head_off(const char *base, const char *p) { int i; - int j; if (*p == NUL) { return 0; @@ -1850,7 +1837,7 @@ int utf_cp_head_off(const char *base, const char *p) } // Find the last character that is 10xx.xxxx - for (j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {} + for (int j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {} // Check for illegal sequence. if (utf8len_tab[(uint8_t)p[i]] == 1) { @@ -2118,7 +2105,6 @@ char *enc_skip(char *p) char *enc_canonize(char *enc) FUNC_ATTR_NONNULL_RET { - char *p, *s; if (strcmp(enc, "default") == 0) { // Use the default encoding as found by set_init_1(). return xstrdup(fenc_default); @@ -2127,8 +2113,8 @@ char *enc_canonize(char *enc) // copy "enc" to allocated memory, with room for two '-' char *r = xmalloc(strlen(enc) + 3); // Make it all lower case and replace '_' with '-'. - p = r; - for (s = enc; *s != NUL; s++) { + char *p = r; + for (char *s = enc; *s != NUL; s++) { if (*s == '_') { *p++ = '-'; } else { @@ -2260,17 +2246,14 @@ enc_locale_copy_enc: // (should return iconv_t, but that causes problems with prototypes). void *my_iconv_open(char *to, char *from) { - iconv_t fd; #define ICONV_TESTLEN 400 char tobuf[ICONV_TESTLEN]; - char *p; - size_t tolen; static WorkingStatus iconv_working = kUnknown; if (iconv_working == kBroken) { return (void *)-1; // detected a broken iconv() previously } - fd = iconv_open(enc_skip(to), enc_skip(from)); + iconv_t fd = iconv_open(enc_skip(to), enc_skip(from)); if (fd != (iconv_t)-1 && iconv_working == kUnknown) { // Do a dummy iconv() call to check if it actually works. There is a @@ -2278,8 +2261,8 @@ void *my_iconv_open(char *to, char *from) // because it's wide-spread. The symptoms are that after outputting // the initial shift state the "to" pointer is NULL and conversion // stops for no apparent reason after about 8160 characters. - p = tobuf; - tolen = ICONV_TESTLEN; + char *p = tobuf; + size_t tolen = ICONV_TESTLEN; (void)iconv(fd, NULL, NULL, &p, &tolen); if (p == NULL) { iconv_working = kBroken; @@ -2301,24 +2284,19 @@ void *my_iconv_open(char *to, char *from) static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t slen, size_t *unconvlenp, size_t *resultlenp) { - const char *from; - size_t fromlen; char *to; - size_t tolen; size_t len = 0; size_t done = 0; char *result = NULL; - char *p; - int l; - from = str; - fromlen = slen; + const char *from = str; + size_t fromlen = slen; while (true) { if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) { // Allocate enough room for most conversions. When re-allocating // increase the buffer size. len = len + fromlen * 2 + 40; - p = xmalloc(len); + char *p = xmalloc(len); if (done > 0) { memmove(p, result, done); } @@ -2327,7 +2305,7 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl } to = result + done; - tolen = len - done - 2; + size_t tolen = len - done - 2; // Avoid a warning for systems with a wrong iconv() prototype by // casting the second argument to void *. if (iconv(vcp->vc_fd, (void *)&from, &fromlen, &to, &tolen) != SIZE_MAX) { @@ -2357,7 +2335,7 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl if (utf_ptr2cells(from) > 1) { *to++ = '?'; } - l = utfc_ptr2len_len(from, (int)fromlen); + int l = utfc_ptr2len_len(from, (int)fromlen); from += l; fromlen -= (size_t)l; } else if (ICONV_ERRNO != ICONV_E2BIG) { @@ -2421,8 +2399,6 @@ int convert_setup(vimconv_T *vcp, char *from, char *to) int convert_setup_ext(vimconv_T *vcp, char *from, bool from_unicode_is_utf8, char *to, bool to_unicode_is_utf8) { - int from_prop; - int to_prop; int from_is_utf8; int to_is_utf8; @@ -2438,8 +2414,8 @@ int convert_setup_ext(vimconv_T *vcp, char *from, bool from_unicode_is_utf8, cha return OK; } - from_prop = enc_canon_props(from); - to_prop = enc_canon_props(to); + int from_prop = enc_canon_props(from); + int to_prop = enc_canon_props(to); if (from_unicode_is_utf8) { from_is_utf8 = from_prop & ENC_UNICODE; } else { -- cgit From b522cb1ac3fbdf6e68eed5d0b6e1cbeaf3ac2254 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 6 Nov 2023 14:52:27 +0100 Subject: refactor(grid): make screen rendering more multibyte than ever before Problem: buffer text with composing chars are converted from UTF-8 to an array of up to seven UTF-32 values and then converted back to UTF-8 strings. Solution: Convert buffer text directly to UTF-8 based schar_T values. The limit of the text size is now in schar_T bytes, which is currently 31+1 but easily could be raised as it no longer multiplies the size of the entire screen grid when not used, the full size is only required for temporary scratch buffers. Also does some general cleanup to win_line text handling, which was unnecessarily complicated due to multibyte rendering being an "opt-in" feature long ago. Nowadays, a char is just a char, regardless if it consists of one ASCII byte or multiple bytes. --- src/nvim/mbyte.c | 123 ++++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 66 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 0d468889a4..3a13aeddb8 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -48,6 +48,7 @@ #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" +#include "nvim/grid.h" #include "nvim/grid_defs.h" #include "nvim/iconv.h" #include "nvim/keycodes.h" @@ -722,80 +723,68 @@ bool utf_composinglike(const char *p1, const char *p2) return arabic_combine(utf_ptr2char(p1), c2); } -/// Convert a UTF-8 string to a wide character +/// Get the screen char at the beginning of a string /// -/// Also gets up to #MAX_MCO composing characters. +/// Caller is expected to check for things like unprintable chars etc +/// If first char in string is a composing char, prepend a space to display it correctly. /// -/// @param[out] pcc Location where to store composing characters. Must have -/// space at least for #MAX_MCO + 1 elements. +/// If "p" starts with an invalid sequence, zero is returned. /// -/// @return leading character. -int utfc_ptr2char(const char *p, int *pcc) +/// @param[out] firstc (required) The first codepoint of the screen char, +/// or the first byte of an invalid sequence +/// +/// @return the char +schar_T utfc_ptr2schar(const char *p, int *firstc) + FUNC_ATTR_NONNULL_ALL { - int i = 0; - int c = utf_ptr2char(p); - int len = utf_ptr2len(p); - - // Only accept a composing char when the first char isn't illegal. - if ((len > 1 || (uint8_t)(*p) < 0x80) - && (uint8_t)p[len] >= 0x80 - && utf_composinglike(p, p + len)) { - int cc = utf_ptr2char(p + len); - while (true) { - pcc[i++] = cc; - if (i == MAX_MCO) { - break; - } - len += utf_ptr2len(p + len); - if ((uint8_t)p[len] < 0x80 || !utf_iscomposing(cc = utf_ptr2char(p + len))) { - break; - } - } - } + *firstc = c; // NOT optional, you are gonna need it + bool first_compose = utf_iscomposing(c); + size_t maxlen = MAX_SCHAR_SIZE - 1 - first_compose; + size_t len = (size_t)utfc_ptr2len_len(p, (int)maxlen); - if (i < MAX_MCO) { // last composing char must be 0 - pcc[i] = 0; + if (len == 1 && (uint8_t)(*p) >= 0x80) { + return 0; // invalid sequence } - return c; + return schar_from_buf_first(p, len, first_compose); } -// Convert a UTF-8 byte string to a wide character. Also get up to MAX_MCO -// composing characters. Use no more than p[maxlen]. -// -// @param [out] pcc: composing chars, last one is 0 -int utfc_ptr2char_len(const char *p, int *pcc, int maxlen) +/// Get the screen char at the beginning of a string with length +/// +/// Like utfc_ptr2schar but use no more than p[maxlen]. +schar_T utfc_ptr2schar_len(const char *p, int maxlen, int *firstc) + FUNC_ATTR_NONNULL_ALL { assert(maxlen > 0); - int i = 0; + size_t len = (size_t)utf_ptr2len_len(p, maxlen); + if (len > (size_t)maxlen || (len == 1 && (uint8_t)(*p) >= 0x80) || len == 0) { + // invalid or truncated sequence + *firstc = (uint8_t)(*p); + return 0; + } - int len = utf_ptr2len_len(p, maxlen); - // Is it safe to use utf_ptr2char()? - bool safe = len > 1 && len <= maxlen; - int c = safe ? utf_ptr2char(p) : (uint8_t)(*p); + int c = utf_ptr2char(p); + *firstc = c; + bool first_compose = utf_iscomposing(c); + maxlen = MIN(maxlen, MAX_SCHAR_SIZE - 1 - first_compose); + len = (size_t)utfc_ptr2len_len(p, maxlen); - // Only accept a composing char when the first char isn't illegal. - if ((safe || c < 0x80) && len < maxlen && (uint8_t)p[len] >= 0x80) { - for (; i < MAX_MCO; i++) { - int len_cc = utf_ptr2len_len(p + len, maxlen - len); - safe = len_cc > 1 && len_cc <= maxlen - len; - if (!safe || (pcc[i] = utf_ptr2char(p + len)) < 0x80 - || !(i == 0 ? utf_composinglike(p, p + len) : utf_iscomposing(pcc[i]))) { - break; - } - len += len_cc; - } - } + return schar_from_buf_first(p, len, first_compose); +} - if (i < MAX_MCO) { - // last composing char must be 0 - pcc[i] = 0; +/// Caller must ensure there is space for `first_compose` +static schar_T schar_from_buf_first(const char *buf, size_t len, bool first_compose) +{ + if (first_compose) { + char cbuf[MAX_SCHAR_SIZE]; + cbuf[0] = ' '; + memcpy(cbuf + 1, buf, len); + return schar_from_buf(cbuf, len + 1); + } else { + return schar_from_buf(buf, len); } - - return c; -#undef ISCOMPOSING } /// Get the length of a UTF-8 byte sequence representing a single codepoint @@ -878,8 +867,7 @@ int utfc_ptr2len(const char *const p) return 1; } - // Check for composing characters. We can handle only the first six, but - // skip all of them (otherwise the cursor would get stuck). + // Check for composing characters. int prevlen = 0; while (true) { if ((uint8_t)p[len] < 0x80 || !utf_composinglike(p + prevlen, p + len)) { @@ -1815,12 +1803,12 @@ int utf_cp_tail_off(const char *base, const char *p_in) /// Return the offset from "p" to the first byte of the codepoint it points /// to. Can start anywhere in a stream of bytes. /// Note: Unlike `utf_head_off`, this counts individual codepoints of composed characters -/// separately and returns a negative offset. +/// separately. /// /// @param[in] base Pointer to start of string /// @param[in] p Pointer to byte for which to return the offset to the previous codepoint // -/// @return 0 if invalid sequence, else offset to previous codepoint +/// @return 0 if invalid sequence, else number of bytes to previous codepoint int utf_cp_head_off(const char *base, const char *p) { int i; @@ -1830,17 +1818,20 @@ int utf_cp_head_off(const char *base, const char *p) } // Find the first character that is not 10xx.xxxx - for (i = 0; p - i > base; i--) { - if (((uint8_t)p[i] & 0xc0) != 0x80) { + for (i = 0; p - i >= base; i++) { + if (((uint8_t)p[-i] & 0xc0) != 0x80) { break; } } - // Find the last character that is 10xx.xxxx - for (int j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {} + // Find the last character that is 10xx.xxxx (condition terminates on NUL) + int j = 1; + while (((uint8_t)p[j] & 0xc0) == 0x80) { + j++; + } // Check for illegal sequence. - if (utf8len_tab[(uint8_t)p[i]] == 1) { + if (utf8len_tab[(uint8_t)p[-i]] != j + i) { return 0; } return i; -- cgit From ac1113ded5f8f09dd99a9894d7a7e795626fb728 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Nov 2023 23:40:37 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment --- src/nvim/mbyte.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 3a13aeddb8..92eddb3cf1 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1248,7 +1248,7 @@ bool mb_isalpha(int a) static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) { - int c1, c2, cdiff; + int c1, c2; char buffer[6]; while (true) { @@ -1263,7 +1263,7 @@ static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) continue; } - cdiff = utf_fold(c1) - utf_fold(c2); + int cdiff = utf_fold(c1) - utf_fold(c2); if (cdiff != 0) { return cdiff; } @@ -1295,7 +1295,7 @@ static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) } while (n1 > 0 && n2 > 0 && *s1 != NUL && *s2 != NUL) { - cdiff = (int)((uint8_t)(*s1)) - (int)((uint8_t)(*s2)); + int cdiff = (int)((uint8_t)(*s1)) - (int)((uint8_t)(*s2)); if (cdiff != 0) { return cdiff; } @@ -1444,11 +1444,11 @@ ssize_t mb_utf_index_to_bytes(const char *s, size_t len, size_t index, bool use_ FUNC_ATTR_NONNULL_ALL { size_t count = 0; - size_t clen, i; + size_t clen; if (index == 0) { return 0; } - for (i = 0; i < len; i += clen) { + for (size_t i = 0; i < len; i += clen) { clen = (size_t)utf_ptr2len_len(s + i, (int)(len - i)); // NB: gets the byte value of invalid sequence bytes. // we only care whether the char fits in the BMP or not @@ -1841,8 +1841,6 @@ int utf_cp_head_off(const char *base, const char *p) void utf_find_illegal(void) { pos_T pos = curwin->w_cursor; - char *p; - int len; vimconv_T vimconv; char *tofree = NULL; @@ -1856,7 +1854,7 @@ void utf_find_illegal(void) curwin->w_cursor.coladd = 0; while (true) { - p = get_cursor_pos_ptr(); + char *p = get_cursor_pos_ptr(); if (vimconv.vc_type != CONV_NONE) { xfree(tofree); tofree = string_convert(&vimconv, p, NULL); @@ -1869,7 +1867,7 @@ void utf_find_illegal(void) while (*p != NUL) { // Illegal means that there are not enough trail bytes (checked by // utf_ptr2len()) or too many of them (overlong sequence). - len = utf_ptr2len(p); + int len = utf_ptr2len(p); if ((uint8_t)(*p) >= 0x80 && (len == 1 || utf_char2len(utf_ptr2char(p)) != len)) { if (vimconv.vc_type == CONV_NONE) { curwin->w_cursor.col += (colnr_T)(p - get_cursor_pos_ptr()); -- cgit From a827003e3052c6d9ee7bdb71518182e9bd76317d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 25 Nov 2023 11:32:32 +0100 Subject: build: rework IWYU mapping files Create mapping to most of the C spec and some POSIX specific functions. This is more robust than relying files shipped with IWYU. --- src/nvim/mbyte.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 92eddb3cf1..37764498c8 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -62,7 +62,6 @@ #include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" -#include "nvim/os/os_defs.h" #include "nvim/pos.h" #include "nvim/strings.h" #include "nvim/types.h" -- cgit From 17d81ac2abc42b75e46d7212f6d8d9c1fe8d4f0a Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 25 Nov 2023 17:52:03 +0100 Subject: build(IWYU): map everything in the C99 specification --- src/nvim/mbyte.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 37764498c8..1151e80e4c 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include "auto/config.h" -- cgit From 40139738eb479d0913ec6ce751ca5adfa50ad8c3 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 26 Nov 2023 21:36:02 +0100 Subject: build: enable IWYU on mac --- src/nvim/mbyte.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 1151e80e4c..a2c0e70d77 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "auto/config.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/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index a2c0e70d77..e2bae06817 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -62,7 +62,7 @@ #include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/strings.h" #include "nvim/types.h" #include "nvim/vim.h" -- cgit From 6c14ae6bfaf51415b555e9a6b85d1d280976358d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 20:27:32 +0100 Subject: refactor: rename types.h to types_defs.h --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index e2bae06817..c50331e7d5 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -64,7 +64,7 @@ #include "nvim/os/os.h" #include "nvim/pos_defs.h" #include "nvim/strings.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/vim.h" typedef struct { -- cgit From c9f53d0e40815644bbf7c57a0792f2c793c954aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Nov 2023 19:00:14 +0800 Subject: refactor: iwyu (#26269) --- src/nvim/mbyte.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c50331e7d5..9443511640 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -49,7 +49,6 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/grid_defs.h" #include "nvim/iconv.h" #include "nvim/keycodes.h" #include "nvim/macros.h" -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/mbyte.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 9443511640..f2883cc5c7 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -37,7 +37,7 @@ #include "auto/config.h" #include "nvim/arabic.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" @@ -49,9 +49,9 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/grid.h" -#include "nvim/iconv.h" +#include "nvim/iconv_defs.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/mbyte_defs.h" @@ -64,7 +64,7 @@ #include "nvim/pos_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" typedef struct { int rangeStart; -- cgit