aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/textobject.c
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-01-13 00:35:39 +0100
committerGitHub <noreply@github.com>2023-01-13 07:35:39 +0800
commitf2141de9e462ed8976b2a59337c32a0fcba2a11d (patch)
tree30de2ad03e5ed71bcff9fc29edde84322281b5bb /src/nvim/textobject.c
parent2f1fd15554921dc2375c2ad136e727229e72348a (diff)
downloadrneovim-f2141de9e462ed8976b2a59337c32a0fcba2a11d.tar.gz
rneovim-f2141de9e462ed8976b2a59337c32a0fcba2a11d.tar.bz2
rneovim-f2141de9e462ed8976b2a59337c32a0fcba2a11d.zip
refactor: replace char_u with char 20 (#21714)
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src/nvim/textobject.c')
-rw-r--r--src/nvim/textobject.c84
1 files changed, 42 insertions, 42 deletions
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 "<aaa>" tag. Ignore "<aaa/>".
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 "</aaa>". 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;
}