refactor: replace char_u with char or uint8_t (#22400)

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
dundargoc
2023-03-04 13:10:00 +01:00
committed by GitHub
parent a4f443994b
commit 6cab36e5b7
17 changed files with 212 additions and 206 deletions

View File

@@ -41,8 +41,8 @@
typedef int result_T; typedef int result_T;
typedef struct digraph { typedef struct digraph {
char_u char1; uint8_t char1;
char_u char2; uint8_t char2;
result_T result; result_T result;
} digr_T; } digr_T;
@@ -1493,7 +1493,7 @@ char *get_digraph_for_char(int val_arg)
{ {
const int val = val_arg; const int val = val_arg;
const digr_T *dp; const digr_T *dp;
static char_u r[3]; static char r[3];
for (int use_defaults = 0; use_defaults <= 1; use_defaults++) { for (int use_defaults = 0; use_defaults <= 1; use_defaults++) {
if (use_defaults == 0) { 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++) { for (int i = 0; use_defaults ? dp->char1 != NUL : i < user_digraphs.ga_len; i++) {
if (dp->result == val) { if (dp->result == val) {
r[0] = dp->char1; r[0] = (char)dp->char1;
r[1] = dp->char2; r[1] = (char)dp->char2;
r[2] = NUL; r[2] = NUL;
return (char *)r; return r;
} }
dp++; dp++;
} }
@@ -1645,8 +1645,8 @@ static void registerdigraph(int char1, int char2, int n)
// Add a new digraph to the table. // Add a new digraph to the table.
dp = GA_APPEND_VIA_PTR(digr_T, &user_digraphs); dp = GA_APPEND_VIA_PTR(digr_T, &user_digraphs);
dp->char1 = (char_u)char1; dp->char1 = (uint8_t)char1;
dp->char2 = (char_u)char2; dp->char2 = (uint8_t)char2;
dp->result = n; dp->result = n;
} }

View File

@@ -2780,7 +2780,7 @@ static bool echeck_abbr(int c)
// that the NL replaced. The extra one stores the characters after the cursor // that the NL replaced. The extra one stores the characters after the cursor
// that were deleted (always white space). // 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_nr = 0; // next entry in replace stack
static ssize_t replace_stack_len = 0; // max. number of entries 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_len += 50;
replace_stack = xrealloc(replace_stack, (size_t)replace_stack_len); 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) { if (replace_offset) {
memmove(p + 1, p, (size_t)replace_offset); memmove(p + 1, p, (size_t)replace_offset);
} }
*p = (char_u)c; *p = (uint8_t)c;
replace_stack_nr++; replace_stack_nr++;
} }
@@ -2868,13 +2868,13 @@ static void replace_pop_ins(void)
static void mb_replace_pop_ins(int cc) static void mb_replace_pop_ins(int cc)
{ {
int n; int n;
char_u buf[MB_MAXBYTES + 1]; uint8_t buf[MB_MAXBYTES + 1];
int i; int i;
if ((n = MB_BYTE2LEN(cc)) > 1) { if ((n = MB_BYTE2LEN(cc)) > 1) {
buf[0] = (char_u)cc; buf[0] = (uint8_t)cc;
for (i = 1; i < n; i++) { 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); ins_bytes_len((char *)buf, (size_t)n);
} else { } else {
@@ -2893,10 +2893,10 @@ static void mb_replace_pop_ins(int cc)
break; break;
} }
buf[0] = (char_u)c; buf[0] = (uint8_t)c;
assert(n > 1); assert(n > 1);
for (i = 1; i < n; i++) { 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))) { if (utf_iscomposing(utf_ptr2char((char *)buf))) {
ins_bytes_len((char *)buf, (size_t)n); 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; return true;
} }
if (keytyped == get_special_key_code((char_u *)look + 1)) { if (keytyped == get_special_key_code(look + 1)) {
return true; return true;
} }
} }

View File

