diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-10-12 17:52:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 17:52:54 +0200 |
commit | 649b3160a10f0053747383f0703b0a5a94548570 (patch) | |
tree | 2898b7213ab1349717c360c8d7561a4606f3c8c2 | |
parent | 64f0fdc6822db4fc1ef5fadb892aab5bf04e75a7 (diff) | |
download | rneovim-649b3160a10f0053747383f0703b0a5a94548570.tar.gz rneovim-649b3160a10f0053747383f0703b0a5a94548570.tar.bz2 rneovim-649b3160a10f0053747383f0703b0a5a94548570.zip |
refactor: reduce number of unique char casts (#15995)
-rw-r--r-- | src/nvim/api/buffer.c | 2 | ||||
-rw-r--r-- | src/nvim/api/private/helpers.c | 4 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 4 | ||||
-rw-r--r-- | src/nvim/buffer.c | 24 | ||||
-rw-r--r-- | src/nvim/cursor_shape.c | 5 | ||||
-rw-r--r-- | src/nvim/debugger.c | 6 | ||||
-rw-r--r-- | src/nvim/edit.c | 8 | ||||
-rw-r--r-- | src/nvim/eval.c | 88 | ||||
-rw-r--r-- | src/nvim/eval/encode.c | 19 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 8 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 2 | ||||
-rw-r--r-- | src/nvim/garray.c | 4 | ||||
-rw-r--r-- | src/nvim/getchar.c | 4 | ||||
-rw-r--r-- | src/nvim/highlight.c | 4 | ||||
-rw-r--r-- | src/nvim/marktree.c | 10 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/shada.c | 2 | ||||
-rw-r--r-- | src/nvim/sign.c | 10 | ||||
-rw-r--r-- | src/nvim/spellfile.c | 2 | ||||
-rw-r--r-- | src/nvim/syntax.c | 29 | ||||
-rw-r--r-- | src/nvim/syntax.h | 2 | ||||
-rw-r--r-- | src/nvim/ui_compositor.c | 8 | ||||
-rw-r--r-- | src/nvim/version.c | 10 | ||||
-rw-r--r-- | src/nvim/window.c | 2 |
29 files changed, 133 insertions, 140 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 3a38a14cdd..31d44c68bf 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -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; } diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index aed87048ce..b2529db5be 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -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; } } diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 0565f8cd77..e58a59e872 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -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); diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 6d91632dcd..2617859381 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -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; } diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 128bc480da..18cade1052 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -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; diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 58b1d9ce7f..aeaf2555b1 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -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, diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 5ac733285d..ea49222a93 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -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); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a281c09042..ac659fbda4 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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); diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 5ef0045659..2d4d9fdea9 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -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")); diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 709ef8e5b6..17cf141b54 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -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++; } } diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index cfc95ba167..6300ce6150 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -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(); } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 3bfbb42d87..d247118589 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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, diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 46b86fbc84..c3cde2f15a 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -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))) { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f4f07e0680..4c4d3e89e4 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -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); diff --git a/src/nvim/garray.c b/src/nvim/garray.c index bc3b7211c9..69ad17ebcb 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -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 diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index a53742b17b..280d2506c6 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -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; diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index bb325b3f25..737e668e81 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -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; diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index e62f91e698..fd7012e895 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -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, "]"); } diff --git a/src/nvim/message.c b/src/nvim/message.c index cc4319b8da..c4aab18c35 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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; diff --git a/src/nvim/option.c b/src/nvim/option.c index a9bff8285c..b766ae92cf 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -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; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index fcd8fb1118..d8cd8c2008 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -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 })); diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 2610df666b..10f93913ad 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -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); diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 25427de6bf..1b100161bf 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -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; } diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 772275df84..2a501f4714 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -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, '/'); } } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 49f54dcfe1..2b5faee8de 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -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(); } diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h index e61c75c840..15fc084a0a 100644 --- a/src/nvim/syntax.h +++ b/src/nvim/syntax.h @@ -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; diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 7a0f68cfeb..d7becb4fd4 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -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) diff --git a/src/nvim/version.c b/src/nvim/version.c index bc06ef0b98..9e2358c9a3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -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'); } diff --git a/src/nvim/window.c b/src/nvim/window.c index ff97eaa757..1fe4aa1add 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -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) { |