refactor: replace char_u variables and functions with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
Dundar Goc
2022-05-04 18:27:22 +02:00
parent 82c7a82c35
commit 9a671e6a24
47 changed files with 569 additions and 576 deletions

View File

@@ -67,10 +67,10 @@ int encode_list_write(void *const data, const char *const buf, const size_t len)
line_end = xmemscan(buf, NL, len);
if (line_end != buf) {
const size_t line_length = (size_t)(line_end - buf);
char *str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string;
char *str = TV_LIST_ITEM_TV(li)->vval.v_string;
const size_t li_len = (str == NULL ? 0 : strlen(str));
TV_LIST_ITEM_TV(li)->vval.v_string = xrealloc(str, li_len + line_length + 1);
str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string + li_len;
str = TV_LIST_ITEM_TV(li)->vval.v_string + li_len;
memcpy(str, buf, line_length);
str[line_length] = 0;
memchrsub(str, NUL, NL, line_length);
@@ -130,9 +130,10 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
case kMPConvDict: {
typval_T key_tv = {
.v_type = VAR_STRING,
.vval = { .v_string = (v.data.d.hi == NULL
? v.data.d.dict->dv_hashtab.ht_array
: (v.data.d.hi - 1))->hi_key },
.vval = { .v_string =
(char *)(v.data.d.hi ==
NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi -
1))->hi_key },
};
char *const key = encode_tv2string(&key_tv, NULL);
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
@@ -263,7 +264,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|| TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
for (size_t i = state->offset; i < state->li_length && p < buf_end; i++) {
assert(TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
const char ch = (char)(TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++]);
const char ch = TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++];
*p++ = (char)(ch == (char)NL ? (char)NUL : ch);
}
if (p < buf_end) {
@@ -869,7 +870,7 @@ char *encode_tv2echo(typval_T *tv, size_t *len)
ga_init(&ga, (int)sizeof(char), 80);
if (tv->v_type == VAR_STRING || tv->v_type == VAR_FUNC) {
if (tv->vval.v_string != NULL) {
ga_concat(&ga, (char *)tv->vval.v_string);
ga_concat(&ga, tv->vval.v_string);
}
} else {
const int eve_ret = encode_vim_to_echo(&ga, tv, N_(":echo argument"));