From fb1edb2f5728d74ae811c6ab32395598cea5609b Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/textobject.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 02174edeb1..a8f4cc7aeb 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -213,13 +213,13 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both) } curwin->w_cursor.lnum = curr; if (curr == curbuf->b_ml.ml_line_count && what != '}') { - char_u *line = ml_get(curr); + char_u *line = (char_u *)ml_get(curr); // Put the cursor on the last character in the last line and make the // motion inclusive. if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { curwin->w_cursor.col--; - curwin->w_cursor.col -= utf_head_off(line, line + curwin->w_cursor.col); + curwin->w_cursor.col -= utf_head_off((char *)line, (char *)line + curwin->w_cursor.col); *pincl = true; } } else { @@ -260,7 +260,7 @@ bool startPS(linenr_T lnum, int para, bool both) { char_u *s; - s = ml_get(lnum); + s = (char_u *)ml_get(lnum); if (*s == para || *s == '\f' || (both && *s == '}')) { return true; } @@ -1467,7 +1467,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e while (col_start > 0) { col_start--; - col_start -= utf_head_off(line, line + col_start); + col_start -= utf_head_off((char *)line, (char *)line + col_start); n = 0; if (escape != NULL) { while (col_start - n > 0 && vim_strchr((char *)escape, -- cgit From 49e893f296bca9eef5ff45a3d746c261d055bf10 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/textobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index a8f4cc7aeb..6863b40599 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1032,7 +1032,7 @@ int current_block(oparg_T *oap, long count, bool include, int what, int other) /// @return true if the cursor is on a "" tag. Ignore "". static bool in_html_tag(bool end_tag) { - char_u *line = get_cursor_line_ptr(); + char_u *line = (char_u *)get_cursor_line_ptr(); char_u *p; int c; int lc = NUL; @@ -1493,7 +1493,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e bool current_quote(oparg_T *oap, long count, bool include, int quotechar) FUNC_ATTR_NONNULL_ALL { - char_u *line = get_cursor_line_ptr(); + char_u *line = (char_u *)get_cursor_line_ptr(); int col_end; int col_start = curwin->w_cursor.col; bool inclusive = false; -- cgit From 73207cae611a1efb8cd17139e8228772daeb9866 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/textobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 6863b40599..621efa44cf 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1157,7 +1157,7 @@ again: // Search for matching "". First isolate the "aaa". inc_cursor(); - p = get_cursor_pos_ptr(); + p = (char_u *)get_cursor_pos_ptr(); for (cp = p; *cp != NUL && *cp != '>' && !ascii_iswhite(*cp); MB_PTR_ADV(cp)) {} @@ -1196,7 +1196,7 @@ again: } } } else { - char_u *c = get_cursor_pos_ptr(); + char_u *c = (char_u *)get_cursor_pos_ptr(); // Exclude the '<' of the end tag. // If the closing tag is on new line, do not decrement cursor, but make // operation exclusive, so that the linefeed will be selected -- cgit From df646572c53f55268a5dbb61628d7c3b302d5663 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:53:52 +0200 Subject: docs: fix typos (#20394) Co-authored-by: Raphael Co-authored-by: smjonas Co-authored-by: zeertzjq --- src/nvim/textobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 621efa44cf..e6b330cbf1 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1503,7 +1503,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) bool inside_quotes = false; // Looks like "i'" done before bool selected_quote = false; // Has quote inside selection int i; - bool restore_vis_bef = false; // resotre VIsual on abort + bool restore_vis_bef = false; // restore VIsual on abort // When 'selection' is "exclusive" move the cursor to where it would be // with 'selection' "inclusive", so that the logic is the same for both. -- cgit From 04cdea5f4ac49fa62cc4091a5c26791b80b4cc4c Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/textobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index e6b330cbf1..dbe7110d60 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -213,13 +213,13 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both) } curwin->w_cursor.lnum = curr; if (curr == curbuf->b_ml.ml_line_count && what != '}') { - char_u *line = (char_u *)ml_get(curr); + char *line = ml_get(curr); // Put the cursor on the last character in the last line and make the // motion inclusive. - if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { + if ((curwin->w_cursor.col = (colnr_T)strlen(line)) != 0) { curwin->w_cursor.col--; - curwin->w_cursor.col -= utf_head_off((char *)line, (char *)line + curwin->w_cursor.col); + curwin->w_cursor.col -= utf_head_off(line, line + curwin->w_cursor.col); *pincl = true; } } else { -- cgit From 784e498c4a9c1f03266ced5ec3f55c3a6c94b80d Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:47:44 +0200 Subject: refactor: clang-tidy fixes to silence clangd warning (#20683) * refactor: readability-uppercase-literal-suffix * refactor: readability-named-parameter * refactor: bugprone-suspicious-string-compare * refactor: google-readability-casting * refactor: readability-redundant-control-flow * refactor: bugprone-too-small-loop-variable * refactor: readability-non-const-parameter * refactor: readability-avoid-const-params-in-decls * refactor: google-readability-todo * refactor: readability-inconsistent-declaration-parameter-name * refactor: bugprone-suspicious-missing-comma * refactor: remove noisy or slow warnings --- src/nvim/textobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index dbe7110d60..8290fe14e5 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -229,7 +229,7 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both) } /// check if the string 's' is a nroff macro that is in option 'opt' -static bool inmacro(char_u *opt, char_u *s) +static bool inmacro(char_u *opt, const char_u *s) { char_u *macro; -- cgit From 66360675cf4d091b7460e4a8e1435c13216c1929 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 11 Sep 2022 17:12:44 +0200 Subject: build: allow IWYU to fix includes for all .c files Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers. --- src/nvim/textobject.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 8290fe14e5..b9b4d0dfe3 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -4,8 +4,11 @@ // textobject.c: functions for text objects #include +#include +#include #include "nvim/ascii.h" +#include "nvim/buffer_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" @@ -13,14 +16,19 @@ #include "nvim/fold.h" #include "nvim/globals.h" #include "nvim/indent.h" +#include "nvim/macros.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" +#include "nvim/memory.h" #include "nvim/normal.h" +#include "nvim/option_defs.h" #include "nvim/pos.h" +#include "nvim/screen.h" #include "nvim/search.h" -#include "nvim/textformat.h" +#include "nvim/strings.h" #include "nvim/textobject.h" +#include "nvim/types.h" #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From f2141de9e462ed8976b2a59337c32a0fcba2a11d Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 13 Jan 2023 00:35:39 +0100 Subject: refactor: replace char_u with char 20 (#21714) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/textobject.c | 84 +++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index b9b4d0dfe3..ee6c39a8ba 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -237,9 +237,9 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both) } /// check if the string 's' is a nroff macro that is in option 'opt' -static bool inmacro(char_u *opt, const char_u *s) +static bool inmacro(char *opt, const char *s) { - char_u *macro; + char *macro; for (macro = opt; macro[0]; macro++) { // Accept two characters in the option being equal to two characters @@ -266,14 +266,14 @@ static bool inmacro(char_u *opt, const char_u *s) /// If 'both' is true also stop at '}' bool startPS(linenr_T lnum, int para, bool both) { - char_u *s; + char *s; - s = (char_u *)ml_get(lnum); - if (*s == para || *s == '\f' || (both && *s == '}')) { + s = ml_get(lnum); + if ((uint8_t)(*s) == para || *s == '\f' || (both && *s == '}')) { return true; } - if (*s == '.' && (inmacro((char_u *)p_sections, s + 1) - || (!para && inmacro(p_para, s + 1)))) { + if (*s == '.' && (inmacro(p_sections, s + 1) + || (!para && inmacro((char *)p_para, s + 1)))) { return true; } return false; @@ -1040,8 +1040,8 @@ int current_block(oparg_T *oap, long count, bool include, int what, int other) /// @return true if the cursor is on a "" tag. Ignore "". static bool in_html_tag(bool end_tag) { - char_u *line = (char_u *)get_cursor_line_ptr(); - char_u *p; + char *line = get_cursor_line_ptr(); + char *p; int c; int lc = NUL; pos_T pos; @@ -1097,8 +1097,8 @@ int current_tagblock(oparg_T *oap, long count_arg, bool include) pos_T start_pos; pos_T end_pos; pos_T old_start, old_end; - char_u *p; - char_u *cp; + char *p; + char *cp; int len; bool do_include = include; bool save_p_ws = p_ws; @@ -1165,7 +1165,7 @@ again: // Search for matching "". First isolate the "aaa". inc_cursor(); - p = (char_u *)get_cursor_pos_ptr(); + p = get_cursor_pos_ptr(); for (cp = p; *cp != NUL && *cp != '>' && !ascii_iswhite(*cp); MB_PTR_ADV(cp)) {} @@ -1204,7 +1204,7 @@ again: } } } else { - char_u *c = (char_u *)get_cursor_pos_ptr(); + char *c = get_cursor_pos_ptr(); // Exclude the '<' of the end tag. // If the closing tag is on new line, do not decrement cursor, but make // operation exclusive, so that the linefeed will be selected @@ -1441,15 +1441,15 @@ extend: /// @param escape escape characters, can be NULL /// /// @return column number of "quotechar" or -1 when not found. -static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape) +static int find_next_quote(char *line, int col, int quotechar, char *escape) { int c; for (;;) { - c = line[col]; + c = (uint8_t)line[col]; if (c == NUL) { return -1; - } else if (escape != NULL && vim_strchr((char *)escape, c)) { + } else if (escape != NULL && vim_strchr(escape, c)) { col++; if (line[col] == NUL) { return -1; @@ -1457,7 +1457,7 @@ static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape) } else if (c == quotechar) { break; } - col += utfc_ptr2len((char *)line + col); + col += utfc_ptr2len(line + col); } return col; } @@ -1469,23 +1469,23 @@ static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape) /// @param escape escape characters, can be NULL /// /// @return the found column or zero. -static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *escape) +static int find_prev_quote(char *line, int col_start, int quotechar, char *escape) { int n; while (col_start > 0) { col_start--; - col_start -= utf_head_off((char *)line, (char *)line + col_start); + col_start -= utf_head_off(line, line + col_start); n = 0; if (escape != NULL) { - while (col_start - n > 0 && vim_strchr((char *)escape, - line[col_start - n - 1]) != NULL) { + while (col_start - n > 0 && vim_strchr(escape, + (uint8_t)line[col_start - n - 1]) != NULL) { n++; } } if (n & 1) { col_start -= n; // uneven number of escape chars, skip it - } else if (line[col_start] == quotechar) { + } else if ((uint8_t)line[col_start] == quotechar) { break; } } @@ -1501,7 +1501,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e bool current_quote(oparg_T *oap, long count, bool include, int quotechar) FUNC_ATTR_NONNULL_ALL { - char_u *line = (char_u *)get_cursor_line_ptr(); + char *line = get_cursor_line_ptr(); int col_end; int col_start = curwin->w_cursor.col; bool inclusive = false; @@ -1550,16 +1550,16 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) // quotes. if (vis_bef_curs) { inside_quotes = VIsual.col > 0 - && line[VIsual.col - 1] == quotechar + && (uint8_t)line[VIsual.col - 1] == quotechar && line[curwin->w_cursor.col] != NUL - && line[curwin->w_cursor.col + 1] == quotechar; + && (uint8_t)line[curwin->w_cursor.col + 1] == quotechar; i = VIsual.col; col_end = curwin->w_cursor.col; } else { inside_quotes = curwin->w_cursor.col > 0 - && line[curwin->w_cursor.col - 1] == quotechar + && (uint8_t)line[curwin->w_cursor.col - 1] == quotechar && line[VIsual.col] != NUL - && line[VIsual.col + 1] == quotechar; + && (uint8_t)line[VIsual.col + 1] == quotechar; i = curwin->w_cursor.col; col_end = VIsual.col; } @@ -1571,14 +1571,14 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) if (line[i] == NUL) { break; } - if (line[i++] == quotechar) { + if ((uint8_t)line[i++] == quotechar) { selected_quote = true; break; } } } - if (!vis_empty && line[col_start] == quotechar) { + if (!vis_empty && (uint8_t)line[col_start] == quotechar) { // Already selecting something and on a quote character. Find the // next quoted string. if (vis_bef_curs) { @@ -1588,7 +1588,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) if (col_start < 0) { goto abort_search; } - col_end = find_next_quote(line, col_start + 1, quotechar, (char_u *)curbuf->b_p_qe); + col_end = find_next_quote(line, col_start + 1, quotechar, curbuf->b_p_qe); if (col_end < 0) { // We were on a starting quote perhaps? col_end = col_start; @@ -1596,17 +1596,17 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) } } else { col_end = find_prev_quote(line, col_start, quotechar, NULL); - if (line[col_end] != quotechar) { + if ((uint8_t)line[col_end] != quotechar) { goto abort_search; } - col_start = find_prev_quote(line, col_end, quotechar, (char_u *)curbuf->b_p_qe); - if (line[col_start] != quotechar) { + col_start = find_prev_quote(line, col_end, quotechar, curbuf->b_p_qe); + if ((uint8_t)line[col_start] != quotechar) { // We were on an ending quote perhaps? col_start = col_end; col_end = curwin->w_cursor.col; } } - } else if (line[col_start] == quotechar || !vis_empty) { + } else if ((uint8_t)line[col_start] == quotechar || !vis_empty) { int first_col = col_start; if (!vis_empty) { @@ -1628,7 +1628,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) goto abort_search; } // Find close quote character. - col_end = find_next_quote(line, col_start + 1, quotechar, (char_u *)curbuf->b_p_qe); + col_end = find_next_quote(line, col_start + 1, quotechar, curbuf->b_p_qe); if (col_end < 0) { goto abort_search; } @@ -1641,8 +1641,8 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) } } else { // Search backward for a starting quote. - col_start = find_prev_quote(line, col_start, quotechar, (char_u *)curbuf->b_p_qe); - if (line[col_start] != quotechar) { + col_start = find_prev_quote(line, col_start, quotechar, curbuf->b_p_qe); + if ((uint8_t)line[col_start] != quotechar) { // No quote before the cursor, look after the cursor. col_start = find_next_quote(line, col_start, quotechar, NULL); if (col_start < 0) { @@ -1651,7 +1651,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) } // Find close quote character. - col_end = find_next_quote(line, col_start + 1, quotechar, (char_u *)curbuf->b_p_qe); + col_end = find_next_quote(line, col_start + 1, quotechar, curbuf->b_p_qe); if (col_end < 0) { goto abort_search; } @@ -1685,9 +1685,9 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) || (vis_bef_curs && !selected_quote && (inside_quotes - || (line[VIsual.col] != quotechar + || ((uint8_t)line[VIsual.col] != quotechar && (VIsual.col == 0 - || line[VIsual.col - 1] != quotechar))))) { + || (uint8_t)line[VIsual.col - 1] != quotechar))))) { VIsual = curwin->w_cursor; redraw_curbuf_later(UPD_INVERTED); } @@ -1715,9 +1715,9 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) // quote. if (inside_quotes || (!selected_quote - && line[VIsual.col] != quotechar + && (uint8_t)line[VIsual.col] != quotechar && (line[VIsual.col] == NUL - || line[VIsual.col + 1] != quotechar))) { + || (uint8_t)line[VIsual.col + 1] != quotechar))) { dec_cursor(); VIsual = curwin->w_cursor; } -- cgit