refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
Dundar Göc
2022-08-26 23:11:25 +02:00
committed by dundargoc
parent 433818351b
commit 04cdea5f4a
35 changed files with 461 additions and 466 deletions

View File

@@ -1311,9 +1311,9 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i
// to only match at the start of a line. Otherwise just match the
// pattern. Also need to double backslashes.
if (ctrl_x_mode_line_or_eval()) {
char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\");
char *pat_esc = (char *)vim_strsave_escaped(pat, (char_u *)"\\");
size_t len = STRLEN(pat_esc) + 10;
size_t len = strlen(pat_esc) + 10;
ptr = xmalloc(len);
vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc);
regmatch.regprog = vim_regcomp((char *)ptr, RE_MAGIC);
@@ -1788,13 +1788,13 @@ static void ins_compl_set_original_text(char *str)
/// matches.
void ins_compl_addfrommatch(void)
{
char_u *p;
char *p;
int len = (int)curwin->w_cursor.col - (int)compl_col;
int c;
compl_T *cp;
assert(compl_shown_match != NULL);
p = (char_u *)compl_shown_match->cp_str;
if ((int)STRLEN(p) <= len) { // the match is too short
p = compl_shown_match->cp_str;
if ((int)strlen(p) <= len) { // the match is too short
// When still at the original match use the first entry that matches
// the leader.
if (!match_at_original_text(compl_shown_match)) {
@@ -1805,17 +1805,17 @@ void ins_compl_addfrommatch(void)
for (cp = compl_shown_match->cp_next; cp != NULL
&& !is_first_match(cp); cp = cp->cp_next) {
if (compl_leader == NULL
|| ins_compl_equal(cp, (char_u *)compl_leader, STRLEN(compl_leader))) {
p = (char_u *)cp->cp_str;
|| ins_compl_equal(cp, (char_u *)compl_leader, strlen(compl_leader))) {
p = cp->cp_str;
break;
}
}
if (p == NULL || (int)STRLEN(p) <= len) {
if (p == NULL || (int)strlen(p) <= len) {
return;
}
}
p += len;
c = utf_ptr2char((char *)p);
c = utf_ptr2char(p);
ins_compl_addleader(c);
}
@@ -2008,17 +2008,17 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
// but only do this, if the Popup is still visible
if (c == Ctrl_E) {
ins_compl_delete();
char_u *p = NULL;
char *p = NULL;
if (compl_leader != NULL) {
p = (char_u *)compl_leader;
p = compl_leader;
} else if (compl_first_match != NULL) {
p = (char_u *)compl_orig_text;
p = compl_orig_text;
}
if (p != NULL) {
const int compl_len = get_compl_len();
const int len = (int)STRLEN(p);
const int len = (int)strlen(p);
if (len > compl_len) {
ins_bytes_len((char *)p + compl_len, (size_t)(len - compl_len));
ins_bytes_len(p + compl_len, (size_t)(len - compl_len));
}
}
retval = true;
@@ -2929,33 +2929,33 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
bool *cont_s_ipos)
{
*match_len = 0;
char_u *ptr = (char_u *)ml_get_buf(ins_buf, cur_match_pos->lnum, false) + cur_match_pos->col;
char *ptr = ml_get_buf(ins_buf, cur_match_pos->lnum, false) + cur_match_pos->col;
int len;
if (ctrl_x_mode_line_or_eval()) {
if (compl_status_adding()) {
if (cur_match_pos->lnum >= ins_buf->b_ml.ml_line_count) {
return NULL;
}
ptr = (char_u *)ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false);
ptr = ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false);
if (!p_paste) {
ptr = (char_u *)skipwhite((char *)ptr);
ptr = skipwhite(ptr);
}
}
len = (int)STRLEN(ptr);
len = (int)strlen(ptr);
} else {
char_u *tmp_ptr = ptr;
char *tmp_ptr = ptr;
if (compl_status_adding() && compl_length <= (int)STRLEN(tmp_ptr)) {
if (compl_status_adding() && compl_length <= (int)strlen(tmp_ptr)) {
tmp_ptr += compl_length;
// Skip if already inside a word.
if (vim_iswordp(tmp_ptr)) {
if (vim_iswordp((char_u *)tmp_ptr)) {
return NULL;
}
// Find start of next word.
tmp_ptr = find_word_start(tmp_ptr);
tmp_ptr = (char *)find_word_start((char_u *)tmp_ptr);
}
// Find end of this word.
tmp_ptr = find_word_end(tmp_ptr);
tmp_ptr = (char *)find_word_end((char_u *)tmp_ptr);
len = (int)(tmp_ptr - ptr);
if (compl_status_adding() && len == compl_length) {
@@ -2964,12 +2964,12 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
// normal command "J" was used. IOSIZE is always greater than
// compl_length, so the next STRNCPY always works -- Acevedo
STRNCPY(IObuff, ptr, len); // NOLINT(runtime/printf)
ptr = (char_u *)ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false);
tmp_ptr = ptr = (char_u *)skipwhite((char *)ptr);
ptr = ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false);
tmp_ptr = ptr = skipwhite(ptr);
// Find start of next word.
tmp_ptr = find_word_start(tmp_ptr);
tmp_ptr = (char *)find_word_start((char_u *)tmp_ptr);
// Find end of next word.
tmp_ptr = find_word_end(tmp_ptr);
tmp_ptr = (char *)find_word_end((char_u *)tmp_ptr);
if (tmp_ptr > ptr) {
if (*ptr != ')' && IObuff[len - 1] != TAB) {
if (IObuff[len - 1] != ' ') {
@@ -2992,7 +2992,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
*cont_s_ipos = true;
}
IObuff[len] = NUL;
ptr = (char_u *)IObuff;
ptr = IObuff;
}
if (len == compl_length) {
return NULL;
@@ -3001,7 +3001,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
}
*match_len = len;
return ptr;
return (char_u *)ptr;
}
/// Get the next set of words matching "compl_pattern" for default completion(s)
@@ -3285,7 +3285,7 @@ static int ins_compl_get_exp(pos_T *ini)
static void ins_compl_update_shown_match(void)
{
while (!ins_compl_equal(compl_shown_match,
(char_u *)compl_leader, STRLEN(compl_leader))
(char_u *)compl_leader, strlen(compl_leader))
&& compl_shown_match->cp_next != NULL
&& !is_first_match(compl_shown_match->cp_next)) {
compl_shown_match = compl_shown_match->cp_next;
@@ -3294,10 +3294,10 @@ static void ins_compl_update_shown_match(void)
// If we didn't find it searching forward, and compl_shows_dir is
// backward, find the last match.
if (compl_shows_dir_backward()
&& !ins_compl_equal(compl_shown_match, (char_u *)compl_leader, STRLEN(compl_leader))
&& !ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader))
&& (compl_shown_match->cp_next == NULL
|| is_first_match(compl_shown_match->cp_next))) {
while (!ins_compl_equal(compl_shown_match, (char_u *)compl_leader, STRLEN(compl_leader))
while (!ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader))
&& compl_shown_match->cp_prev != NULL
&& !is_first_match(compl_shown_match->cp_prev)) {
compl_shown_match = compl_shown_match->cp_prev;
@@ -3442,7 +3442,7 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a
if (!match_at_original_text(compl_shown_match)
&& compl_leader != NULL
&& !ins_compl_equal(compl_shown_match,
(char_u *)compl_leader, STRLEN(compl_leader))) {
(char_u *)compl_leader, strlen(compl_leader))) {
todo++;
} else {
// Remember a matching item.
@@ -3721,17 +3721,17 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length);
}
} else if (compl_status_adding()) {
char_u *prefix = (char_u *)"\\<";
char *prefix = "\\<";
// we need up to 2 extra chars for the prefix
compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col, compl_length) + 2);
if (!vim_iswordp((char_u *)line + compl_col)
|| (compl_col > 0
&& (vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + compl_col))))) {
prefix = (char_u *)"";
prefix = "";
}
STRCPY(compl_pattern, prefix);
(void)quote_meta((char_u *)compl_pattern + STRLEN(prefix),
(void)quote_meta((char_u *)compl_pattern + strlen(prefix),
(char_u *)line + compl_col, compl_length);
} else if (--startcol < 0
|| !vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + startcol + 1))) {