@@ -1185,7 +1185,7 @@ int eval_foldexpr(char *arg, int *cp)
// the number. // the number.
char *s = tv.vval.v_string; char *s = tv.vval.v_string;
if (!ascii_isdigit(*s) && *s != '-') { if (!ascii_isdigit(*s) && *s != '-') {
*cp = (char_u)(*s++); *cp = (uint8_t)(*s++);
} }
retval = atol(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; dictitem_T *di;
if (lp->ll_tv == NULL) { if (lp->ll_tv == NULL) {
cc = (char_u)(*endp); cc = (uint8_t)(*endp);
*endp = NUL; *endp = NUL;
if (lp->ll_blob != NULL) { if (lp->ll_blob != NULL) {
if (op != NULL && *op != '=') { 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; arg = xp->xp_pattern;
if (*arg != NUL) { 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. // Repeat computing, until no '+', '-' or '.' is following.
for (;;) { for (;;) {
int op = (char_u)(**arg); int op = (uint8_t)(**arg);
if (op != '+' && op != '-' && op != '.') { if (op != '+' && op != '-' && op != '.') {
break; 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. // Repeat computing, until no '*', '/' or '%' is following.
for (;;) { for (;;) {
op = (char_u)(**arg); op = (uint8_t)(**arg);
if (op != '*' && op != '/' && op != '%') { if (op != '*' && op != '/' && op != '%') {
break; break;
} }
@@ -7441,9 +7441,9 @@ void ex_execute(exarg_T *eap)
const size_t len = strlen(argstr); const size_t len = strlen(argstr);
ga_grow(&ga, (int)len + 2); ga_grow(&ga, (int)len + 2);
if (!GA_EMPTY(&ga)) { 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) { if (eap->cmdidx != CMD_execute) {
xfree((void *)argstr); xfree((void *)argstr);
} }
@@ -7838,7 +7838,7 @@ repeat:
// ":~" - path relative to the home directory // ":~" - path relative to the home directory
// ":8" - shortname path - postponed till after // ":8" - shortname path - postponed till after
while (src[*usedlen] == ':' while (src[*usedlen] == ':'
&& ((c = (char_u)src[*usedlen + 1]) == '.' || c == '~' || c == '8')) { && ((c = (uint8_t)src[*usedlen + 1]) == '.' || c == '~' || c == '8')) {
*usedlen += 2; *usedlen += 2;
if (c == '8') { if (c == '8') {
continue; 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]) { if (zero_width == regmatch.startp[0]) {
// avoid getting stuck on a match with an empty string // avoid getting stuck on a match with an empty string
int i = utfc_ptr2len(tail); 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; ga.ga_len += i;
tail += i; tail += i;
continue; 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 // copy the text up to where the match is
int i = (int)(regmatch.startp[0] - tail); 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 // add the substituted text
(void)vim_regsub(&regmatch, sub, expr, (void)vim_regsub(&regmatch, sub, expr,
(char *)ga.ga_data + ga.ga_len + i, sublen, (char *)ga.ga_data + ga.ga_len + i, sublen,

View File

@@ -107,19 +107,19 @@ enum {
// Structure to pass arguments from buf_write() to buf_write_bytes(). // Structure to pass arguments from buf_write() to buf_write_bytes().
struct bw_info { struct bw_info {
int bw_fd; // file descriptor int bw_fd; // file descriptor
char *bw_buf; // buffer with data to be written char *bw_buf; // buffer with data to be written
int bw_len; // length of data int bw_len; // length of data
int bw_flags; // FIO_ flags int bw_flags; // FIO_ flags
char_u bw_rest[CONV_RESTLEN]; // not converted bytes uint8_t bw_rest[CONV_RESTLEN]; // not converted bytes
int bw_restlen; // nr of bytes in bw_rest[] int bw_restlen; // nr of bytes in bw_rest[]
int bw_first; // first write call int bw_first; // first write call
char *bw_conv_buf; // buffer for writing converted chars char *bw_conv_buf; // buffer for writing converted chars
size_t bw_conv_buflen; // size of bw_conv_buf size_t bw_conv_buflen; // size of bw_conv_buf
int bw_conv_error; // set for conversion error int bw_conv_error; // set for conversion error
linenr_T bw_conv_error_lnum; // first line with error or zero linenr_T bw_conv_error_lnum; // first line with error or zero
linenr_T bw_start_lnum; // line number at start of buffer linenr_T bw_start_lnum; // line number at start of buffer
iconv_t bw_iconv_fd; // descriptor for iconv() or -1 iconv_t bw_iconv_fd; // descriptor for iconv() or -1
}; };
typedef struct { typedef struct {
@@ -989,7 +989,7 @@ retry:
int ni; int ni;
long tlen = 0; long tlen = 0;
for (;;) { 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); int n = (int)strlen((char *)p);
if ((int)tlen + n + 1 > size) { if ((int)tlen + n + 1 > size) {
// Filled up to "size", append partial line. // Filled up to "size", append partial line.
@@ -1798,7 +1798,7 @@ failed:
msg_scrolled_ign = true; msg_scrolled_ign = true;
if (!read_stdin && !read_buffer) { 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 if (read_stdin || read_buffer || restart_edit != 0
@@ -1859,7 +1859,7 @@ failed:
// When opening a new file locate undo info and read it. // When opening a new file locate undo info and read it.
if (read_undo_file) { if (read_undo_file) {
char_u hash[UNDO_HASH_SIZE]; uint8_t hash[UNDO_HASH_SIZE];
sha256_finish(&sha_ctx, hash); sha256_finish(&sha_ctx, hash);
u_read_undo(NULL, hash, fname); u_read_undo(NULL, hash, fname);
@@ -3208,7 +3208,7 @@ restore_backup:
// Skip the BOM when appending and the file already existed, the BOM // Skip the BOM when appending and the file already existed, the BOM
// only makes sense at the start of the file. // only makes sense at the start of the file.
if (buf->b_p_bomb && !write_bin && (!append || perm < 0)) { 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) { if (write_info.bw_len > 0) {
// don't convert // don't convert
write_info.bw_flags = FIO_NOCONVERT | wb_flags; 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 /// @param flags FIO_ flags that specify which encoding to use
/// ///
/// @return true for an error, false when it's OK. /// @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; bool error = false;
if (flags & FIO_UCS4) { 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". /// Generate a BOM in "buf[4]" for encoding "name".
/// ///
/// @return the length of the BOM (zero when no BOM). /// @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); int flags = get_fio_flags(name);
// Can't put a BOM in a non-Unicode file. // 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; char *p = (char *)buf;
(void)ucs2bytes(0xfeff, &p, flags); (void)ucs2bytes(0xfeff, &p, flags);
return (int)((char_u *)p - buf); return (int)((uint8_t *)p - buf);
} }
/// Shorten filename of a buffer. /// Shorten filename of a buffer.
@@ -4953,7 +4955,7 @@ int buf_check_timestamp(buf_T *buf)
// Reload the buffer. // Reload the buffer.
buf_reload(buf, orig_mode, reload == RELOAD_DETECT); buf_reload(buf, orig_mode, reload == RELOAD_DETECT);
if (buf->b_p_udf && buf->b_ffname != NULL) { 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. // Any existing undo file is unusable, write it now.
u_compute_hash(buf, hash); u_compute_hash(buf, hash);

View File

@@ -50,7 +50,7 @@ struct ScreenGrid {
schar_T *chars; schar_T *chars;
sattr_T *attrs; sattr_T *attrs;
size_t *line_offset; size_t *line_offset;
char_u *line_wraps; char *line_wraps;
// last column that was drawn (not cleared with the default background). // last column that was drawn (not cleared with the default background).
// only used when "throttled" is set. Not allocated by grid_alloc! // only used when "throttled" is set. Not allocated by grid_alloc!

View File

@@ -1022,7 +1022,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
*p2 = NUL; *p2 = NUL;
vim_snprintf(NameBuff, MAXPATHL, vim_snprintf(NameBuff, MAXPATHL,
_("E154: Duplicate tag \"%s\" in file %s/%s"), _("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); emsg(NameBuff);
*p2 = '\t'; *p2 = '\t';
break; break;

View File

@@ -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] == '>') { if (modifiers != 0 && last_dash[l + 1] == '>') {
key = utf_ptr2char(last_dash + off); key = utf_ptr2char(last_dash + off);
} else { } 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)) { if (!(flags & FSK_KEEP_X_KEY)) {
key = handle_x_keys(key); key = handle_x_keys(key);
} }
@@ -822,18 +822,18 @@ int find_special_key_in_table(int c)
/// a termcap name. /// a termcap name.
/// ///
/// @return Key code or 0 if not found. /// @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 FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
for (int i = 0; key_names_table[i].name != NULL; i++) { for (int i = 0; key_names_table[i].name != NULL; i++) {
const char *const table_name = key_names_table[i].name; const char *const table_name = key_names_table[i].name;
int j; int j;
for (j = 0; ascii_isident(name[j]) && table_name[j] != NUL; j++) { for (j = 0; ascii_isident((uint8_t)name[j]) && table_name[j] != NUL; j++) {
if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) { if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC((uint8_t)name[j])) {
break; 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; return key_names_table[i].key;
} }
} }

View File

@@ -1162,8 +1162,9 @@ static bool expand_buffer = false;
/// @param cpo_flags Value of various flags present in &cpo /// @param cpo_flags Value of various flags present in &cpo
/// ///
/// @return NULL when there is a problem. /// @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; garray_T ga;
ga_init(&ga, 1, 40); ga_init(&ga, 1, 40);
@@ -1346,7 +1347,7 @@ int ExpandMappings(char *pat, regmatch_T *regmatch, int *numMatches, char ***mat
continue; 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) { if (p == NULL) {
continue; continue;
} }

View File

@@ -1930,16 +1930,16 @@ theend:
/// @return true if string "s" is a valid utf-8 string. /// @return true if string "s" is a valid utf-8 string.
/// When "end" is NULL stop at the first NUL. Otherwise stop at "end". /// 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]; int l = utf8len_tab_zero[*p];
if (l == 0) { if (l == 0) {
return false; // invalid lead byte return false; // invalid lead byte
} }
if (end != NULL && p + l > end) { if (end != NULL && p + l > (uint8_t *)end) {
return false; // incomplete byte sequence return false; // incomplete byte sequence
} }
p++; 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. // 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 *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, size_t *unconvlenp)
{ {
char_u *retval = NULL; uint8_t *retval = NULL;
char_u *d; uint8_t *d;
int c; int c;
size_t len; 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++) { for (size_t i = 0; i < len; i++) {
c = (uint8_t)ptr[i]; c = (uint8_t)ptr[i];
if (c < 0x80) { if (c < 0x80) {
*d++ = (char_u)c; *d++ = (uint8_t)c;
} else { } else {
*d++ = (char_u)(0xc0 + (char_u)((unsigned)c >> 6)); *d++ = (uint8_t)(0xc0 + (uint8_t)((unsigned)c >> 6));
*d++ = (char_u)(0x80 + (c & 0x3f)); *d++ = (uint8_t)(0x80 + (c & 0x3f));
} }
} }
*d = NUL; *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 (!utf_iscomposing(c)) { // skip composing chars
if (c < 0x100) { if (c < 0x100) {
*d++ = (char_u)c; *d++ = (uint8_t)c;
} else if (vcp->vc_fail) { } else if (vcp->vc_fail) {
xfree(retval); xfree(retval);
return NULL; return NULL;
@@ -2594,7 +2594,7 @@ char *string_convert_ext(const vimconv_T *const vcp, char *ptr, size_t *lenp, si
break; break;
case CONV_ICONV: // conversion with vcp->vc_fd 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; break;
} }

View File

@@ -179,19 +179,19 @@ enum {
// different machines. b0_magic_* is used to check the byte order and size of // 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. // variables, because the rest of the swap file is not portable.
struct block0 { 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 b0_version[10]; // Vim version string
char_u b0_page_size[4]; // number of bytes per page char b0_page_size[4]; // number of bytes per page
char_u b0_mtime[4]; // last modification time of file char b0_mtime[4]; // last modification time of file
char_u b0_ino[4]; // inode of b0_fname char b0_ino[4]; // inode of b0_fname
char_u b0_pid[4]; // process id of creator (or 0) 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_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_hname[B0_HNAME_SIZE]; // host name (if it has a name)
char b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited char b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited
long b0_magic_long; // check for byte order of long long b0_magic_long; // check for byte order of long
int b0_magic_int; // check for byte order of int int b0_magic_int; // check for byte order of int
int16_t b0_magic_short; // check for byte order of short 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 // 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. /// Move a long integer into a four byte character array.
/// Used for machine independency in block zero. /// 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; n = (unsigned)n >> 8;
s[1] = (char_u)(n & 0xff); s[1] = (uint8_t)(n & 0xff);
n = (unsigned)n >> 8; n = (unsigned)n >> 8;
s[2] = (char_u)(n & 0xff); s[2] = (uint8_t)(n & 0xff);
n = (unsigned)n >> 8; 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; long retval;
retval = s[3]; retval = s[3];

View File

@@ -1186,7 +1186,7 @@ int do_execreg(int regname, int colon, int addcr, int silent)
/// used only after other typeahead has been processed. /// used only after other typeahead has been processed.
static void put_reedit_in_typebuf(int silent) static void put_reedit_in_typebuf(int silent)
{ {
char_u buf[3]; uint8_t buf[3];
if (restart_edit == NUL) { if (restart_edit == NUL) {
return; return;
@@ -1197,7 +1197,7 @@ static void put_reedit_in_typebuf(int silent)
buf[1] = 'R'; buf[1] = 'R';
buf[2] = NUL; buf[2] = NUL;
} else { } else {
buf[0] = (char_u)(restart_edit == 'I' ? 'i' : restart_edit); buf[0] = (uint8_t)(restart_edit == 'I' ? 'i' : restart_edit);
buf[1] = NUL; buf[1] = NUL;
} }
if (ins_typebuf((char *)buf, REMAP_NONE, 0, true, silent) == OK) { if (ins_typebuf((char *)buf, REMAP_NONE, 0, true, silent) == OK) {

View File

@@ -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 // Handle some special cases with string option values
static void munge_string_opt_val(char **varp, char **oldval, char **const origval, 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 origval_l, char **const origval_g, char **const argp,
char **const argp, char *const whichwrap, size_t whichwraplen, char *const whichwrap, size_t whichwraplen, char **const save_argp)
char **const save_argp)
{ {
// Set 'keywordprg' to ":help" if an empty // Set 'keywordprg' to ":help" if an empty
// value was passed to :set by the user. // 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) { if (*origval == *oldval) {
*origval = *varp; *origval = *varp;
} }
if (*origval_l == (char_u *)(*oldval)) { if (*origval_l == *oldval) {
*origval_l = *(char_u **)varp; *origval_l = *varp;
} }
if (*origval_g == (char_u *)(*oldval)) { if (*origval_g == *oldval) {
*origval_g = *(char_u **)varp; *origval_g = *varp;
} }
*oldval = *varp; *oldval = *varp;
} else if (varp == &p_ww && ascii_isdigit(**argp)) { } 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 *varp = varp_arg;
char *save_arg = NULL; char *save_arg = NULL;
char *s = NULL; char *s = NULL;
char_u *origval_l = NULL; char *origval_l = NULL;
char_u *origval_g = NULL; char *origval_g = NULL;
char whichwrap[80]; char whichwrap[80];
// When using ":set opt=val" for a global option // 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; char *oldval = *(char **)varp;
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) { if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) {
origval_l = *(char_u **)get_varp_scope(&(options[opt_idx]), OPT_LOCAL); origval_l = *(char **)get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
origval_g = *(char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); origval_g = *(char **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
// A global-local string option might have an empty option as value to // A global-local string option might have an empty option as value to
// indicate that the global value should be used. // 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; 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. // origval may be freed by did_set_string_option(), make a copy.
char *saved_origval = (origval != NULL) ? xstrdup(origval) : NULL; char *saved_origval = (origval != NULL) ? xstrdup(origval) : NULL;
char *saved_origval_l = (origval_l != NULL) ? xstrdup((char *)origval_l) : NULL; char *saved_origval_l = (origval_l != NULL) ? xstrdup(origval_l) : NULL;
char *saved_origval_g = (origval_g != NULL) ? xstrdup((char *)origval_g) : NULL; char *saved_origval_g = (origval_g != NULL) ? xstrdup(origval_g) : NULL;
// newval (and varp) may become invalid if the buffer is closed by // newval (and varp) may become invalid if the buffer is closed by
// autocommands. // autocommands.
@@ -4672,7 +4671,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
return; return;
} }
} }
int key = get_special_key_code((char_u *)arg + 1); int key = get_special_key_code(arg + 1);
if (key == 0) { // unknown name if (key == 0) { // unknown name
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
return; return;

View File

@@ -98,11 +98,11 @@ typedef struct {
bool re_in_use; bool re_in_use;
int regstart; int regstart;
char_u reganch; uint8_t reganch;
char_u *regmust; uint8_t *regmust;
int regmlen; int regmlen;
char_u reghasz; uint8_t reghasz;
char_u program[]; uint8_t program[];
} bt_regprog_T; } bt_regprog_T;
// Structure representing a NFA state. // Structure representing a NFA state.
@@ -130,7 +130,7 @@ typedef struct {
int reganch; // pattern starts with ^ int reganch; // pattern starts with ^
int regstart; // char at start of pattern 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_zend; // pattern contains \ze
int has_backref; // pattern contains \1 .. \9 int has_backref; // pattern contains \1 .. \9
@@ -158,19 +158,19 @@ typedef struct {
// from 1 to zero the matches need to be freed. // from 1 to zero the matches need to be freed.
struct reg_extmatch { struct reg_extmatch {
int16_t refcnt; int16_t refcnt;
char_u *matches[NSUBEXP]; uint8_t *matches[NSUBEXP];
}; };
struct regengine { struct regengine {
/// bt_regcomp or nfa_regcomp /// bt_regcomp or nfa_regcomp
regprog_T *(*regcomp)(char_u *, int); regprog_T *(*regcomp)(uint8_t *, int);
/// bt_regfree or nfa_regfree /// bt_regfree or nfa_regfree
void (*regfree)(regprog_T *); void (*regfree)(regprog_T *);
/// bt_regexec_nl or nfa_regexec_nl /// 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 /// bt_regexec_mult or nfa_regexec_mult
long (*regexec_multi)(regmmatch_T *, win_T *, buf_T *, linenr_T, colnr_T, proftime_T *, int *); 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() // Flags used by vim_regsub() and vim_regsub_both()

View File

@@ -737,7 +737,7 @@ static void find_word(matchinf_T *mip, int mode)
// If the word ends the sequence of compound flags of the // If the word ends the sequence of compound flags of the
// words must match with one of the COMPOUNDRULE items and // words must match with one of the COMPOUNDRULE items and
// the number of syllables must not be too large. // 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; mip->mi_compflags[mip->mi_complen + 1] = NUL;
if (word_ends) { if (word_ends) {
char fword[MAXWLEN] = { 0 }; char fword[MAXWLEN] = { 0 };
@@ -2354,8 +2354,8 @@ void clear_spell_chartab(spelltab_T *sp)
CLEAR_FIELD(sp->st_isu); CLEAR_FIELD(sp->st_isu);
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
sp->st_fold[i] = (char_u)i; sp->st_fold[i] = (uint8_t)i;
sp->st_upper[i] = (char_u)i; sp->st_upper[i] = (uint8_t)i;
} }
// We include digits. A word shouldn't start with a digit, but handling // 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++) { for (int i = 'A'; i <= 'Z'; i++) {
sp->st_isw[i] = true; sp->st_isw[i] = true;
sp->st_isu[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++) { for (int i = 'a'; i <= 'z'; i++) {
sp->st_isw[i] = true; 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 // The folded/upper-cased value is different between latin1 and
// utf8 for 0xb5, causing E763 for no good reason. Use the latin1 // utf8 for 0xb5, causing E763 for no good reason. Use the latin1
// value for utf-8 to avoid this. // value for utf-8 to avoid this.
spelltab.st_fold[i] = (f < 256) ? (char_u)f : (char_u)i; spelltab.st_fold[i] = (f < 256) ? (uint8_t)f : (uint8_t)i;
spelltab.st_upper[i] = (u < 256) ? (char_u)u : (char_u)i; spelltab.st_upper[i] = (u < 256) ? (uint8_t)u : (uint8_t)i;
} }
} }

View File

@@ -206,8 +206,8 @@ typedef struct langp_S {
typedef struct { typedef struct {
bool st_isw[256]; // flags: is word char bool st_isw[256]; // flags: is word char
bool st_isu[256]; // flags: is uppercase char bool st_isu[256]; // flags: is uppercase char
char_u st_fold[256]; // chars: folded case uint8_t st_fold[256]; // chars: folded case
char_u st_upper[256]; // chars: upper case uint8_t st_upper[256]; // chars: upper case
} spelltab_T; } spelltab_T;
// Use our own character-case definitions, because the current locale may // Use our own character-case definitions, because the current locale may

View File

@@ -1079,7 +1079,7 @@ static int read_charflags_section(FILE *fd)
// Set the word-char flags and fill SPELL_ISUPPER() table. // Set the word-char flags and fill SPELL_ISUPPER() table.
if (flags != NULL && fol != NULL) { if (flags != NULL && fol != NULL) {
set_spell_charflags((char_u *)flags, flagslen, (char *)fol); set_spell_charflags(flags, flagslen, (char *)fol);
} }
xfree(flags); xfree(flags);
@@ -1314,7 +1314,7 @@ static int read_words_section(FILE *fd, slang_T *lp, int len)
int done = 0; int done = 0;
int i; int i;
int c; int c;
char_u word[MAXWLEN]; uint8_t word[MAXWLEN];
while (done < len) { while (done < len) {
// Read one word at a time. // 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) { if (c == EOF) {
return SP_TRUNCERROR; return SP_TRUNCERROR;
} }
word[i] = (char_u)c; word[i] = (uint8_t)c;
if (word[i] == NUL) { if (word[i] == NUL) {
break; break;
} }
@@ -1480,7 +1480,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
// Add all flags to "sl_compallflags". // Add all flags to "sl_compallflags".
if (vim_strchr("?*+[]/", c) == NULL if (vim_strchr("?*+[]/", c) == NULL
&& !byte_in_str(slang->sl_compallflags, c)) { && !byte_in_str(slang->sl_compallflags, c)) {
*ap++ = (char_u)c; *ap++ = (uint8_t)c;
*ap = NUL; *ap = NUL;
} }
@@ -1493,7 +1493,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
atstart = 0; atstart = 0;
} else { } else {
if (!byte_in_str(slang->sl_compstartflags, c)) { if (!byte_in_str(slang->sl_compstartflags, c)) {
*cp++ = (char_u)c; *cp++ = (uint8_t)c;
*cp = NUL; *cp = NUL;
} }
if (atstart == 1) { if (atstart == 1) {
@@ -1508,7 +1508,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
XFREE_CLEAR(slang->sl_comprules); XFREE_CLEAR(slang->sl_comprules);
crp = NULL; crp = NULL;
} else { } 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; *idxsp = ip;
// Recursively read the tree and store it in the array. // 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) { if (idx < 0) {
return idx; 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 startidx current index in "byts" and "idxs"
/// @param prefixtree true for reading PREFIXTREE /// @param prefixtree true for reading PREFIXTREE
/// @param maxprefcondnr maximum for <prefcondnr> /// @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) bool prefixtree, int maxprefcondnr)
{ {
uint8_t *byts = (uint8_t *)byts_in;
int len; int len;
int n; int n;
idx_T idx = startidx; 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) { if (startidx + len >= maxidx) {
return SP_FORMERROR; return SP_FORMERROR;
} }
byts[idx++] = (char_u)len; byts[idx++] = (uint8_t)len;
// Read the byte values, flag/region bytes and shared indexes. // Read the byte values, flag/region bytes and shared indexes.
for (int i = 1; i <= len; i++) { 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> c = getc(fd); // <xbyte>
} }
} }
byts[idx++] = (char_u)c; byts[idx++] = (uint8_t)c;
} }
// Recursively read the children for non-shared siblings. // 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; idxs[startidx + i] &= ~SHARED_MASK;
} else { } else {
idxs[startidx + i] = idx; 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); prefixtree, maxprefcondnr);
if (idx < 0) { if (idx < 0) {
break; break;
@@ -2783,11 +2784,11 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry)
if (entry->ae_flags != NULL if (entry->ae_flags != NULL
&& (affile->af_compforbid != 0 || affile->af_comppermit != 0)) { && (affile->af_compforbid != 0 || affile->af_comppermit != 0)) {
for (p = entry->ae_flags; *p != NUL;) { for (p = entry->ae_flags; *p != NUL;) {
char_u *prevp = (char_u *)p; char *prevp = p;
unsigned flag = get_affitem(affile->af_flagtype, &p); unsigned flag = get_affitem(affile->af_flagtype, &p);
if (flag == affile->af_comppermit || flag == affile->af_compforbid) { if (flag == affile->af_comppermit || flag == affile->af_compforbid) {
STRMOVE(prevp, p); STRMOVE(prevp, p);
p = (char *)prevp; p = prevp;
if (flag == affile->af_comppermit) { if (flag == affile->af_comppermit) {
entry->ae_comppermit = true; entry->ae_comppermit = true;
} else { } else {
@@ -2894,12 +2895,12 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags
STRCAT(p, "/"); STRCAT(p, "/");
} }
spin->si_compflags = 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;) { for (p = compflags; *p != NUL;) {
if (vim_strchr("/?*+[]", (uint8_t)(*p)) != NULL) { if (vim_strchr("/?*+[]", (uint8_t)(*p)) != NULL) {
// Copy non-flag characters directly. // Copy non-flag characters directly.
*tp++ = (char_u)(*p++); *tp++ = (uint8_t)(*p++);
} else { } else {
// First get the flag number, also checks validity. // First get the flag number, also checks validity.
prevp = p; prevp = p;
@@ -3640,7 +3641,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
char rline[MAXLINELEN]; char rline[MAXLINELEN];
char *line; char *line;
char *pc = NULL; char *pc = NULL;
char_u *p; char *p;
int l; int l;
int retval = OK; int retval = OK;
bool did_word = false; bool did_word = false;
@@ -3748,7 +3749,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
regionmask = spin->si_region; regionmask = spin->si_region;
// Check for flags and region after a slash. // Check for flags and region after a slash.
p = (char_u *)vim_strchr(line, '/'); p = vim_strchr(line, '/');
if (p != NULL) { if (p != NULL) {
*p++ = NUL; *p++ = NUL;
while (*p != NUL) { while (*p != NUL) {
@@ -3758,13 +3759,13 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
flags |= WF_BANNED; flags |= WF_BANNED;
} else if (*p == '?') { // Rare word. } else if (*p == '?') { // Rare word.
flags |= WF_RARE; 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 if ((flags & WF_REGION) == 0) { // first one
regionmask = 0; regionmask = 0;
} }
flags |= WF_REGION; flags |= WF_REGION;
l = *p - '0'; l = (uint8_t)(*p) - '0';
if (l == 0 || l > spin->si_region_count) { if (l == 0 || l > spin->si_region_count) {
smsg(_("Invalid region nr in %s line %ld: %s"), smsg(_("Invalid region nr in %s line %ld: %s"),
fname, lnum, p); 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) static void *getroom(spellinfo_T *spin, size_t len, bool align)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_RET
{ {
char_u *p; char *p;
sblock_T *bl = spin->si_blocks; sblock_T *bl = spin->si_blocks;
assert(len <= SBLOCKSIZE); assert(len <= SBLOCKSIZE);
@@ -3837,7 +3838,7 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align)
spin->si_blocks_cnt++; spin->si_blocks_cnt++;
} }
p = bl->sb_data + bl->sb_used; p = (char *)bl->sb_data + bl->sb_used;
bl->sb_used += (int)len; bl->sb_used += (int)len;
return p; return p;
@@ -3876,7 +3877,7 @@ static wordnode_T *wordtree_alloc(spellinfo_T *spin)
/// Control characters and trailing '/' are invalid. Space is OK. /// Control characters and trailing '/' are invalid. Space is OK.
static bool valid_spell_word(const char *word, const char *end) 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; return false;
} }
for (const char *p = word; *p != NUL && p < end; p += utfc_ptr2len(p)) { 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); (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)) { if (!need_affix || (p != NULL && *p != NUL)) {
res = tree_add_word(spin, (char_u *)foldword, spin->si_foldroot, ct | flags, res = tree_add_word(spin, (char_u *)foldword, spin->si_foldroot, ct | flags,
region, p == NULL ? 0 : *p); 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++; spin->si_foldwcount++;
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) { 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)) { if (!need_affix || (p != NULL && *p != NUL)) {
res = tree_add_word(spin, (char_u *)word, spin->si_keeproot, flags, res = tree_add_word(spin, (char_u *)word, spin->si_keeproot, flags,
region, p == NULL ? 0 : *p); 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. /// Set the spell character tables from strings in the .spl file.
/// ///
/// @param cnt length of "flags" /// @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 // We build the new tables here first, so that we can compare with the
// previous one. // previous one.
spelltab_T new_st; spelltab_T new_st;
@@ -5745,9 +5747,9 @@ static void set_spell_charflags(const char_u *flags, int cnt, char *fol)
if (*p != NUL) { if (*p != NUL) {
c = mb_ptr2char_adv((const char **)&p); 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) { 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);
} }
} }
} }

View File

@@ -189,28 +189,28 @@ typedef enum {
/// Struct to keep the state at each level in suggest_try_change(). /// Struct to keep the state at each level in suggest_try_change().
typedef struct trystate_S { typedef struct trystate_S {
state_T ts_state; ///< state at this level, STATE_ state_T ts_state; ///< state at this level, STATE_
int ts_score; ///< score int ts_score; ///< score
idx_T ts_arridx; ///< index in tree array, start of node idx_T ts_arridx; ///< index in tree array, start of node
int16_t ts_curi; ///< index in list of child nodes int16_t ts_curi; ///< index in list of child nodes
char_u ts_fidx; ///< index in fword[], case-folded bad word uint8_t ts_fidx; ///< index in fword[], case-folded bad word
char_u ts_fidxtry; ///< ts_fidx at which bytes may be changed uint8_t ts_fidxtry; ///< ts_fidx at which bytes may be changed
char_u ts_twordlen; ///< valid length of tword[] uint8_t ts_twordlen; ///< valid length of tword[]
char_u ts_prefixdepth; ///< stack depth for end of prefix or uint8_t ts_prefixdepth; ///< stack depth for end of prefix or
///< PFD_PREFIXTREE or PFD_NOPREFIX ///< PFD_PREFIXTREE or PFD_NOPREFIX
char_u ts_flags; ///< TSF_ flags uint8_t ts_flags; ///< TSF_ flags
char_u ts_tcharlen; ///< number of bytes in tword character uint8_t ts_tcharlen; ///< number of bytes in tword character
char_u ts_tcharidx; ///< current byte index in tword character uint8_t ts_tcharidx; ///< current byte index in tword character
char_u ts_isdiff; ///< DIFF_ values uint8_t ts_isdiff; ///< DIFF_ values
char_u ts_fcharstart; ///< index in fword where badword char started uint8_t ts_fcharstart; ///< index in fword where badword char started
char_u ts_prewordlen; ///< length of word in "preword[]" uint8_t ts_prewordlen; ///< length of word in "preword[]"
char_u ts_splitoff; ///< index in "tword" after last split uint8_t ts_splitoff; ///< index in "tword" after last split
char_u ts_splitfidx; ///< "ts_fidx" at word split uint8_t ts_splitfidx; ///< "ts_fidx" at word split
char_u ts_complen; ///< nr of compound words used uint8_t ts_complen; ///< nr of compound words used
char_u ts_compsplit; ///< index for "compflags" where word was spit uint8_t ts_compsplit; ///< index for "compflags" where word was spit
char_u ts_save_badflags; ///< su_badflags saved here uint8_t ts_save_badflags; ///< su_badflags saved here
char_u ts_delidx; ///< index in fword for char that was deleted, uint8_t ts_delidx; ///< index in fword for char that was deleted,
///< valid when "ts_flags" has TSF_DIDDEL ///< valid when "ts_flags" has TSF_DIDDEL
} trystate_T; } trystate_T;
// values for ts_isdiff // 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 /// Returns true when the sequence of flags in "compflags" plus "flag" can
/// possibly form a valid compounded word. This also checks the COMPOUNDRULE /// possibly form a valid compounded word. This also checks the COMPOUNDRULE
/// lines if they don't contain wildcards. /// 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 // If the flag doesn't appear in sl_compstartflags or sl_compallflags
// then it can't possibly compound. // 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 // possibly can form a match with COMPOUNDRULE patterns. This only
// makes sense when we have two or more words. // makes sense when we have two or more words.
if (slang->sl_comprules != NULL && sp->ts_complen > sp->ts_compsplit) { 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; compflags[sp->ts_complen + 1] = NUL;
bool v = match_compoundrule(slang, compflags + sp->ts_compsplit); bool v = match_compoundrule(slang, compflags + sp->ts_compsplit);
compflags[sp->ts_complen] = NUL; compflags[sp->ts_complen] = NUL;
@@ -349,7 +349,7 @@ static int badword_captype(char *word, char *end)
/// @return the offset. /// @return the offset.
static int bytes2offset(char **pp) static int bytes2offset(char **pp)
{ {
char_u *p = (char_u *)(*pp); uint8_t *p = (uint8_t *)(*pp);
int nr; int nr;
int c = *p++; 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 // words and split word. NUL terminated
// when going deeper but not when coming // when going deeper but not when coming
// back. // back.
char_u compflags[MAXWLEN]; // compound flags, one for each word uint8_t compflags[MAXWLEN]; // compound flags, one for each word
int newscore; int newscore;
int score; int score;
char_u *byts, *fbyts, *pbyts; uint8_t *byts, *fbyts, *pbyts;
idx_T *idxs, *fidxs, *pidxs; idx_T *idxs, *fidxs, *pidxs;
int c, c2, c3; int c, c2, c3;
int n = 0; 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; bool goodword_ends;
#ifdef DEBUG_TRIEWALK #ifdef DEBUG_TRIEWALK
// Stores the name of the change made at each level. // Stores the name of the change made at each level.
char_u changename[MAXWLEN][80]; uint8_t changename[MAXWLEN][80];
#endif #endif
int breakcheckcount = 1000; int breakcheckcount = 1000;
bool compound_ok; bool compound_ok;
@@ -1181,7 +1181,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
if (soundfold) { if (soundfold) {
// Going through the soundfold tree. // Going through the soundfold tree.
byts = fbyts = (char_u *)slang->sl_sbyts; byts = fbyts = (uint8_t *)slang->sl_sbyts;
idxs = fidxs = slang->sl_sidxs; idxs = fidxs = slang->sl_sidxs;
pbyts = NULL; pbyts = NULL;
pidxs = NULL; pidxs = NULL;
@@ -1190,9 +1190,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
} else { } else {
// When there are postponed prefixes we need to use these first. At // When there are postponed prefixes we need to use these first. At
// the end of the prefix we continue in the case-fold tree. // 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; fidxs = slang->sl_fidxs;
pbyts = (char_u *)slang->sl_pbyts; pbyts = (uint8_t *)slang->sl_pbyts;
pidxs = slang->sl_pidxs; pidxs = slang->sl_pidxs;
if (pbyts != NULL) { if (pbyts != NULL) {
byts = pbyts; 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; n = (int)sp->ts_state;
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL; 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 // At end of a prefix or at start of prefixtree: check for
// following word. // 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); go_deeper(stack, depth, 0);
depth++; depth++;
sp = &stack[depth]; sp = &stack[depth];
sp->ts_prefixdepth = (char_u)(depth - 1); sp->ts_prefixdepth = (uint8_t)(depth - 1);
byts = fbyts; byts = fbyts;
idxs = fidxs; idxs = fidxs;
sp->ts_arridx = 0; 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; tword[sp->ts_twordlen] = NUL;
make_case_word(tword + sp->ts_splitoff, make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, flags); 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; sp->ts_splitoff = sp->ts_twordlen;
} }
break; 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. // Past bytes in node and/or past NUL bytes.
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL; sp->ts_state = STATE_ENDNUL;
sp->ts_save_badflags = (char_u)su->su_badflags; sp->ts_save_badflags = (uint8_t)su->su_badflags;
break; break;
} }
@@ -1379,7 +1379,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
break; 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; compflags[sp->ts_complen + 1] = NUL;
xstrlcpy(preword + sp->ts_prewordlen, xstrlcpy(preword + sp->ts_prewordlen,
tword + sp->ts_splitoff, 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) < slang->sl_compmax)
&& (can_be_compound(sp, slang, compflags, (int)((unsigned)flags >> 24)))) { && (can_be_compound(sp, slang, compflags, (int)((unsigned)flags >> 24)))) {
try_compound = true; 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; 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 sp->ts_curi--; // do the same NUL again
compflags[sp->ts_complen] = NUL; compflags[sp->ts_complen] = NUL;
} else { } else {
sp->ts_flags &= (char_u) ~TSF_DIDSPLIT; sp->ts_flags &= (uint8_t) ~TSF_DIDSPLIT;
} }
if (try_split || try_compound) { 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 #endif
// Save things to be restored at STATE_SPLITUNDO. // 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) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SPLITUNDO; 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) { if (!try_compound && !fword_ends) {
STRCAT(preword, " "); STRCAT(preword, " ");
} }
sp->ts_prewordlen = (char_u)strlen(preword); sp->ts_prewordlen = (uint8_t)strlen(preword);
sp->ts_splitoff = sp->ts_twordlen; sp->ts_splitoff = sp->ts_twordlen;
sp->ts_splitfidx = sp->ts_fidx; 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) { if (fword_ends) {
// Copy the skipped character to preword. // Copy the skipped character to preword.
memmove(preword + sp->ts_prewordlen, fword + sp->ts_fidx, (size_t)l); 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; preword[sp->ts_prewordlen] = NUL;
} else { } else {
sp->ts_score -= SCORE_SPLIT - SCORE_SUBST; 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 // 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. // First byte.
sp->ts_tcharidx = 0; sp->ts_tcharidx = 0;
sp->ts_tcharlen = MB_BYTE2LEN(c); 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) sp->ts_isdiff = (newscore != 0)
? DIFF_YES : DIFF_NONE; ? DIFF_YES : DIFF_NONE;
} else if (sp->ts_isdiff == DIFF_INSERT && sp->ts_fidx > 0) { } 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) { if (sp->ts_isdiff == DIFF_YES) {
// Correct ts_fidx for the byte length of the // Correct ts_fidx for the byte length of the
// character (we didn't check that before). // character (we didn't check that before).
sp->ts_fidx = (char_u)(sp->ts_fcharstart sp->ts_fidx = (uint8_t)(sp->ts_fcharstart
+ utfc_ptr2len(fword + sp->ts_fcharstart)); + utfc_ptr2len(fword + sp->ts_fcharstart));
// For changing a composing character adjust // For changing a composing character adjust
// the score from SCORE_SUBST to // 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. // results.
c = utf_ptr2char(fword + sp->ts_fidx); c = utf_ptr2char(fword + sp->ts_fidx);
stack[depth].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)) { if (utf_iscomposing(c)) {
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP; stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) { } 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. // There are following bytes for the same character.
// We must find all bytes before trying // We must find all bytes before trying
// delete/insert/swap/etc. // delete/insert/swap/etc.
sp->ts_tcharlen = (char_u)fl; sp->ts_tcharlen = (uint8_t)fl;
sp->ts_tcharidx = 1; sp->ts_tcharidx = 1;
sp->ts_isdiff = DIFF_INSERT; 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); fl = utf_char2len(c2);
memmove(p, p + n, (size_t)fl); memmove(p, p + n, (size_t)fl);
utf_char2bytes(c, p + 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 { } else {
// If this swap doesn't work then SWAP3 won't either. // If this swap doesn't work then SWAP3 won't either.
PROF_STORE(sp->ts_state) 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); memmove(p, p + n + fl, (size_t)tl);
utf_char2bytes(c2, p + tl); utf_char2bytes(c2, p + tl);
utf_char2bytes(c, p + fl + 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 { } else {
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI; 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); fl += utf_ptr2len(p + n + fl);
memmove(p, p + n, (size_t)fl); memmove(p, p + n, (size_t)fl);
utf_char2bytes(c, p + 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 { } else {
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI; 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); tl = utf_ptr2len(p + n);
memmove(p + tl, p, (size_t)n); memmove(p + tl, p, (size_t)n);
utf_char2bytes(c, p); 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 { } else {
PROF_STORE(sp->ts_state) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI; 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; repextra += tl - fl;
} }
memmove(p, ftp->ft_to, (size_t)tl); 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; stack[depth].ts_tcharlen = 0;
break; break;
} }
@@ -2381,7 +2381,7 @@ static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
int c; int c;
idx_T lo, hi, m; idx_T lo, hi, m;
char *p; 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 idx_T *idxs = slang->sl_kidxs; // array with indexes
if (byts == NULL) { 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. /// handled already.
typedef struct { typedef struct {
int16_t sft_score; ///< lowest score used int16_t sft_score; ///< lowest score used
char_u sft_word[]; ///< soundfolded word uint8_t sft_word[]; ///< soundfolded word
} sftword_T; } sftword_T;
static sftword_T dumsft; 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) #define HI2SFT(hi) HIKEY2SFT((hi)->hi_key)
/// Prepare for calling suggest_try_soundalike(). /// 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]; char theword[MAXWLEN];
int i; int i;
int wlen; int wlen;
char_u *byts; uint8_t *byts;
idx_T *idxs; idx_T *idxs;
int n; int n;
int wordcount; int wordcount;
@@ -2824,7 +2824,7 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
// previous wordnr. // previous wordnr.
orgnr += bytes2offset(&nrline); orgnr += bytes2offset(&nrline);
byts = (char_u *)slang->sl_fbyts; byts = (uint8_t *)slang->sl_fbyts;
idxs = slang->sl_fidxs; idxs = slang->sl_fidxs;
// Lookup the word "orgnr" one of the two tries. // 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; idx_T arridx = 0;
int wlen = 0; int wlen = 0;
char_u *ptr = (char_u *)word; uint8_t *ptr = (uint8_t *)word;
int wordnr = 0; 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; idx_T *idxs = slang->sl_sidxs;
for (;;) { 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 // Only rescore suggestions that have no sal score yet and do have a
// language. // language.
if (slang != NULL && !GA_EMPTY(&slang->sl_sal) && !stp->st_had_bonus) { if (slang != NULL && !GA_EMPTY(&slang->sl_sal) && !stp->st_had_bonus) {
char_u *p; char *p;
if (slang == su->su_sallang) { if (slang == su->su_sallang) {
p = (char_u *)su->su_sal_badword; p = su->su_sal_badword;
} else { } else {
spell_soundfold(slang, su->su_fbadword, true, sal_badword); 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) { if (stp->st_altscore == SCORE_MAXMAX) {
stp->st_altscore = SCORE_BIG; stp->st_altscore = SCORE_BIG;
} }