aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-03-04 13:10:00 +0100
committerGitHub <noreply@github.com>2023-03-04 20:10:00 +0800
commit6cab36e5b7b0d741abe6c5a7c0e20bad30361034 (patch)
tree8f00dab70b4a63ff572600a6e4824f59b0ae29c6
parenta4f443994bb91321b00f29af9e6357df9102ce75 (diff)
downloadrneovim-6cab36e5b7b0d741abe6c5a7c0e20bad30361034.tar.gz
rneovim-6cab36e5b7b0d741abe6c5a7c0e20bad30361034.tar.bz2
rneovim-6cab36e5b7b0d741abe6c5a7c0e20bad30361034.zip
refactor: replace char_u with char or uint8_t (#22400)
Work on https://github.com/neovim/neovim/issues/459
-rw-r--r--src/nvim/digraph.c16
-rw-r--r--src/nvim/edit.c18
-rw-r--r--src/nvim/eval.c20
-rw-r--r--src/nvim/fileio.c46
-rw-r--r--src/nvim/grid_defs.h2
-rw-r--r--src/nvim/help.c2
-rw-r--r--src/nvim/keycodes.c10
-rw-r--r--src/nvim/mapping.c5
-rw-r--r--src/nvim/mbyte.c22
-rw-r--r--src/nvim/memline.c26
-rw-r--r--src/nvim/ops.c4
-rw-r--r--src/nvim/option.c29
-rw-r--r--src/nvim/regexp_defs.h18
-rw-r--r--src/nvim/spell.c14
-rw-r--r--src/nvim/spell_defs.h4
-rw-r--r--src/nvim/spellfile.c56
-rw-r--r--src/nvim/spellsuggest.c126
17 files changed, 212 insertions, 206 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index a057978a5e..ae13164191 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -41,8 +41,8 @@
typedef int result_T;
typedef struct digraph {
- char_u char1;
- char_u char2;
+ uint8_t char1;
+ uint8_t char2;
result_T result;
} digr_T;
@@ -1493,7 +1493,7 @@ char *get_digraph_for_char(int val_arg)
{
const int val = val_arg;
const digr_T *dp;
- static char_u r[3];
+ static char r[3];
for (int use_defaults = 0; use_defaults <= 1; use_defaults++) {
if (use_defaults == 0) {
@@ -1503,10 +1503,10 @@ char *get_digraph_for_char(int val_arg)
}
for (int i = 0; use_defaults ? dp->char1 != NUL : i < user_digraphs.ga_len; i++) {
if (dp->result == val) {
- r[0] = dp->char1;
- r[1] = dp->char2;
+ r[0] = (char)dp->char1;
+ r[1] = (char)dp->char2;
r[2] = NUL;
- return (char *)r;
+ return r;
}
dp++;
}
@@ -1645,8 +1645,8 @@ static void registerdigraph(int char1, int char2, int n)
// Add a new digraph to the table.
dp = GA_APPEND_VIA_PTR(digr_T, &user_digraphs);
- dp->char1 = (char_u)char1;
- dp->char2 = (char_u)char2;
+ dp->char1 = (uint8_t)char1;
+ dp->char2 = (uint8_t)char2;
dp->result = n;
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 2849268da2..9eb4802d97 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -2780,7 +2780,7 @@ static bool echeck_abbr(int c)
// that the NL replaced. The extra one stores the characters after the cursor
// that were deleted (always white space).
-static char_u *replace_stack = NULL;
+static uint8_t *replace_stack = NULL;
static ssize_t replace_stack_nr = 0; // next entry in replace stack
static ssize_t replace_stack_len = 0; // max. number of entries
@@ -2801,11 +2801,11 @@ void replace_push(int c)
replace_stack_len += 50;
replace_stack = xrealloc(replace_stack, (size_t)replace_stack_len);
}
- char_u *p = replace_stack + replace_stack_nr - replace_offset;
+ uint8_t *p = replace_stack + replace_stack_nr - replace_offset;
if (replace_offset) {
memmove(p + 1, p, (size_t)replace_offset);
}
- *p = (char_u)c;
+ *p = (uint8_t)c;
replace_stack_nr++;
}
@@ -2868,13 +2868,13 @@ static void replace_pop_ins(void)
static void mb_replace_pop_ins(int cc)
{
int n;
- char_u buf[MB_MAXBYTES + 1];
+ uint8_t buf[MB_MAXBYTES + 1];
int i;
if ((n = MB_BYTE2LEN(cc)) > 1) {
- buf[0] = (char_u)cc;
+ buf[0] = (uint8_t)cc;
for (i = 1; i < n; i++) {
- buf[i] = (char_u)replace_pop();
+ buf[i] = (uint8_t)replace_pop();
}
ins_bytes_len((char *)buf, (size_t)n);
} else {
@@ -2893,10 +2893,10 @@ static void mb_replace_pop_ins(int cc)
break;
}
- buf[0] = (char_u)c;
+ buf[0] = (uint8_t)c;
assert(n > 1);
for (i = 1; i < n; i++) {
- buf[i] = (char_u)replace_pop();
+ buf[i] = (uint8_t)replace_pop();
}
if (utf_iscomposing(utf_ptr2char((char *)buf))) {
ins_bytes_len((char *)buf, (size_t)n);
@@ -3113,7 +3113,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
return true;
}
- if (keytyped == get_special_key_code((char_u *)look + 1)) {
+ if (keytyped == get_special_key_code(look + 1)) {
return true;
}
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index da2a88346a..67fede1aea 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1185,7 +1185,7 @@ int eval_foldexpr(char *arg, int *cp)
// the number.
char *s = tv.vval.v_string;
if (!ascii_isdigit(*s) && *s != '-') {
- *cp = (char_u)(*s++);
+ *cp = (uint8_t)(*s++);
}
retval = atol(s);
}
@@ -1597,7 +1597,7 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool
dictitem_T *di;
if (lp->ll_tv == NULL) {
- cc = (char_u)(*endp);
+ cc = (uint8_t)(*endp);
*endp = NUL;
if (lp->ll_blob != NULL) {
if (op != NULL && *op != '=') {
@@ -1993,7 +1993,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
}
arg = xp->xp_pattern;
if (*arg != NUL) {
- while ((c = (char_u)(*++arg)) != NUL && (c == ' ' || c == '\t')) {}
+ while ((c = (uint8_t)(*++arg)) != NUL && (c == ' ' || c == '\t')) {}
}
}
@@ -2602,7 +2602,7 @@ static int eval5(char **arg, typval_T *rettv, int evaluate)
// Repeat computing, until no '+', '-' or '.' is following.
for (;;) {
- int op = (char_u)(**arg);
+ int op = (uint8_t)(**arg);
if (op != '+' && op != '-' && op != '.') {
break;
}
@@ -2747,7 +2747,7 @@ static int eval6(char **arg, typval_T *rettv, int evaluate, int want_string)
// Repeat computing, until no '*', '/' or '%' is following.
for (;;) {
- op = (char_u)(**arg);
+ op = (uint8_t)(**arg);
if (op != '*' && op != '/' && op != '%') {
break;
}
@@ -7441,9 +7441,9 @@ void ex_execute(exarg_T *eap)
const size_t len = strlen(argstr);
ga_grow(&ga, (int)len + 2);
if (!GA_EMPTY(&ga)) {
- ((char_u *)(ga.ga_data))[ga.ga_len++] = ' ';
+ ((char *)(ga.ga_data))[ga.ga_len++] = ' ';
}
- memcpy((char_u *)(ga.ga_data) + ga.ga_len, argstr, len + 1);
+ memcpy((char *)(ga.ga_data) + ga.ga_len, argstr, len + 1);
if (eap->cmdidx != CMD_execute) {
xfree((void *)argstr);
}
@@ -7838,7 +7838,7 @@ repeat:
// ":~" - path relative to the home directory
// ":8" - shortname path - postponed till after
while (src[*usedlen] == ':'
- && ((c = (char_u)src[*usedlen + 1]) == '.' || c == '~' || c == '8')) {
+ && ((c = (uint8_t)src[*usedlen + 1]) == '.' || c == '~' || c == '8')) {
*usedlen += 2;
if (c == '8') {
continue;
@@ -8084,7 +8084,7 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, const char
if (zero_width == regmatch.startp[0]) {
// avoid getting stuck on a match with an empty string
int i = utfc_ptr2len(tail);
- memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i);
+ memmove((char *)ga.ga_data + ga.ga_len, tail, (size_t)i);
ga.ga_len += i;
tail += i;
continue;
@@ -8103,7 +8103,7 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, const char
// copy the text up to where the match is
int i = (int)(regmatch.startp[0] - tail);
- memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i);
+ memmove((char *)ga.ga_data + ga.ga_len, tail, (size_t)i);
// add the substituted text
(void)vim_regsub(&regmatch, sub, expr,
(char *)ga.ga_data + ga.ga_len + i, sublen,
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index c93df43cff..6a13548027 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -107,19 +107,19 @@ enum {
// Structure to pass arguments from buf_write() to buf_write_bytes().
struct bw_info {
- int bw_fd; // file descriptor
- char *bw_buf; // buffer with data to be written
- int bw_len; // length of data
- int bw_flags; // FIO_ flags
- char_u bw_rest[CONV_RESTLEN]; // not converted bytes
- int bw_restlen; // nr of bytes in bw_rest[]
- int bw_first; // first write call
- char *bw_conv_buf; // buffer for writing converted chars
- size_t bw_conv_buflen; // size of bw_conv_buf
- int bw_conv_error; // set for conversion error
- linenr_T bw_conv_error_lnum; // first line with error or zero
- linenr_T bw_start_lnum; // line number at start of buffer
- iconv_t bw_iconv_fd; // descriptor for iconv() or -1
+ int bw_fd; // file descriptor
+ char *bw_buf; // buffer with data to be written
+ int bw_len; // length of data
+ int bw_flags; // FIO_ flags
+ uint8_t bw_rest[CONV_RESTLEN]; // not converted bytes
+ int bw_restlen; // nr of bytes in bw_rest[]
+ int bw_first; // first write call
+ char *bw_conv_buf; // buffer for writing converted chars
+ size_t bw_conv_buflen; // size of bw_conv_buf
+ int bw_conv_error; // set for conversion error
+ linenr_T bw_conv_error_lnum; // first line with error or zero
+ linenr_T bw_start_lnum; // line number at start of buffer
+ iconv_t bw_iconv_fd; // descriptor for iconv() or -1
};
typedef struct {
@@ -989,7 +989,7 @@ retry:
int ni;
long tlen = 0;
for (;;) {
- p = (char_u *)ml_get(read_buf_lnum) + read_buf_col;
+ p = (uint8_t *)ml_get(read_buf_lnum) + read_buf_col;
int n = (int)strlen((char *)p);
if ((int)tlen + n + 1 > size) {
// Filled up to "size", append partial line.
@@ -1798,7 +1798,7 @@ failed:
msg_scrolled_ign = true;
if (!read_stdin && !read_buffer) {
- p = (char_u *)msg_trunc_attr(IObuff, false, 0);
+ p = (uint8_t *)msg_trunc_attr(IObuff, false, 0);
}
if (read_stdin || read_buffer || restart_edit != 0
@@ -1859,7 +1859,7 @@ failed:
// When opening a new file locate undo info and read it.
if (read_undo_file) {
- char_u hash[UNDO_HASH_SIZE];
+ uint8_t hash[UNDO_HASH_SIZE];
sha256_finish(&sha_ctx, hash);
u_read_undo(NULL, hash, fname);
@@ -3208,7 +3208,7 @@ restore_backup:
// Skip the BOM when appending and the file already existed, the BOM
// only makes sense at the start of the file.
if (buf->b_p_bomb && !write_bin && (!append || perm < 0)) {
- write_info.bw_len = make_bom((char_u *)buffer, fenc);
+ write_info.bw_len = make_bom(buffer, fenc);
if (write_info.bw_len > 0) {
// don't convert
write_info.bw_flags = FIO_NOCONVERT | wb_flags;
@@ -3991,9 +3991,10 @@ static int buf_write_bytes(struct bw_info *ip)
/// @param flags FIO_ flags that specify which encoding to use
///
/// @return true for an error, false when it's OK.
-static bool ucs2bytes(unsigned c, char **pp, int flags) FUNC_ATTR_NONNULL_ALL
+static bool ucs2bytes(unsigned c, char **pp, int flags)
+ FUNC_ATTR_NONNULL_ALL
{
- char_u *p = (char_u *)(*pp);
+ uint8_t *p = (uint8_t *)(*pp);
bool error = false;
if (flags & FIO_UCS4) {
@@ -4170,8 +4171,9 @@ static char *check_for_bom(const char *p_in, int size, int *lenp, int flags)
/// Generate a BOM in "buf[4]" for encoding "name".
///
/// @return the length of the BOM (zero when no BOM).
-static int make_bom(char_u *buf, char *name)
+static int make_bom(char *buf_in, char *name)
{
+ uint8_t *buf = (uint8_t *)buf_in;
int flags = get_fio_flags(name);
// Can't put a BOM in a non-Unicode file.
@@ -4187,7 +4189,7 @@ static int make_bom(char_u *buf, char *name)
}
char *p = (char *)buf;
(void)ucs2bytes(0xfeff, &p, flags);
- return (int)((char_u *)p - buf);
+ return (int)((uint8_t *)p - buf);
}
/// Shorten filename of a buffer.
@@ -4953,7 +4955,7 @@ int buf_check_timestamp(buf_T *buf)
// Reload the buffer.
buf_reload(buf, orig_mode, reload == RELOAD_DETECT);
if (buf->b_p_udf && buf->b_ffname != NULL) {
- char_u hash[UNDO_HASH_SIZE];
+ uint8_t hash[UNDO_HASH_SIZE];
// Any existing undo file is unusable, write it now.
u_compute_hash(buf, hash);
diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h
index db31f7b984..830c74e86d 100644
--- a/src/nvim/grid_defs.h
+++ b/src/nvim/grid_defs.h
@@ -50,7 +50,7 @@ struct ScreenGrid {
schar_T *chars;
sattr_T *attrs;
size_t *line_offset;
- char_u *line_wraps;
+ char *line_wraps;
// last column that was drawn (not cleared with the default background).
// only used when "throttled" is set. Not allocated by grid_alloc!
diff --git a/src/nvim/help.c b/src/nvim/help.c
index 5fa48e0cee..968f0bc2f4 100644
--- a/src/nvim/help.c
+++ b/src/nvim/help.c
@@ -1022,7 +1022,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
*p2 = NUL;
vim_snprintf(NameBuff, MAXPATHL,
_("E154: Duplicate tag \"%s\" in file %s/%s"),
- ((char_u **)ga.ga_data)[i], dir, p2 + 1);
+ ((char **)ga.ga_data)[i], dir, p2 + 1);
emsg(NameBuff);
*p2 = '\t';
break;
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index 8114efc10c..404087fec3 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -723,7 +723,7 @@ int find_special_key(const char **const srcp, const size_t src_len, int *const m
if (modifiers != 0 && last_dash[l + 1] == '>') {
key = utf_ptr2char(last_dash + off);
} else {
- key = get_special_key_code((char_u *)last_dash + off);
+ key = get_special_key_code(last_dash + off);
if (!(flags & FSK_KEEP_X_KEY)) {
key = handle_x_keys(key);
}
@@ -822,18 +822,18 @@ int find_special_key_in_table(int c)
/// a termcap name.
///
/// @return Key code or 0 if not found.
-int get_special_key_code(const char_u *name)
+int get_special_key_code(const char *name)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
for (int i = 0; key_names_table[i].name != NULL; i++) {
const char *const table_name = key_names_table[i].name;
int j;
- for (j = 0; ascii_isident(name[j]) && table_name[j] != NUL; j++) {
- if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) {
+ for (j = 0; ascii_isident((uint8_t)name[j]) && table_name[j] != NUL; j++) {
+ if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC((uint8_t)name[j])) {
break;
}
}
- if (!ascii_isident(name[j]) && table_name[j] == NUL) {
+ if (!ascii_isident((uint8_t)name[j]) && table_name[j] == NUL) {
return key_names_table[i].key;
}
}
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 60524b9fb7..3c4ce0ee2b 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -1162,8 +1162,9 @@ static bool expand_buffer = false;
/// @param cpo_flags Value of various flags present in &cpo
///
/// @return NULL when there is a problem.
-static char *translate_mapping(char_u *str, int cpo_flags)
+static char *translate_mapping(char *str_in, int cpo_flags)
{
+ uint8_t *str = (uint8_t *)str_in;
garray_T ga;
ga_init(&ga, 1, 40);
@@ -1346,7 +1347,7 @@ int ExpandMappings(char *pat, regmatch_T *regmatch, int *numMatches, char ***mat
continue;
}
- char *p = translate_mapping((char_u *)mp->m_keys, CPO_TO_CPO_FLAGS);
+ char *p = translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
if (p == NULL) {
continue;
}
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;
}
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index e9988eb844..0d8da68a02 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -179,19 +179,19 @@ enum {
// different machines. b0_magic_* is used to check the byte order and size of
// variables, because the rest of the swap file is not portable.
struct block0 {
- char_u b0_id[2]; ///< ID for block 0: BLOCK0_ID0 and BLOCK0_ID1.
+ char b0_id[2]; ///< ID for block 0: BLOCK0_ID0 and BLOCK0_ID1.
char b0_version[10]; // Vim version string
- char_u b0_page_size[4]; // number of bytes per page
- char_u b0_mtime[4]; // last modification time of file
- char_u b0_ino[4]; // inode of b0_fname
- char_u b0_pid[4]; // process id of creator (or 0)
+ char b0_page_size[4]; // number of bytes per page
+ char b0_mtime[4]; // last modification time of file
+ char b0_ino[4]; // inode of b0_fname
+ char b0_pid[4]; // process id of creator (or 0)
char b0_uname[B0_UNAME_SIZE]; // name of user (uid if no name)
char b0_hname[B0_HNAME_SIZE]; // host name (if it has a name)
char b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited
long b0_magic_long; // check for byte order of long
int b0_magic_int; // check for byte order of int
int16_t b0_magic_short; // check for byte order of short
- char_u b0_magic_char; // check for last char
+ char b0_magic_char; // check for last char
};
// Note: b0_dirty and b0_flags are put at the end of the file name. For very
@@ -3556,19 +3556,21 @@ static bool fnamecmp_ino(char *fname_c, char *fname_s, long ino_block0)
/// Move a long integer into a four byte character array.
/// Used for machine independency in block zero.
-static void long_to_char(long n, char_u *s)
+static void long_to_char(long n, char *s_in)
{
- s[0] = (char_u)(n & 0xff);
+ uint8_t *s= (uint8_t *)s_in;
+ s[0] = (uint8_t)(n & 0xff);
n = (unsigned)n >> 8;
- s[1] = (char_u)(n & 0xff);
+ s[1] = (uint8_t)(n & 0xff);
n = (unsigned)n >> 8;
- s[2] = (char_u)(n & 0xff);
+ s[2] = (uint8_t)(n & 0xff);
n = (unsigned)n >> 8;
- s[3] = (char_u)(n & 0xff);
+ s[3] = (uint8_t)(n & 0xff);
}
-static long char_to_long(const char_u *s)
+static long char_to_long(const char *s_in)
{
+ const uint8_t *s = (uint8_t *)s_in;
long retval;
retval = s[3];
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d2a96be5ad..884eeef433 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1186,7 +1186,7 @@ int do_execreg(int regname, int colon, int addcr, int silent)
/// used only after other typeahead has been processed.
static void put_reedit_in_typebuf(int silent)
{
- char_u buf[3];
+ uint8_t buf[3];
if (restart_edit == NUL) {
return;
@@ -1197,7 +1197,7 @@ static void put_reedit_in_typebuf(int silent)
buf[1] = 'R';
buf[2] = NUL;
} else {
- buf[0] = (char_u)(restart_edit == 'I' ? 'i' : restart_edit);
+ buf[0] = (uint8_t)(restart_edit == 'I' ? 'i' : restart_edit);
buf[1] = NUL;
}
if (ins_typebuf((char *)buf, REMAP_NONE, 0, true, silent) == OK) {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 6ddc3b5cfb..04cf7eede4 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -839,9 +839,8 @@ static void do_set_num(int opt_idx, int opt_flags, char **argp, int nextchar, co
// Handle some special cases with string option values
static void munge_string_opt_val(char **varp, char **oldval, char **const origval,
- char_u **const origval_l, char_u **const origval_g,
- char **const argp, char *const whichwrap, size_t whichwraplen,
- char **const save_argp)
+ char **const origval_l, char **const origval_g, char **const argp,
+ char *const whichwrap, size_t whichwraplen, char **const save_argp)
{
// Set 'keywordprg' to ":help" if an empty
// value was passed to :set by the user.
@@ -870,11 +869,11 @@ static void munge_string_opt_val(char **varp, char **oldval, char **const origva
if (*origval == *oldval) {
*origval = *varp;
}
- if (*origval_l == (char_u *)(*oldval)) {
- *origval_l = *(char_u **)varp;
+ if (*origval_l == *oldval) {
+ *origval_l = *varp;
}
- if (*origval_g == (char_u *)(*oldval)) {
- *origval_g = *(char_u **)varp;
+ if (*origval_g == *oldval) {
+ *origval_g = *varp;
}
*oldval = *varp;
} else if (varp == &p_ww && ascii_isdigit(**argp)) {
@@ -919,8 +918,8 @@ static void do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
char *varp = varp_arg;
char *save_arg = NULL;
char *s = NULL;
- char_u *origval_l = NULL;
- char_u *origval_g = NULL;
+ char *origval_l = NULL;
+ char *origval_g = NULL;
char whichwrap[80];
// When using ":set opt=val" for a global option
@@ -935,12 +934,12 @@ static void do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
char *oldval = *(char **)varp;
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) {
- origval_l = *(char_u **)get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
- origval_g = *(char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
+ origval_l = *(char **)get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
+ origval_g = *(char **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
// A global-local string option might have an empty option as value to
// indicate that the global value should be used.
- if (((int)options[opt_idx].indir & PV_BOTH) && origval_l == (char_u *)empty_option) {
+ if (((int)options[opt_idx].indir & PV_BOTH) && origval_l == empty_option) {
origval_l = origval_g;
}
}
@@ -1132,8 +1131,8 @@ static void do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
// origval may be freed by did_set_string_option(), make a copy.
char *saved_origval = (origval != NULL) ? xstrdup(origval) : NULL;
- char *saved_origval_l = (origval_l != NULL) ? xstrdup((char *)origval_l) : NULL;
- char *saved_origval_g = (origval_g != NULL) ? xstrdup((char *)origval_g) : NULL;
+ char *saved_origval_l = (origval_l != NULL) ? xstrdup(origval_l) : NULL;
+ char *saved_origval_g = (origval_g != NULL) ? xstrdup(origval_g) : NULL;
// newval (and varp) may become invalid if the buffer is closed by
// autocommands.
@@ -4672,7 +4671,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
return;
}
}
- int key = get_special_key_code((char_u *)arg + 1);
+ int key = get_special_key_code(arg + 1);
if (key == 0) { // unknown name
xp->xp_context = EXPAND_NOTHING;
return;
diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h
index b27a5b5942..ef155e8d46 100644
--- a/src/nvim/regexp_defs.h
+++ b/src/nvim/regexp_defs.h
@@ -98,11 +98,11 @@ typedef struct {
bool re_in_use;
int regstart;
- char_u reganch;
- char_u *regmust;
+ uint8_t reganch;
+ uint8_t *regmust;
int regmlen;
- char_u reghasz;
- char_u program[];
+ uint8_t reghasz;
+ uint8_t program[];
} bt_regprog_T;
// Structure representing a NFA state.
@@ -130,7 +130,7 @@ typedef struct {
int reganch; // pattern starts with ^
int regstart; // char at start of pattern
- char_u *match_text; // plain text to match with
+ uint8_t *match_text; // plain text to match with
int has_zend; // pattern contains \ze
int has_backref; // pattern contains \1 .. \9
@@ -158,19 +158,19 @@ typedef struct {
// from 1 to zero the matches need to be freed.
struct reg_extmatch {
int16_t refcnt;
- char_u *matches[NSUBEXP];
+ uint8_t *matches[NSUBEXP];
};
struct regengine {
/// bt_regcomp or nfa_regcomp
- regprog_T *(*regcomp)(char_u *, int);
+ regprog_T *(*regcomp)(uint8_t *, int);
/// bt_regfree or nfa_regfree
void (*regfree)(regprog_T *);
/// bt_regexec_nl or nfa_regexec_nl
- int (*regexec_nl)(regmatch_T *, char_u *, colnr_T, bool);
+ int (*regexec_nl)(regmatch_T *, uint8_t *, colnr_T, bool);
/// bt_regexec_mult or nfa_regexec_mult
long (*regexec_multi)(regmmatch_T *, win_T *, buf_T *, linenr_T, colnr_T, proftime_T *, int *);
- // char_u *expr;
+ // uint8_t *expr;
};
// Flags used by vim_regsub() and vim_regsub_both()
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 117a770e50..dbe8ad5763 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -737,7 +737,7 @@ static void find_word(matchinf_T *mip, int mode)
// If the word ends the sequence of compound flags of the
// words must match with one of the COMPOUNDRULE items and
// the number of syllables must not be too large.
- mip->mi_compflags[mip->mi_complen] = (char_u)((unsigned)flags >> 24);
+ mip->mi_compflags[mip->mi_complen] = (uint8_t)((unsigned)flags >> 24);
mip->mi_compflags[mip->mi_complen + 1] = NUL;
if (word_ends) {
char fword[MAXWLEN] = { 0 };
@@ -2354,8 +2354,8 @@ void clear_spell_chartab(spelltab_T *sp)
CLEAR_FIELD(sp->st_isu);
for (int i = 0; i < 256; i++) {
- sp->st_fold[i] = (char_u)i;
- sp->st_upper[i] = (char_u)i;
+ sp->st_fold[i] = (uint8_t)i;
+ sp->st_upper[i] = (uint8_t)i;
}
// We include digits. A word shouldn't start with a digit, but handling
@@ -2366,11 +2366,11 @@ void clear_spell_chartab(spelltab_T *sp)
for (int i = 'A'; i <= 'Z'; i++) {
sp->st_isw[i] = true;
sp->st_isu[i] = true;
- sp->st_fold[i] = (char_u)(i + 0x20);
+ sp->st_fold[i] = (uint8_t)(i + 0x20);
}
for (int i = 'a'; i <= 'z'; i++) {
sp->st_isw[i] = true;
- sp->st_upper[i] = (char_u)(i - 0x20);
+ sp->st_upper[i] = (uint8_t)(i - 0x20);
}
}
@@ -2391,8 +2391,8 @@ void init_spell_chartab(void)
// The folded/upper-cased value is different between latin1 and
// utf8 for 0xb5, causing E763 for no good reason. Use the latin1
// value for utf-8 to avoid this.
- spelltab.st_fold[i] = (f < 256) ? (char_u)f : (char_u)i;
- spelltab.st_upper[i] = (u < 256) ? (char_u)u : (char_u)i;
+ spelltab.st_fold[i] = (f < 256) ? (uint8_t)f : (uint8_t)i;
+ spelltab.st_upper[i] = (u < 256) ? (uint8_t)u : (uint8_t)i;
}
}
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index 93cf335c3a..bda43a94d1 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -206,8 +206,8 @@ typedef struct langp_S {
typedef struct {
bool st_isw[256]; // flags: is word char
bool st_isu[256]; // flags: is uppercase char
- char_u st_fold[256]; // chars: folded case
- char_u st_upper[256]; // chars: upper case
+ uint8_t st_fold[256]; // chars: folded case
+ uint8_t st_upper[256]; // chars: upper case
} spelltab_T;
// Use our own character-case definitions, because the current locale may
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index e9dd0a4d5e..bb2ef1a458 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -1079,7 +1079,7 @@ static int read_charflags_section(FILE *fd)
// Set the word-char flags and fill SPELL_ISUPPER() table.
if (flags != NULL && fol != NULL) {
- set_spell_charflags((char_u *)flags, flagslen, (char *)fol);
+ set_spell_charflags(flags, flagslen, (char *)fol);
}
xfree(flags);
@@ -1314,7 +1314,7 @@ static int read_words_section(FILE *fd, slang_T *lp, int len)
int done = 0;
int i;
int c;
- char_u word[MAXWLEN];
+ uint8_t word[MAXWLEN];
while (done < len) {
// Read one word at a time.
@@ -1323,7 +1323,7 @@ static int read_words_section(FILE *fd, slang_T *lp, int len)
if (c == EOF) {
return SP_TRUNCERROR;
}
- word[i] = (char_u)c;
+ word[i] = (uint8_t)c;
if (word[i] == NUL) {
break;
}
@@ -1480,7 +1480,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
// Add all flags to "sl_compallflags".
if (vim_strchr("?*+[]/", c) == NULL
&& !byte_in_str(slang->sl_compallflags, c)) {
- *ap++ = (char_u)c;
+ *ap++ = (uint8_t)c;
*ap = NUL;
}
@@ -1493,7 +1493,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
atstart = 0;
} else {
if (!byte_in_str(slang->sl_compstartflags, c)) {
- *cp++ = (char_u)c;
+ *cp++ = (uint8_t)c;
*cp = NUL;
}
if (atstart == 1) {
@@ -1508,7 +1508,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
XFREE_CLEAR(slang->sl_comprules);
crp = NULL;
} else {
- *crp++ = (char_u)c;
+ *crp++ = (uint8_t)c;
}
}
@@ -1709,7 +1709,7 @@ static int spell_read_tree(FILE *fd, char **bytsp, long *bytsp_len, idx_T **idxs
*idxsp = ip;
// Recursively read the tree and store it in the array.
- idx = read_tree_node(fd, (char_u *)bp, ip, (int)len, 0, prefixtree, prefixcnt);
+ idx = read_tree_node(fd, bp, ip, (int)len, 0, prefixtree, prefixcnt);
if (idx < 0) {
return idx;
}
@@ -1729,9 +1729,10 @@ static int spell_read_tree(FILE *fd, char **bytsp, long *bytsp_len, idx_T **idxs
/// @param startidx current index in "byts" and "idxs"
/// @param prefixtree true for reading PREFIXTREE
/// @param maxprefcondnr maximum for <prefcondnr>
-static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx_T startidx,
+static idx_T read_tree_node(FILE *fd, char *byts_in, idx_T *idxs, int maxidx, idx_T startidx,
bool prefixtree, int maxprefcondnr)
{
+ uint8_t *byts = (uint8_t *)byts_in;
int len;
int n;
idx_T idx = startidx;
@@ -1746,7 +1747,7 @@ static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx
if (startidx + len >= maxidx) {
return SP_FORMERROR;
}
- byts[idx++] = (char_u)len;
+ byts[idx++] = (uint8_t)len;
// Read the byte values, flag/region bytes and shared indexes.
for (int i = 1; i <= len; i++) {
@@ -1806,7 +1807,7 @@ static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx
c = getc(fd); // <xbyte>
}
}
- byts[idx++] = (char_u)c;
+ byts[idx++] = (uint8_t)c;
}
// Recursively read the children for non-shared siblings.
@@ -1818,7 +1819,7 @@ static idx_T read_tree_node(FILE *fd, char_u *byts, idx_T *idxs, int maxidx, idx
idxs[startidx + i] &= ~SHARED_MASK;
} else {
idxs[startidx + i] = idx;
- idx = read_tree_node(fd, byts, idxs, maxidx, idx,
+ idx = read_tree_node(fd, (char *)byts, idxs, maxidx, idx,
prefixtree, maxprefcondnr);
if (idx < 0) {
break;
@@ -2783,11 +2784,11 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry)
if (entry->ae_flags != NULL
&& (affile->af_compforbid != 0 || affile->af_comppermit != 0)) {
for (p = entry->ae_flags; *p != NUL;) {
- char_u *prevp = (char_u *)p;
+ char *prevp = p;
unsigned flag = get_affitem(affile->af_flagtype, &p);
if (flag == affile->af_comppermit || flag == affile->af_compforbid) {
STRMOVE(prevp, p);
- p = (char *)prevp;
+ p = prevp;
if (flag == affile->af_comppermit) {
entry->ae_comppermit = true;
} else {
@@ -2894,12 +2895,12 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags
STRCAT(p, "/");
}
spin->si_compflags = p;
- char_u *tp = (char_u *)p + strlen(p);
+ uint8_t *tp = (uint8_t *)p + strlen(p);
for (p = compflags; *p != NUL;) {
if (vim_strchr("/?*+[]", (uint8_t)(*p)) != NULL) {
// Copy non-flag characters directly.
- *tp++ = (char_u)(*p++);
+ *tp++ = (uint8_t)(*p++);
} else {
// First get the flag number, also checks validity.
prevp = p;
@@ -3640,7 +3641,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
char rline[MAXLINELEN];
char *line;
char *pc = NULL;
- char_u *p;
+ char *p;
int l;
int retval = OK;
bool did_word = false;
@@ -3748,7 +3749,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
regionmask = spin->si_region;
// Check for flags and region after a slash.
- p = (char_u *)vim_strchr(line, '/');
+ p = vim_strchr(line, '/');
if (p != NULL) {
*p++ = NUL;
while (*p != NUL) {
@@ -3758,13 +3759,13 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
flags |= WF_BANNED;
} else if (*p == '?') { // Rare word.
flags |= WF_RARE;
- } else if (ascii_isdigit(*p)) { // region number(s)
+ } else if (ascii_isdigit((uint8_t)(*p))) { // region number(s)
if ((flags & WF_REGION) == 0) { // first one
regionmask = 0;
}
flags |= WF_REGION;
- l = *p - '0';
+ l = (uint8_t)(*p) - '0';
if (l == 0 || l > spin->si_region_count) {
smsg(_("Invalid region nr in %s line %ld: %s"),
fname, lnum, p);
@@ -3817,7 +3818,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
static void *getroom(spellinfo_T *spin, size_t len, bool align)
FUNC_ATTR_NONNULL_RET
{
- char_u *p;
+ char *p;
sblock_T *bl = spin->si_blocks;
assert(len <= SBLOCKSIZE);
@@ -3837,7 +3838,7 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align)
spin->si_blocks_cnt++;
}
- p = bl->sb_data + bl->sb_used;
+ p = (char *)bl->sb_data + bl->sb_used;
bl->sb_used += (int)len;
return p;
@@ -3876,7 +3877,7 @@ static wordnode_T *wordtree_alloc(spellinfo_T *spin)
/// Control characters and trailing '/' are invalid. Space is OK.
static bool valid_spell_word(const char *word, const char *end)
{
- if (!utf_valid_string((char_u *)word, (char_u *)end)) {
+ if (!utf_valid_string(word, end)) {
return false;
}
for (const char *p = word; *p != NUL && p < end; p += utfc_ptr2len(p)) {
@@ -3913,7 +3914,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
}
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
- for (const char_u *p = (char_u *)pfxlist; res == OK; p++) {
+ for (const char *p = pfxlist; res == OK; p++) {
if (!need_affix || (p != NULL && *p != NUL)) {
res = tree_add_word(spin, (char_u *)foldword, spin->si_foldroot, ct | flags,
region, p == NULL ? 0 : *p);
@@ -3925,7 +3926,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
spin->si_foldwcount++;
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) {
- for (const char_u *p = (char_u *)pfxlist; res == OK; p++) {
+ for (const char *p = pfxlist; res == OK; p++) {
if (!need_affix || (p != NULL && *p != NUL)) {
res = tree_add_word(spin, (char_u *)word, spin->si_keeproot, flags,
region, p == NULL ? 0 : *p);
@@ -5727,8 +5728,9 @@ static void init_spellfile(void)
/// Set the spell character tables from strings in the .spl file.
///
/// @param cnt length of "flags"
-static void set_spell_charflags(const char_u *flags, int cnt, char *fol)
+static void set_spell_charflags(const char *flags_in, int cnt, char *fol)
{
+ const uint8_t *flags = (uint8_t *)flags_in;
// We build the new tables here first, so that we can compare with the
// previous one.
spelltab_T new_st;
@@ -5745,9 +5747,9 @@ static void set_spell_charflags(const char_u *flags, int cnt, char *fol)
if (*p != NUL) {
c = mb_ptr2char_adv((const char **)&p);
- new_st.st_fold[i + 128] = (char_u)c;
+ new_st.st_fold[i + 128] = (uint8_t)c;
if (i + 128 != c && new_st.st_isu[i + 128] && c < 256) {
- new_st.st_upper[c] = (char_u)(i + 128);
+ new_st.st_upper[c] = (uint8_t)(i + 128);
}
}
}
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index ea2d5e6ff7..2823e74c2f 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -189,28 +189,28 @@ typedef enum {
/// Struct to keep the state at each level in suggest_try_change().
typedef struct trystate_S {
- state_T ts_state; ///< state at this level, STATE_
- int ts_score; ///< score
- idx_T ts_arridx; ///< index in tree array, start of node
- int16_t ts_curi; ///< index in list of child nodes
- char_u ts_fidx; ///< index in fword[], case-folded bad word
- char_u ts_fidxtry; ///< ts_fidx at which bytes may be changed
- char_u ts_twordlen; ///< valid length of tword[]
- char_u ts_prefixdepth; ///< stack depth for end of prefix or
- ///< PFD_PREFIXTREE or PFD_NOPREFIX
- char_u ts_flags; ///< TSF_ flags
- char_u ts_tcharlen; ///< number of bytes in tword character
- char_u ts_tcharidx; ///< current byte index in tword character
- char_u ts_isdiff; ///< DIFF_ values
- char_u ts_fcharstart; ///< index in fword where badword char started
- char_u ts_prewordlen; ///< length of word in "preword[]"
- char_u ts_splitoff; ///< index in "tword" after last split
- char_u ts_splitfidx; ///< "ts_fidx" at word split
- char_u ts_complen; ///< nr of compound words used
- char_u ts_compsplit; ///< index for "compflags" where word was spit
- char_u ts_save_badflags; ///< su_badflags saved here
- char_u ts_delidx; ///< index in fword for char that was deleted,
- ///< valid when "ts_flags" has TSF_DIDDEL
+ state_T ts_state; ///< state at this level, STATE_
+ int ts_score; ///< score
+ idx_T ts_arridx; ///< index in tree array, start of node
+ int16_t ts_curi; ///< index in list of child nodes
+ uint8_t ts_fidx; ///< index in fword[], case-folded bad word
+ uint8_t ts_fidxtry; ///< ts_fidx at which bytes may be changed
+ uint8_t ts_twordlen; ///< valid length of tword[]
+ uint8_t ts_prefixdepth; ///< stack depth for end of prefix or
+ ///< PFD_PREFIXTREE or PFD_NOPREFIX
+ uint8_t ts_flags; ///< TSF_ flags
+ uint8_t ts_tcharlen; ///< number of bytes in tword character
+ uint8_t ts_tcharidx; ///< current byte index in tword character
+ uint8_t ts_isdiff; ///< DIFF_ values
+ uint8_t ts_fcharstart; ///< index in fword where badword char started
+ uint8_t ts_prewordlen; ///< length of word in "preword[]"
+ uint8_t ts_splitoff; ///< index in "tword" after last split
+ uint8_t ts_splitfidx; ///< "ts_fidx" at word split
+ uint8_t ts_complen; ///< nr of compound words used
+ uint8_t ts_compsplit; ///< index for "compflags" where word was spit
+ uint8_t ts_save_badflags; ///< su_badflags saved here
+ uint8_t ts_delidx; ///< index in fword for char that was deleted,
+ ///< valid when "ts_flags" has TSF_DIDDEL
} trystate_T;
// values for ts_isdiff
@@ -243,7 +243,7 @@ static long spell_suggest_timeout = 5000;
/// Returns true when the sequence of flags in "compflags" plus "flag" can
/// possibly form a valid compounded word. This also checks the COMPOUNDRULE
/// lines if they don't contain wildcards.
-static bool can_be_compound(trystate_T *sp, slang_T *slang, char_u *compflags, int flag)
+static bool can_be_compound(trystate_T *sp, slang_T *slang, uint8_t *compflags, int flag)
{
// If the flag doesn't appear in sl_compstartflags or sl_compallflags
// then it can't possibly compound.
@@ -256,7 +256,7 @@ static bool can_be_compound(trystate_T *sp, slang_T *slang, char_u *compflags, i
// possibly can form a match with COMPOUNDRULE patterns. This only
// makes sense when we have two or more words.
if (slang->sl_comprules != NULL && sp->ts_complen > sp->ts_compsplit) {
- compflags[sp->ts_complen] = (char_u)flag;
+ compflags[sp->ts_complen] = (uint8_t)flag;
compflags[sp->ts_complen + 1] = NUL;
bool v = match_compoundrule(slang, compflags + sp->ts_compsplit);
compflags[sp->ts_complen] = NUL;
@@ -349,7 +349,7 @@ static int badword_captype(char *word, char *end)
/// @return the offset.
static int bytes2offset(char **pp)
{
- char_u *p = (char_u *)(*pp);
+ uint8_t *p = (uint8_t *)(*pp);
int nr;
int c = *p++;
@@ -1145,10 +1145,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// words and split word. NUL terminated
// when going deeper but not when coming
// back.
- char_u compflags[MAXWLEN]; // compound flags, one for each word
+ uint8_t compflags[MAXWLEN]; // compound flags, one for each word
int newscore;
int score;
- char_u *byts, *fbyts, *pbyts;
+ uint8_t *byts, *fbyts, *pbyts;
idx_T *idxs, *fidxs, *pidxs;
int c, c2, c3;
int n = 0;
@@ -1165,7 +1165,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
bool goodword_ends;
#ifdef DEBUG_TRIEWALK
// Stores the name of the change made at each level.
- char_u changename[MAXWLEN][80];
+ uint8_t changename[MAXWLEN][80];
#endif
int breakcheckcount = 1000;
bool compound_ok;
@@ -1181,7 +1181,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
if (soundfold) {
// Going through the soundfold tree.
- byts = fbyts = (char_u *)slang->sl_sbyts;
+ byts = fbyts = (uint8_t *)slang->sl_sbyts;
idxs = fidxs = slang->sl_sidxs;
pbyts = NULL;
pidxs = NULL;
@@ -1190,9 +1190,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
} else {
// When there are postponed prefixes we need to use these first. At
// the end of the prefix we continue in the case-fold tree.
- fbyts = (char_u *)slang->sl_fbyts;
+ fbyts = (uint8_t *)slang->sl_fbyts;
fidxs = slang->sl_fidxs;
- pbyts = (char_u *)slang->sl_pbyts;
+ pbyts = (uint8_t *)slang->sl_pbyts;
pidxs = slang->sl_pidxs;
if (pbyts != NULL) {
byts = pbyts;
@@ -1239,7 +1239,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
n = (int)sp->ts_state;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL;
- sp->ts_save_badflags = (char_u)su->su_badflags;
+ sp->ts_save_badflags = (uint8_t)su->su_badflags;
// At end of a prefix or at start of prefixtree: check for
// following word.
@@ -1256,7 +1256,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
go_deeper(stack, depth, 0);
depth++;
sp = &stack[depth];
- sp->ts_prefixdepth = (char_u)(depth - 1);
+ sp->ts_prefixdepth = (uint8_t)(depth - 1);
byts = fbyts;
idxs = fidxs;
sp->ts_arridx = 0;
@@ -1266,7 +1266,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
tword[sp->ts_twordlen] = NUL;
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, flags);
- sp->ts_prewordlen = (char_u)strlen(preword);
+ sp->ts_prewordlen = (uint8_t)strlen(preword);
sp->ts_splitoff = sp->ts_twordlen;
}
break;
@@ -1276,7 +1276,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// Past bytes in node and/or past NUL bytes.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL;
- sp->ts_save_badflags = (char_u)su->su_badflags;
+ sp->ts_save_badflags = (uint8_t)su->su_badflags;
break;
}
@@ -1379,7 +1379,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
break;
}
- compflags[sp->ts_complen] = (char_u)((unsigned)flags >> 24);
+ compflags[sp->ts_complen] = (uint8_t)((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
xstrlcpy(preword + sp->ts_prewordlen,
tword + sp->ts_splitoff,
@@ -1577,7 +1577,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
< slang->sl_compmax)
&& (can_be_compound(sp, slang, compflags, (int)((unsigned)flags >> 24)))) {
try_compound = true;
- compflags[sp->ts_complen] = (char_u)((unsigned)flags >> 24);
+ compflags[sp->ts_complen] = (uint8_t)((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
}
@@ -1596,7 +1596,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
sp->ts_curi--; // do the same NUL again
compflags[sp->ts_complen] = NUL;
} else {
- sp->ts_flags &= (char_u) ~TSF_DIDSPLIT;
+ sp->ts_flags &= (uint8_t) ~TSF_DIDSPLIT;
}
if (try_split || try_compound) {
@@ -1641,7 +1641,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
}
#endif
// Save things to be restored at STATE_SPLITUNDO.
- sp->ts_save_badflags = (char_u)su->su_badflags;
+ sp->ts_save_badflags = (uint8_t)su->su_badflags;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SPLITUNDO;
@@ -1652,7 +1652,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
if (!try_compound && !fword_ends) {
STRCAT(preword, " ");
}
- sp->ts_prewordlen = (char_u)strlen(preword);
+ sp->ts_prewordlen = (uint8_t)strlen(preword);
sp->ts_splitoff = sp->ts_twordlen;
sp->ts_splitfidx = sp->ts_fidx;
@@ -1673,12 +1673,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
if (fword_ends) {
// Copy the skipped character to preword.
memmove(preword + sp->ts_prewordlen, fword + sp->ts_fidx, (size_t)l);
- sp->ts_prewordlen = (char_u)(sp->ts_prewordlen + l);
+ sp->ts_prewordlen = (uint8_t)(sp->ts_prewordlen + l);
preword[sp->ts_prewordlen] = NUL;
} else {
sp->ts_score -= SCORE_SPLIT - SCORE_SUBST;
}
- sp->ts_fidx = (char_u)(sp->ts_fidx + l);
+ sp->ts_fidx = (uint8_t)(sp->ts_fidx + l);
}
// When compounding include compound flag in
@@ -1803,7 +1803,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// First byte.
sp->ts_tcharidx = 0;
sp->ts_tcharlen = MB_BYTE2LEN(c);
- sp->ts_fcharstart = (char_u)(sp->ts_fidx - 1);
+ sp->ts_fcharstart = (uint8_t)(sp->ts_fidx - 1);
sp->ts_isdiff = (newscore != 0)
? DIFF_YES : DIFF_NONE;
} else if (sp->ts_isdiff == DIFF_INSERT && sp->ts_fidx > 0) {
@@ -1816,8 +1816,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
if (sp->ts_isdiff == DIFF_YES) {
// Correct ts_fidx for the byte length of the
// character (we didn't check that before).
- sp->ts_fidx = (char_u)(sp->ts_fcharstart
- + utfc_ptr2len(fword + sp->ts_fcharstart));
+ sp->ts_fidx = (uint8_t)(sp->ts_fcharstart
+ + utfc_ptr2len(fword + sp->ts_fcharstart));
// For changing a composing character adjust
// the score from SCORE_SUBST to
@@ -1905,7 +1905,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// results.
c = utf_ptr2char(fword + sp->ts_fidx);
stack[depth].ts_fidx =
- (char_u)(stack[depth].ts_fidx + utfc_ptr2len(fword + sp->ts_fidx));
+ (uint8_t)(stack[depth].ts_fidx + utfc_ptr2len(fword + sp->ts_fidx));
if (utf_iscomposing(c)) {
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
@@ -1985,7 +1985,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// There are following bytes for the same character.
// We must find all bytes before trying
// delete/insert/swap/etc.
- sp->ts_tcharlen = (char_u)fl;
+ sp->ts_tcharlen = (uint8_t)fl;
sp->ts_tcharidx = 1;
sp->ts_isdiff = DIFF_INSERT;
}
@@ -2061,7 +2061,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
fl = utf_char2len(c2);
memmove(p, p + n, (size_t)fl);
utf_char2bytes(c, p + fl);
- stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
+ stack[depth].ts_fidxtry = (uint8_t)(sp->ts_fidx + n + fl);
} else {
// If this swap doesn't work then SWAP3 won't either.
PROF_STORE(sp->ts_state)
@@ -2118,7 +2118,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
memmove(p, p + n + fl, (size_t)tl);
utf_char2bytes(c2, p + tl);
utf_char2bytes(c, p + fl + tl);
- stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl + tl);
+ stack[depth].ts_fidxtry = (uint8_t)(sp->ts_fidx + n + fl + tl);
} else {
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
@@ -2166,7 +2166,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
fl += utf_ptr2len(p + n + fl);
memmove(p, p + n, (size_t)fl);
utf_char2bytes(c, p + fl);
- stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
+ stack[depth].ts_fidxtry = (uint8_t)(sp->ts_fidx + n + fl);
} else {
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
@@ -2203,7 +2203,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
tl = utf_ptr2len(p + n);
memmove(p + tl, p, (size_t)n);
utf_char2bytes(c, p);
- stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + tl);
+ stack[depth].ts_fidxtry = (uint8_t)(sp->ts_fidx + n + tl);
} else {
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
@@ -2293,7 +2293,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
repextra += tl - fl;
}
memmove(p, ftp->ft_to, (size_t)tl);
- stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + tl);
+ stack[depth].ts_fidxtry = (uint8_t)(sp->ts_fidx + tl);
stack[depth].ts_tcharlen = 0;
break;
}
@@ -2381,7 +2381,7 @@ static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
int c;
idx_T lo, hi, m;
char *p;
- char_u *byts = (char_u *)slang->sl_kbyts; // array with bytes of the words
+ uint8_t *byts = (uint8_t *)slang->sl_kbyts; // array with bytes of the words
idx_T *idxs = slang->sl_kidxs; // array with indexes
if (byts == NULL) {
@@ -2683,11 +2683,11 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *ba
/// handled already.
typedef struct {
int16_t sft_score; ///< lowest score used
- char_u sft_word[]; ///< soundfolded word
+ uint8_t sft_word[]; ///< soundfolded word
} sftword_T;
static sftword_T dumsft;
-#define HIKEY2SFT(p) ((sftword_T *)((p) - (dumsft.sft_word - (char_u *)&dumsft)))
+#define HIKEY2SFT(p) ((sftword_T *)((p) - (dumsft.sft_word - (uint8_t *)&dumsft)))
#define HI2SFT(hi) HIKEY2SFT((hi)->hi_key)
/// Prepare for calling suggest_try_soundalike().
@@ -2779,7 +2779,7 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
char theword[MAXWLEN];
int i;
int wlen;
- char_u *byts;
+ uint8_t *byts;
idx_T *idxs;
int n;
int wordcount;
@@ -2824,7 +2824,7 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
// previous wordnr.
orgnr += bytes2offset(&nrline);
- byts = (char_u *)slang->sl_fbyts;
+ byts = (uint8_t *)slang->sl_fbyts;
idxs = slang->sl_fidxs;
// Lookup the word "orgnr" one of the two tries.
@@ -2954,10 +2954,10 @@ static int soundfold_find(slang_T *slang, char *word)
{
idx_T arridx = 0;
int wlen = 0;
- char_u *ptr = (char_u *)word;
+ uint8_t *ptr = (uint8_t *)word;
int wordnr = 0;
- char_u *byts = (char_u *)slang->sl_sbyts;
+ uint8_t *byts = (uint8_t *)slang->sl_sbyts;
idx_T *idxs = slang->sl_sidxs;
for (;;) {
@@ -3236,15 +3236,15 @@ static void rescore_one(suginfo_T *su, suggest_T *stp)
// Only rescore suggestions that have no sal score yet and do have a
// language.
if (slang != NULL && !GA_EMPTY(&slang->sl_sal) && !stp->st_had_bonus) {
- char_u *p;
+ char *p;
if (slang == su->su_sallang) {
- p = (char_u *)su->su_sal_badword;
+ p = su->su_sal_badword;
} else {
spell_soundfold(slang, su->su_fbadword, true, sal_badword);
- p = (char_u *)sal_badword;
+ p = sal_badword;
}
- stp->st_altscore = stp_sal_score(stp, su, slang, (char *)p);
+ stp->st_altscore = stp_sal_score(stp, su, slang, p);
if (stp->st_altscore == SCORE_MAXMAX) {
stp->st_altscore = SCORE_BIG;
}