mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: reduce number of unique char casts (#15995)
This commit is contained in:
parent
64f0fdc682
commit
649b3160a1
@ -1903,7 +1903,7 @@ Integer nvim_buf_add_highlight(Buffer buffer, Integer ns_id, String hl_group, In
|
||||
|
||||
int hl_id = 0;
|
||||
if (hl_group.size > 0) {
|
||||
hl_id = syn_check_group((char_u *)hl_group.data, (int)hl_group.size);
|
||||
hl_id = syn_check_group(hl_group.data, (int)hl_group.size);
|
||||
} else {
|
||||
return ns_id;
|
||||
}
|
||||
|
@ -1559,7 +1559,7 @@ int object_to_hl_id(Object obj, const char *what, Error *err)
|
||||
{
|
||||
if (obj.type == kObjectTypeString) {
|
||||
String str = obj.data.string;
|
||||
return str.size ? syn_check_group((char_u *)str.data, (int)str.size) : 0;
|
||||
return str.size ? syn_check_group(str.data, (int)str.size) : 0;
|
||||
} else if (obj.type == kObjectTypeInteger) {
|
||||
return MAX((int)obj.data.integer, 0);
|
||||
} else {
|
||||
@ -1593,7 +1593,7 @@ HlMessage parse_hl_msg(Array chunks, Error *err)
|
||||
String hl = chunk.items[1].data.string;
|
||||
if (hl.size > 0) {
|
||||
// TODO(bfredl): use object_to_hl_id and allow integer
|
||||
int hl_id = syn_check_group((char_u *)hl.data, (int)hl.size);
|
||||
int hl_id = syn_check_group(hl.data, (int)hl.size);
|
||||
attr = hl_id > 0 ? syn_id2attr(hl_id) : 0;
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err)
|
||||
Integer nvim_get_hl_id_by_name(String name)
|
||||
FUNC_API_SINCE(7)
|
||||
{
|
||||
return syn_check_group((const char_u *)name.data, (int)name.size);
|
||||
return syn_check_group(name.data, (int)name.size);
|
||||
}
|
||||
|
||||
Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
|
||||
@ -227,7 +227,7 @@ Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
|
||||
void nvim_set_hl(Integer ns_id, String name, Dictionary val, Error *err)
|
||||
FUNC_API_SINCE(7)
|
||||
{
|
||||
int hl_id = syn_check_group( (char_u *)(name.data), (int)name.size);
|
||||
int hl_id = syn_check_group(name.data, (int)name.size);
|
||||
int link_id = -1;
|
||||
|
||||
HlAttrs attrs = dict2hlattrs(val, true, &link_id, err);
|
||||
|
@ -2711,21 +2711,21 @@ void buflist_list(exarg_T *eap)
|
||||
const bool job_running = buf->terminal && terminal_running(buf->terminal);
|
||||
|
||||
// skip unspecified buffers
|
||||
if ((!buf->b_p_bl && !eap->forceit && !strchr((char *)eap->arg, 'u'))
|
||||
|| (strchr((char *)eap->arg, 'u') && buf->b_p_bl)
|
||||
|| (strchr((char *)eap->arg, '+')
|
||||
if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u'))
|
||||
|| (vim_strchr(eap->arg, 'u') && buf->b_p_bl)
|
||||
|| (vim_strchr(eap->arg, '+')
|
||||
&& ((buf->b_flags & BF_READERR) || !bufIsChanged(buf)))
|
||||
|| (strchr((char *)eap->arg, 'a')
|
||||
|| (vim_strchr(eap->arg, 'a')
|
||||
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0))
|
||||
|| (strchr((char *)eap->arg, 'h')
|
||||
|| (vim_strchr(eap->arg, 'h')
|
||||
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0))
|
||||
|| (strchr((char *)eap->arg, 'R') && (!is_terminal || !job_running))
|
||||
|| (strchr((char *)eap->arg, 'F') && (!is_terminal || job_running))
|
||||
|| (strchr((char *)eap->arg, '-') && buf->b_p_ma)
|
||||
|| (strchr((char *)eap->arg, '=') && !buf->b_p_ro)
|
||||
|| (strchr((char *)eap->arg, 'x') && !(buf->b_flags & BF_READERR))
|
||||
|| (strchr((char *)eap->arg, '%') && buf != curbuf)
|
||||
|| (strchr((char *)eap->arg, '#')
|
||||
|| (vim_strchr(eap->arg, 'R') && (!is_terminal || !job_running))
|
||||
|| (vim_strchr(eap->arg, 'F') && (!is_terminal || job_running))
|
||||
|| (vim_strchr(eap->arg, '-') && buf->b_p_ma)
|
||||
|| (vim_strchr(eap->arg, '=') && !buf->b_p_ro)
|
||||
|| (vim_strchr(eap->arg, 'x') && !(buf->b_flags & BF_READERR))
|
||||
|| (vim_strchr(eap->arg, '%') && buf != curbuf)
|
||||
|| (vim_strchr(eap->arg, '#')
|
||||
&& (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) {
|
||||
continue;
|
||||
}
|
||||
|
@ -230,12 +230,11 @@ char_u *parse_shape_opt(int what)
|
||||
slashp = vim_strchr(p, '/');
|
||||
if (slashp != NULL && slashp < endp) {
|
||||
// "group/langmap_group"
|
||||
i = syn_check_group(p, (int)(slashp - p));
|
||||
i = syn_check_group((char *)p, (int)(slashp - p));
|
||||
p = slashp + 1;
|
||||
}
|
||||
if (round == 2) {
|
||||
shape_table[idx].id = syn_check_group(p,
|
||||
(int)(endp - p));
|
||||
shape_table[idx].id = syn_check_group((char *)p, (int)(endp - p));
|
||||
shape_table[idx].id_lm = shape_table[idx].id;
|
||||
if (slashp != NULL && slashp < endp) {
|
||||
shape_table[idx].id = i;
|
||||
|
@ -390,7 +390,7 @@ static char_u *debug_skipped_name;
|
||||
/// Called from do_one_cmd() before executing a command.
|
||||
void dbg_check_breakpoint(exarg_T *eap)
|
||||
{
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
debug_skipped = false;
|
||||
if (debug_breakpoint_name != NULL) {
|
||||
@ -399,9 +399,9 @@ void dbg_check_breakpoint(exarg_T *eap)
|
||||
if (debug_breakpoint_name[0] == K_SPECIAL
|
||||
&& debug_breakpoint_name[1] == KS_EXTRA
|
||||
&& debug_breakpoint_name[2] == KE_SNR) {
|
||||
p = (char_u *)"<SNR>";
|
||||
p = "<SNR>";
|
||||
} else {
|
||||
p = (char_u *)"";
|
||||
p = "";
|
||||
}
|
||||
smsg(_("Breakpoint in \"%s%s\" line %" PRId64),
|
||||
p,
|
||||
|
@ -5123,7 +5123,7 @@ static int ins_complete(int c, bool enable_pum)
|
||||
))) {
|
||||
prefix = (char_u *)"";
|
||||
}
|
||||
STRCPY((char *)compl_pattern, prefix);
|
||||
STRCPY(compl_pattern, prefix);
|
||||
(void)quote_meta(compl_pattern + STRLEN(prefix),
|
||||
line + compl_col, compl_length);
|
||||
} else if (--startcol < 0
|
||||
@ -5152,13 +5152,13 @@ static int ins_complete(int c, bool enable_pum)
|
||||
* xmalloc(7) is enough -- Acevedo
|
||||
*/
|
||||
compl_pattern = xmalloc(7);
|
||||
STRCPY((char *)compl_pattern, "\\<");
|
||||
STRCPY(compl_pattern, "\\<");
|
||||
(void)quote_meta(compl_pattern + 2, line + compl_col, 1);
|
||||
STRCAT((char *)compl_pattern, "\\k");
|
||||
STRCAT(compl_pattern, "\\k");
|
||||
} else {
|
||||
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col,
|
||||
compl_length) + 2);
|
||||
STRCPY((char *)compl_pattern, "\\<");
|
||||
STRCPY(compl_pattern, "\\<");
|
||||
(void)quote_meta(compl_pattern + 2, line + compl_col,
|
||||
compl_length);
|
||||
}
|
||||
|
@ -5899,17 +5899,17 @@ void prepare_assert_error(garray_T *gap)
|
||||
|
||||
ga_init(gap, 1, 100);
|
||||
if (sourcing_name != NULL) {
|
||||
ga_concat(gap, sourcing_name);
|
||||
ga_concat(gap, (char *)sourcing_name);
|
||||
if (sourcing_lnum > 0) {
|
||||
ga_concat(gap, (char_u *)" ");
|
||||
ga_concat(gap, " ");
|
||||
}
|
||||
}
|
||||
if (sourcing_lnum > 0) {
|
||||
vim_snprintf(buf, ARRAY_SIZE(buf), "line %" PRId64, (int64_t)sourcing_lnum);
|
||||
ga_concat(gap, (char_u *)buf);
|
||||
ga_concat(gap, buf);
|
||||
}
|
||||
if (sourcing_name != NULL || sourcing_lnum > 0) {
|
||||
ga_concat(gap, (char_u *)": ");
|
||||
ga_concat(gap, ": ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -5923,27 +5923,27 @@ static void ga_concat_esc(garray_T *gap, const char_u *p, int clen)
|
||||
if (clen > 1) {
|
||||
memmove(buf, p, clen);
|
||||
buf[clen] = NUL;
|
||||
ga_concat(gap, buf);
|
||||
ga_concat(gap, (char *)buf);
|
||||
} else {
|
||||
switch (*p) {
|
||||
case BS:
|
||||
ga_concat(gap, (char_u *)"\\b"); break;
|
||||
ga_concat(gap, "\\b"); break;
|
||||
case ESC:
|
||||
ga_concat(gap, (char_u *)"\\e"); break;
|
||||
ga_concat(gap, "\\e"); break;
|
||||
case FF:
|
||||
ga_concat(gap, (char_u *)"\\f"); break;
|
||||
ga_concat(gap, "\\f"); break;
|
||||
case NL:
|
||||
ga_concat(gap, (char_u *)"\\n"); break;
|
||||
ga_concat(gap, "\\n"); break;
|
||||
case TAB:
|
||||
ga_concat(gap, (char_u *)"\\t"); break;
|
||||
ga_concat(gap, "\\t"); break;
|
||||
case CAR:
|
||||
ga_concat(gap, (char_u *)"\\r"); break;
|
||||
ga_concat(gap, "\\r"); break;
|
||||
case '\\':
|
||||
ga_concat(gap, (char_u *)"\\\\"); break;
|
||||
ga_concat(gap, "\\\\"); break;
|
||||
default:
|
||||
if (*p < ' ') {
|
||||
vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p);
|
||||
ga_concat(gap, buf);
|
||||
ga_concat(gap, (char *)buf);
|
||||
} else {
|
||||
ga_append(gap, *p);
|
||||
}
|
||||
@ -5960,7 +5960,7 @@ static void ga_concat_shorten_esc(garray_T *gap, const char_u *str)
|
||||
char_u buf[NUMBUFLEN];
|
||||
|
||||
if (str == NULL) {
|
||||
ga_concat(gap, (char_u *)"NULL");
|
||||
ga_concat(gap, "NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5974,12 +5974,12 @@ static void ga_concat_shorten_esc(garray_T *gap, const char_u *str)
|
||||
s += clen;
|
||||
}
|
||||
if (same_len > 20) {
|
||||
ga_concat(gap, (char_u *)"\\[");
|
||||
ga_concat(gap, "\\[");
|
||||
ga_concat_esc(gap, p, clen);
|
||||
ga_concat(gap, (char_u *)" occurs ");
|
||||
ga_concat(gap, " occurs ");
|
||||
vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
|
||||
ga_concat(gap, buf);
|
||||
ga_concat(gap, (char_u *)" times]");
|
||||
ga_concat(gap, (char *)buf);
|
||||
ga_concat(gap, " times]");
|
||||
p = s - 1;
|
||||
} else {
|
||||
ga_concat_esc(gap, p, clen);
|
||||
@ -5995,17 +5995,17 @@ void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typ
|
||||
|
||||
if (opt_msg_tv->v_type != VAR_UNKNOWN) {
|
||||
tofree = (char_u *)encode_tv2echo(opt_msg_tv, NULL);
|
||||
ga_concat(gap, tofree);
|
||||
ga_concat(gap, (char *)tofree);
|
||||
xfree(tofree);
|
||||
ga_concat(gap, (char_u *)": ");
|
||||
ga_concat(gap, ": ");
|
||||
}
|
||||
|
||||
if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) {
|
||||
ga_concat(gap, (char_u *)"Pattern ");
|
||||
ga_concat(gap, "Pattern ");
|
||||
} else if (atype == ASSERT_NOTEQUAL) {
|
||||
ga_concat(gap, (char_u *)"Expected not equal to ");
|
||||
ga_concat(gap, "Expected not equal to ");
|
||||
} else {
|
||||
ga_concat(gap, (char_u *)"Expected ");
|
||||
ga_concat(gap, "Expected ");
|
||||
}
|
||||
|
||||
if (exp_str == NULL) {
|
||||
@ -6018,11 +6018,11 @@ void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typ
|
||||
|
||||
if (atype != ASSERT_NOTEQUAL) {
|
||||
if (atype == ASSERT_MATCH) {
|
||||
ga_concat(gap, (char_u *)" does not match ");
|
||||
ga_concat(gap, " does not match ");
|
||||
} else if (atype == ASSERT_NOTMATCH) {
|
||||
ga_concat(gap, (char_u *)" does match ");
|
||||
ga_concat(gap, " does match ");
|
||||
} else {
|
||||
ga_concat(gap, (char_u *)" but got ");
|
||||
ga_concat(gap, " but got ");
|
||||
}
|
||||
tofree = (char_u *)encode_tv2string(got_tv, NULL);
|
||||
ga_concat_shorten_esc(gap, tofree);
|
||||
@ -6126,21 +6126,21 @@ int assert_equalfile(typval_T *argvars)
|
||||
prepare_assert_error(&ga);
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
char *const tofree = encode_tv2echo(&argvars[2], NULL);
|
||||
ga_concat(&ga, (char_u *)tofree);
|
||||
ga_concat(&ga, tofree);
|
||||
xfree(tofree);
|
||||
ga_concat(&ga, (char_u *)": ");
|
||||
ga_concat(&ga, ": ");
|
||||
}
|
||||
ga_concat(&ga, IObuff);
|
||||
ga_concat(&ga, (char *)IObuff);
|
||||
if (lineidx > 0) {
|
||||
line1[lineidx] = NUL;
|
||||
line2[lineidx] = NUL;
|
||||
ga_concat(&ga, (char_u *)" after \"");
|
||||
ga_concat(&ga, (char_u *)line1);
|
||||
ga_concat(&ga, " after \"");
|
||||
ga_concat(&ga, line1);
|
||||
if (STRCMP(line1, line2) != 0) {
|
||||
ga_concat(&ga, (char_u *)"\" vs \"");
|
||||
ga_concat(&ga, (char_u *)line2);
|
||||
ga_concat(&ga, "\" vs \"");
|
||||
ga_concat(&ga, line2);
|
||||
}
|
||||
ga_concat(&ga, (char_u *)"\"");
|
||||
ga_concat(&ga, "\"");
|
||||
}
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
@ -6166,13 +6166,13 @@ int assert_inrange(typval_T *argvars)
|
||||
prepare_assert_error(&ga);
|
||||
if (argvars[3].v_type != VAR_UNKNOWN) {
|
||||
char_u *const tofree = (char_u *)encode_tv2string(&argvars[3], NULL);
|
||||
ga_concat(&ga, tofree);
|
||||
ga_concat(&ga, (char *)tofree);
|
||||
xfree(tofree);
|
||||
} else {
|
||||
char msg[80];
|
||||
vim_snprintf(msg, sizeof(msg), "Expected range %g - %g, but got %g",
|
||||
flower, fupper, factual);
|
||||
ga_concat(&ga, (char_u *)msg);
|
||||
ga_concat(&ga, msg);
|
||||
}
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
@ -6238,7 +6238,7 @@ int assert_exception(typval_T *argvars)
|
||||
const char *const error = tv_get_string_chk(&argvars[0]);
|
||||
if (vimvars[VV_EXCEPTION].vv_str == NULL) {
|
||||
prepare_assert_error(&ga);
|
||||
ga_concat(&ga, (char_u *)"v:exception is not set");
|
||||
ga_concat(&ga, "v:exception is not set");
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
return 1;
|
||||
@ -6259,10 +6259,10 @@ static void assert_append_cmd_or_arg(garray_T *gap, typval_T *argvars, const cha
|
||||
{
|
||||
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) {
|
||||
char *const tofree = encode_tv2echo(&argvars[2], NULL);
|
||||
ga_concat(gap, (char_u *)tofree);
|
||||
ga_concat(gap, tofree);
|
||||
xfree(tofree);
|
||||
} else {
|
||||
ga_concat(gap, (char_u *)cmd);
|
||||
ga_concat(gap, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6280,11 +6280,11 @@ int assert_beeps(typval_T *argvars, bool no_beep)
|
||||
garray_T ga;
|
||||
prepare_assert_error(&ga);
|
||||
if (no_beep) {
|
||||
ga_concat(&ga, (const char_u *)"command did beep: ");
|
||||
ga_concat(&ga, "command did beep: ");
|
||||
} else {
|
||||
ga_concat(&ga, (const char_u *)"command did not beep: ");
|
||||
ga_concat(&ga, "command did not beep: ");
|
||||
}
|
||||
ga_concat(&ga, (const char_u *)cmd);
|
||||
ga_concat(&ga, cmd);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
ret = 1;
|
||||
@ -6312,7 +6312,7 @@ int assert_fails(typval_T *argvars)
|
||||
do_cmdline_cmd(cmd);
|
||||
if (!called_emsg) {
|
||||
prepare_assert_error(&ga);
|
||||
ga_concat(&ga, (const char_u *)"command did not fail: ");
|
||||
ga_concat(&ga, "command did not fail: ");
|
||||
assert_append_cmd_or_arg(&ga, argvars, cmd);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
@ -6326,7 +6326,7 @@ int assert_fails(typval_T *argvars)
|
||||
prepare_assert_error(&ga);
|
||||
fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
|
||||
&vimvars[VV_ERRMSG].vv_tv, ASSERT_OTHER);
|
||||
ga_concat(&ga, (char_u *)": ");
|
||||
ga_concat(&ga, ": ");
|
||||
assert_append_cmd_or_arg(&ga, argvars, cmd);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "nvim/message.h"
|
||||
#include "nvim/vim.h" // For _()
|
||||
|
||||
#define ga_concat(a, b) ga_concat(a, (char_u *)b)
|
||||
#define utf_ptr2char(b) utf_ptr2char((char_u *)b)
|
||||
#define utf_ptr2len(b) ((size_t)utf_ptr2len((char_u *)b))
|
||||
#define utf_char2len(b) ((size_t)utf_char2len(b))
|
||||
@ -142,7 +141,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|
||||
char *const key = encode_tv2string(&key_tv, NULL);
|
||||
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
|
||||
xfree(key);
|
||||
ga_concat(&msg_ga, IObuff);
|
||||
ga_concat(&msg_ga, (char *)IObuff);
|
||||
break;
|
||||
}
|
||||
case kMPConvPairs:
|
||||
@ -163,7 +162,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|
||||
|| (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
|
||||
&& tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) <= 0)) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, idx_msg, idx);
|
||||
ga_concat(&msg_ga, IObuff);
|
||||
ga_concat(&msg_ga, (char *)IObuff);
|
||||
} else {
|
||||
assert(li != NULL);
|
||||
listitem_T *const first_item =
|
||||
@ -173,7 +172,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|
||||
char *const key = encode_tv2echo(&key_tv, NULL);
|
||||
vim_snprintf((char *)IObuff, IOSIZE, key_pair_msg, key, idx);
|
||||
xfree(key);
|
||||
ga_concat(&msg_ga, IObuff);
|
||||
ga_concat(&msg_ga, (char *)IObuff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -193,7 +192,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|
||||
case kMPConvPartialList: {
|
||||
const int idx = (int)(v.data.a.arg - v.data.a.argv) - 1;
|
||||
vim_snprintf((char *)IObuff, IOSIZE, partial_arg_i_msg, idx);
|
||||
ga_concat(&msg_ga, IObuff);
|
||||
ga_concat(&msg_ga, (char *)IObuff);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -355,20 +354,20 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|
||||
const float_T flt_ = (flt); \
|
||||
switch (xfpclassify(flt_)) { \
|
||||
case FP_NAN: { \
|
||||
ga_concat(gap, (char_u *)"str2float('nan')"); \
|
||||
ga_concat(gap, "str2float('nan')"); \
|
||||
break; \
|
||||
} \
|
||||
case FP_INFINITE: { \
|
||||
if (flt_ < 0) { \
|
||||
ga_append(gap, '-'); \
|
||||
} \
|
||||
ga_concat(gap, (char_u *)"str2float('inf')"); \
|
||||
ga_concat(gap, "str2float('inf')"); \
|
||||
break; \
|
||||
} \
|
||||
default: { \
|
||||
char numbuf[NUMBUFLEN]; \
|
||||
vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
|
||||
ga_concat(gap, (char_u *)numbuf); \
|
||||
ga_concat(gap, numbuf); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
@ -569,7 +568,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|
||||
default: { \
|
||||
char numbuf[NUMBUFLEN]; \
|
||||
vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
|
||||
ga_concat(gap, (char_u *)numbuf); \
|
||||
ga_concat(gap, numbuf); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
@ -874,7 +873,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, tv->vval.v_string);
|
||||
ga_concat(&ga, (char *)tv->vval.v_string);
|
||||
}
|
||||
} else {
|
||||
const int eve_ret = encode_vim_to_echo(&ga, tv, N_(":echo argument"));
|
||||
|
@ -491,7 +491,7 @@ static void f_assert_report(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
garray_T ga;
|
||||
|
||||
prepare_assert_error(&ga);
|
||||
ga_concat(&ga, (const char_u *)tv_get_string(&argvars[0]));
|
||||
ga_concat(&ga, tv_get_string(&argvars[0]));
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
rettv->vval.v_number = 1;
|
||||
@ -5909,7 +5909,7 @@ static void f_list2str(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
TV_LIST_ITER_CONST(l, li, {
|
||||
buf[utf_char2bytes(tv_get_number(TV_LIST_ITEM_TV(li)), buf)] = NUL;
|
||||
ga_concat(&ga, buf);
|
||||
ga_concat(&ga, (char *)buf);
|
||||
});
|
||||
ga_append(&ga, NUL);
|
||||
|
||||
@ -12012,10 +12012,10 @@ static void f_winrestcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||
snprintf((char *)buf, sizeof(buf), "%dresize %d|", winnr,
|
||||
wp->w_height);
|
||||
ga_concat(&ga, buf);
|
||||
ga_concat(&ga, (char *)buf);
|
||||
snprintf((char *)buf, sizeof(buf), "vert %dresize %d|", winnr,
|
||||
wp->w_width);
|
||||
ga_concat(&ga, buf);
|
||||
ga_concat(&ga, (char *)buf);
|
||||
winnr++;
|
||||
}
|
||||
}
|
||||
|
@ -789,12 +789,12 @@ static int list_join_inner(garray_T *const gap, list_T *const l, const char *con
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
ga_concat(gap, (const char_u *)sep);
|
||||
ga_concat(gap, sep);
|
||||
}
|
||||
const Join *const p = ((const Join *)join_gap->ga_data) + i;
|
||||
|
||||
if (p->s != NULL) {
|
||||
ga_concat(gap, p->s);
|
||||
ga_concat(gap, (char *)p->s);
|
||||
}
|
||||
line_breakcheck();
|
||||
}
|
||||
|
@ -4409,7 +4409,7 @@ skip:
|
||||
pre_src_id = (int)nvim_create_namespace((String)STRING_INIT);
|
||||
}
|
||||
if (pre_hl_id == 0) {
|
||||
pre_hl_id = syn_check_group((char_u *)S_LEN("Substitute"));
|
||||
pre_hl_id = syn_check_group(S_LEN("Substitute"));
|
||||
}
|
||||
curbuf->b_changed = save_b_changed; // preserve 'modified' during preview
|
||||
preview_buf = show_sub(eap, old_cursor, &preview_lines,
|
||||
|
@ -1984,7 +1984,7 @@ static void cmd_source_buffer(const exarg_T *const eap)
|
||||
if (ga.ga_len > 400) {
|
||||
ga_set_growsize(&ga, MAX(ga.ga_len, 8000));
|
||||
}
|
||||
ga_concat(&ga, ml_get(curr_lnum));
|
||||
ga_concat(&ga, (char *)ml_get(curr_lnum));
|
||||
ga_append(&ga, NL);
|
||||
}
|
||||
((char_u *)ga.ga_data)[ga.ga_len - 1] = NUL;
|
||||
@ -2459,7 +2459,7 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
garray_T ga;
|
||||
|
||||
ga_init(&ga, (int)sizeof(char_u), 400);
|
||||
ga_concat(&ga, line);
|
||||
ga_concat(&ga, (char *)line);
|
||||
while (sp->nextline != NULL
|
||||
&& concat_continued_line(&ga, 400, sp->nextline,
|
||||
STRLEN(sp->nextline))) {
|
||||
|
@ -6595,7 +6595,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp)
|
||||
}
|
||||
|
||||
if (!eap->skip) {
|
||||
ga_concat(&ga, (const char_u *)theline);
|
||||
ga_concat(&ga, theline);
|
||||
ga_append(&ga, '\n');
|
||||
}
|
||||
xfree(theline);
|
||||
|
@ -192,13 +192,13 @@ char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
|
||||
///
|
||||
/// @param gap
|
||||
/// @param s
|
||||
void ga_concat(garray_T *gap, const char_u *restrict s)
|
||||
void ga_concat(garray_T *gap, const char *restrict s)
|
||||
{
|
||||
if (s == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ga_concat_len(gap, (const char *restrict)s, strlen((char *)s));
|
||||
ga_concat_len(gap, s, strlen((char *)s));
|
||||
}
|
||||
|
||||
/// Concatenate a string to a growarray which contains characters
|
||||
|
@ -4470,7 +4470,7 @@ static char_u *translate_mapping(char_u *str, int cpo_flags)
|
||||
str += 2;
|
||||
}
|
||||
if (IS_SPECIAL(c) || modifiers) { // special key
|
||||
ga_concat(&ga, get_special_key_name(c, modifiers));
|
||||
ga_concat(&ga, (char *)get_special_key_name(c, modifiers));
|
||||
continue; // for (str)
|
||||
}
|
||||
}
|
||||
@ -4564,7 +4564,7 @@ char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
|
||||
aborted = true;
|
||||
} else if (IS_SPECIAL(c1)) {
|
||||
if (c1 == K_SNR) {
|
||||
ga_concat(&line_ga, (char_u *)"<SNR>");
|
||||
ga_concat(&line_ga, "<SNR>");
|
||||
} else {
|
||||
EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod));
|
||||
aborted = true;
|
||||
|
@ -306,7 +306,7 @@ void update_window_hl(win_T *wp, bool invalid)
|
||||
// syntax group! It needs at least 10 layers of special casing! Noooooo!
|
||||
//
|
||||
// haha, theme engine go brrr
|
||||
int normality = syn_check_group((const char_u *)S_LEN("Normal"));
|
||||
int normality = syn_check_group(S_LEN("Normal"));
|
||||
int ns_attr = ns_get_hl(-1, normality, false, false);
|
||||
if (ns_attr > 0) {
|
||||
// TODO(bfredl): hantera NormalNC and so on
|
||||
@ -890,7 +890,7 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
|
||||
} else if (link_id && strequal(key, "link")) {
|
||||
if (val.type == kObjectTypeString) {
|
||||
String str = val.data.string;
|
||||
*link_id = syn_check_group((const char_u *)str.data, (int)str.size);
|
||||
*link_id = syn_check_group(str.data, (int)str.size);
|
||||
} else if (val.type == kObjectTypeInteger) {
|
||||
// TODO(bfredl): validate range?
|
||||
*link_id = (int)val.data.integer;
|
||||
|
@ -1168,8 +1168,7 @@ char *mt_inspect_rec(MarkTree *b)
|
||||
void mt_inspect_node(MarkTree *b, garray_T *ga, mtnode_t *n, mtpos_t off)
|
||||
{
|
||||
static char buf[1024];
|
||||
#define GA_PUT(x) ga_concat(ga, (char_u *)(x))
|
||||
GA_PUT("[");
|
||||
ga_concat(ga, "[");
|
||||
if (n->level) {
|
||||
mt_inspect_node(b, ga, n->ptr[0], off);
|
||||
}
|
||||
@ -1177,14 +1176,13 @@ void mt_inspect_node(MarkTree *b, garray_T *ga, mtnode_t *n, mtpos_t off)
|
||||
mtpos_t p = n->key[i].pos;
|
||||
unrelative(off, &p);
|
||||
snprintf((char *)buf, sizeof(buf), "%d/%d", p.row, p.col);
|
||||
GA_PUT(buf);
|
||||
ga_concat(ga, buf);
|
||||
if (n->level) {
|
||||
mt_inspect_node(b, ga, n->ptr[i+1], p);
|
||||
} else {
|
||||
GA_PUT(",");
|
||||
ga_concat(ga, ",");
|
||||
}
|
||||
}
|
||||
GA_PUT("]");
|
||||
#undef GA_PUT
|
||||
ga_concat(ga, "]");
|
||||
}
|
||||
|
||||
|
@ -1609,7 +1609,7 @@ char *str2special_save(const char *const str, const bool replace_spaces, const b
|
||||
|
||||
const char *p = str;
|
||||
while (*p != NUL) {
|
||||
ga_concat(&ga, (const char_u *)str2special(&p, replace_spaces, replace_lt));
|
||||
ga_concat(&ga, str2special(&p, replace_spaces, replace_lt));
|
||||
}
|
||||
ga_append(&ga, NUL);
|
||||
return (char *)ga.ga_data;
|
||||
|
@ -3745,7 +3745,7 @@ static bool parse_winhl_opt(win_T *wp)
|
||||
char *hi = colon+1;
|
||||
char *commap = xstrchrnul(hi, ',');
|
||||
int len = (int)(commap-hi);
|
||||
int hl_id = len ? syn_check_group((char_u *)hi, len) : -1;
|
||||
int hl_id = len ? syn_check_group(hi, len) : -1;
|
||||
|
||||
if (strncmp("Normal", p, nlen) == 0) {
|
||||
w_hl_id_normal = hl_id;
|
||||
|
@ -2208,7 +2208,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
|
||||
|
||||
if (provider_err) {
|
||||
Decoration err_decor = DECORATION_INIT;
|
||||
int hl_err = syn_check_group((char_u *)S_LEN("ErrorMsg"));
|
||||
int hl_err = syn_check_group(S_LEN("ErrorMsg"));
|
||||
kv_push(err_decor.virt_text,
|
||||
((VirtTextChunk){ .text = provider_err,
|
||||
.hl_id = hl_err }));
|
||||
|
@ -3978,7 +3978,7 @@ static bool shada_removable(const char *name)
|
||||
|
||||
char *new_name = (char *)home_replace_save(NULL, (char_u *)name);
|
||||
for (p = (char *)p_shada; *p; ) {
|
||||
(void)(char *)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", ");
|
||||
(void)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", ");
|
||||
if (part[0] == 'r') {
|
||||
home_replace(NULL, (char_u *)(part + 1), (char_u *)NameBuff, MAXPATHL, true);
|
||||
size_t n = STRLEN(NameBuff);
|
||||
|
@ -902,7 +902,7 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
|
||||
|
||||
/// Define a new sign or update an existing sign
|
||||
int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text, char_u *texthl,
|
||||
char_u *numhl)
|
||||
char *numhl)
|
||||
{
|
||||
sign_T *sp_prev;
|
||||
sign_T *sp;
|
||||
@ -940,11 +940,11 @@ int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text
|
||||
}
|
||||
|
||||
if (linehl != NULL) {
|
||||
sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl));
|
||||
sp->sn_line_hl = syn_check_group((char *)linehl, (int)STRLEN(linehl));
|
||||
}
|
||||
|
||||
if (texthl != NULL) {
|
||||
sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl));
|
||||
sp->sn_text_hl = syn_check_group((char *)texthl, (int)STRLEN(texthl));
|
||||
}
|
||||
|
||||
if (numhl != NULL) {
|
||||
@ -1167,7 +1167,7 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
sign_define_by_name(sign_name, icon, linehl, text, texthl, numhl);
|
||||
sign_define_by_name(sign_name, icon, linehl, text, texthl, (char *)numhl);
|
||||
}
|
||||
|
||||
xfree(icon);
|
||||
@ -1871,7 +1871,7 @@ int sign_define_from_dict(const char *name_arg, dict_T *dict)
|
||||
}
|
||||
|
||||
if (sign_define_by_name((char_u *)name, (char_u *)icon, (char_u *)linehl,
|
||||
(char_u *)text, (char_u *)texthl, (char_u *)numhl)
|
||||
(char_u *)text, (char_u *)texthl, numhl)
|
||||
== OK) {
|
||||
retval = 0;
|
||||
}
|
||||
|
@ -2659,7 +2659,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
|
||||
// We simply concatenate all the MAP strings, separated by
|
||||
// slashes.
|
||||
ga_concat(&spin->si_map, items[1]);
|
||||
ga_concat(&spin->si_map, (char *)items[1]);
|
||||
ga_append(&spin->si_map, '/');
|
||||
}
|
||||
}
|
||||
|
@ -4423,7 +4423,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
|
||||
if (eap->skip) {
|
||||
syn_id = -1;
|
||||
} else {
|
||||
syn_id = syn_check_group(arg, (int)(group_name_end - arg));
|
||||
syn_id = syn_check_group((char *)arg, (int)(group_name_end - arg));
|
||||
}
|
||||
if (syn_id != 0) {
|
||||
// Allocate a buffer, for removing backslashes in the keyword.
|
||||
@ -4560,7 +4560,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
|
||||
if (!ends_excmd(*rest) || eap->skip) {
|
||||
rest = NULL;
|
||||
} else {
|
||||
if ((syn_id = syn_check_group(arg, (int)(group_name_end - arg))) != 0) {
|
||||
if ((syn_id = syn_check_group((char *)arg, (int)(group_name_end - arg))) != 0) {
|
||||
syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
|
||||
/*
|
||||
* Store the pattern in the syn_items list
|
||||
@ -4709,7 +4709,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
|
||||
if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip) {
|
||||
matchgroup_id = 0;
|
||||
} else {
|
||||
matchgroup_id = syn_check_group(rest, (int)(p - rest));
|
||||
matchgroup_id = syn_check_group((char *)rest, (int)(p - rest));
|
||||
if (matchgroup_id == 0) {
|
||||
illegal = true;
|
||||
break;
|
||||
@ -4768,7 +4768,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
|
||||
rest = NULL;
|
||||
} else {
|
||||
ga_grow(&(curwin->w_s->b_syn_patterns), pat_count);
|
||||
if ((syn_id = syn_check_group(arg, (int)(group_name_end - arg))) != 0) {
|
||||
if ((syn_id = syn_check_group((char *)arg, (int)(group_name_end - arg))) != 0) {
|
||||
syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
|
||||
/*
|
||||
* Store the start/skip/end in the syn_items list
|
||||
@ -5264,8 +5264,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|
||||
if (!ends_excmd(*next_arg)) {
|
||||
arg_end = skiptowhite(next_arg);
|
||||
if (!eap->skip) {
|
||||
curwin->w_s->b_syn_sync_id = syn_check_group(next_arg,
|
||||
(int)(arg_end - next_arg));
|
||||
curwin->w_s->b_syn_sync_id = syn_check_group((char *)next_arg, (int)(arg_end - next_arg));
|
||||
}
|
||||
next_arg = skipwhite(arg_end);
|
||||
} else if (!eap->skip) {
|
||||
@ -5447,7 +5446,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis
|
||||
* Handle full group name.
|
||||
*/
|
||||
if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL) {
|
||||
id = syn_check_group(name + 1, (int)(end - p));
|
||||
id = syn_check_group((char *)(name + 1), (int)(end - p));
|
||||
} else {
|
||||
// Handle match of regexp with group names.
|
||||
*name = '^';
|
||||
@ -6813,13 +6812,11 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
||||
return;
|
||||
}
|
||||
|
||||
from_id = syn_check_group((const char_u *)from_start,
|
||||
(int)(from_end - from_start));
|
||||
from_id = syn_check_group(from_start, (int)(from_end - from_start));
|
||||
if (strncmp(to_start, "NONE", 4) == 0) {
|
||||
to_id = 0;
|
||||
} else {
|
||||
to_id = syn_check_group((const char_u *)to_start,
|
||||
(int)(to_end - to_start));
|
||||
to_id = syn_check_group(to_start, (int)(to_end - to_start));
|
||||
}
|
||||
|
||||
if (from_id > 0) {
|
||||
@ -6880,7 +6877,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
||||
}
|
||||
|
||||
// Find the group name in the table. If it does not exist yet, add it.
|
||||
id = syn_check_group((const char_u *)line, (int)(name_end - line));
|
||||
id = syn_check_group(line, (int)(name_end - line));
|
||||
if (id == 0) { // Failed (out of memory).
|
||||
return;
|
||||
}
|
||||
@ -7684,11 +7681,11 @@ char_u *syn_id2name(int id)
|
||||
/// @param len length of \p pp
|
||||
///
|
||||
/// @return 0 for failure else the id of the group
|
||||
int syn_check_group(const char_u *name, int len)
|
||||
int syn_check_group(const char *name, int len)
|
||||
{
|
||||
int id = syn_name2id_len(name, len);
|
||||
int id = syn_name2id_len((char_u *)name, len);
|
||||
if (id == 0) { // doesn't exist yet
|
||||
return syn_add_group(vim_strnsave(name, len));
|
||||
return syn_add_group(vim_strnsave((char_u *)name, len));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@ -7888,7 +7885,7 @@ void highlight_changed(void)
|
||||
|
||||
/// Translate builtin highlight groups into attributes for quick lookup.
|
||||
for (int hlf = 0; hlf < HLF_COUNT; hlf++) {
|
||||
id = syn_check_group((char_u *)hlf_names[hlf], STRLEN(hlf_names[hlf]));
|
||||
id = syn_check_group(hlf_names[hlf], STRLEN(hlf_names[hlf]));
|
||||
if (id == 0) {
|
||||
abort();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define HL_CONCEAL 0x20000 // can be concealed
|
||||
#define HL_CONCEALENDS 0x40000 // can be concealed
|
||||
|
||||
#define SYN_GROUP_STATIC(s) syn_check_group((char_u *)S_LEN(s))
|
||||
#define SYN_GROUP_STATIC(s) syn_check_group(S_LEN(s))
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
|
@ -89,10 +89,10 @@ void ui_comp_init(void)
|
||||
|
||||
void ui_comp_syn_init(void)
|
||||
{
|
||||
dbghl_normal = syn_check_group((char_u *)S_LEN("RedrawDebugNormal"));
|
||||
dbghl_clear = syn_check_group((char_u *)S_LEN("RedrawDebugClear"));
|
||||
dbghl_composed = syn_check_group((char_u *)S_LEN("RedrawDebugComposed"));
|
||||
dbghl_recompose = syn_check_group((char_u *)S_LEN("RedrawDebugRecompose"));
|
||||
dbghl_normal = syn_check_group(S_LEN("RedrawDebugNormal"));
|
||||
dbghl_clear = syn_check_group(S_LEN("RedrawDebugClear"));
|
||||
dbghl_composed = syn_check_group(S_LEN("RedrawDebugComposed"));
|
||||
dbghl_recompose = syn_check_group(S_LEN("RedrawDebugRecompose"));
|
||||
}
|
||||
|
||||
void ui_comp_attach(UI *ui)
|
||||
|
@ -2017,9 +2017,9 @@ void ex_version(exarg_T *eap)
|
||||
/// When "wrap" is TRUE wrap the string in [].
|
||||
/// @param s
|
||||
/// @param wrap
|
||||
static void version_msg_wrap(char_u *s, int wrap)
|
||||
static void version_msg_wrap(char *s, int wrap)
|
||||
{
|
||||
int len = vim_strsize(s) + (wrap ? 2 : 0);
|
||||
int len = vim_strsize((char_u *)s) + (wrap ? 2 : 0);
|
||||
|
||||
if (!got_int
|
||||
&& (len < Columns)
|
||||
@ -2032,7 +2032,7 @@ static void version_msg_wrap(char_u *s, int wrap)
|
||||
if (wrap) {
|
||||
msg_puts("[");
|
||||
}
|
||||
msg_puts((char *)s);
|
||||
msg_puts(s);
|
||||
if (wrap) {
|
||||
msg_puts("]");
|
||||
}
|
||||
@ -2041,7 +2041,7 @@ static void version_msg_wrap(char_u *s, int wrap)
|
||||
|
||||
static void version_msg(char *s)
|
||||
{
|
||||
version_msg_wrap((char_u *)s, false);
|
||||
version_msg_wrap(s, false);
|
||||
}
|
||||
|
||||
/// List all features.
|
||||
@ -2082,7 +2082,7 @@ void list_in_columns(char_u **items, int size, int current)
|
||||
if (Columns < width) {
|
||||
// Not enough screen columns - show one per line
|
||||
for (i = 0; i < item_count; i++) {
|
||||
version_msg_wrap(items[i], i == current);
|
||||
version_msg_wrap((char *)items[i], i == current);
|
||||
if (msg_col > 0 && i < item_count - 1) {
|
||||
msg_putchar('\n');
|
||||
}
|
||||
|
@ -6693,7 +6693,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, int prio,
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
if ((hlg_id = syn_check_group((const char_u *)grp, strlen(grp))) == 0) {
|
||||
if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (pat != NULL && (regprog = vim_regcomp((char_u *)pat, RE_MAGIC)) == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user