mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 05:05:00 -07:00
refactor: remove some (const char **) casts (#24423)
This commit is contained in:
parent
4b57ff77fe
commit
d2efcbf2dc
@ -2879,10 +2879,10 @@ bool checkforcmd(char **pp, const char *cmd, int len)
|
||||
/// Append "cmd" to the error message in IObuff.
|
||||
/// Takes care of limiting the length and handling 0xa0, which would be
|
||||
/// invisible otherwise.
|
||||
static void append_command(char *cmd)
|
||||
static void append_command(const char *cmd)
|
||||
{
|
||||
size_t len = strlen(IObuff);
|
||||
char *s = cmd;
|
||||
const char *s = cmd;
|
||||
char *d;
|
||||
|
||||
if (len > IOSIZE - 100) {
|
||||
@ -2901,7 +2901,7 @@ static void append_command(char *cmd)
|
||||
} else if (d - IObuff + utfc_ptr2len(s) + 1 >= IOSIZE) {
|
||||
break;
|
||||
} else {
|
||||
mb_copy_char((const char **)&s, &d);
|
||||
mb_copy_char(&s, &d);
|
||||
}
|
||||
}
|
||||
*d = NUL;
|
||||
|
@ -3530,7 +3530,7 @@ void unputcmdline(void)
|
||||
// part will be redrawn, otherwise it will not. If this function is called
|
||||
// twice in a row, then 'redraw' should be false and redrawcmd() should be
|
||||
// called afterwards.
|
||||
void put_on_cmdline(char *str, int len, int redraw)
|
||||
void put_on_cmdline(const char *str, int len, int redraw)
|
||||
{
|
||||
int i;
|
||||
int m;
|
||||
@ -3740,7 +3740,7 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
|
||||
// When "literally" is true, insert literally.
|
||||
// When "literally" is false, insert as typed, but don't leave the command
|
||||
// line.
|
||||
void cmdline_paste_str(char *s, int literally)
|
||||
void cmdline_paste_str(const char *s, int literally)
|
||||
{
|
||||
if (literally) {
|
||||
put_on_cmdline(s, -1, true);
|
||||
@ -3750,7 +3750,7 @@ void cmdline_paste_str(char *s, int literally)
|
||||
if (cv == Ctrl_V && s[1]) {
|
||||
s++;
|
||||
}
|
||||
int c = mb_cptr2char_adv((const char **)&s);
|
||||
int c = mb_cptr2char_adv(&s);
|
||||
if (cv == Ctrl_V || c == ESC || c == Ctrl_C
|
||||
|| c == CAR || c == NL || c == Ctrl_L
|
||||
|| (c == Ctrl_BSL && *s == Ctrl_N)) {
|
||||
|
@ -242,8 +242,8 @@ bool os_isatty(int fd)
|
||||
|
||||
size_t input_enqueue(String keys)
|
||||
{
|
||||
char *ptr = keys.data;
|
||||
char *end = ptr + keys.size;
|
||||
const char *ptr = keys.data;
|
||||
const char *end = ptr + keys.size;
|
||||
|
||||
while (rbuffer_space(input_buffer) >= 19 && ptr < end) {
|
||||
// A "<x>" form occupies at least 1 characters, and produces up
|
||||
@ -254,8 +254,7 @@ size_t input_enqueue(String keys)
|
||||
uint8_t buf[19] = { 0 };
|
||||
// Do not simplify the keys here. Simplification will be done later.
|
||||
unsigned new_size
|
||||
= trans_special((const char **)&ptr, (size_t)(end - ptr), (char *)buf, FSK_KEYCODE, true,
|
||||
NULL);
|
||||
= trans_special(&ptr, (size_t)(end - ptr), (char *)buf, FSK_KEYCODE, true, NULL);
|
||||
|
||||
if (new_size) {
|
||||
new_size = handle_mouse_event(&ptr, buf, new_size);
|
||||
@ -264,7 +263,7 @@ size_t input_enqueue(String keys)
|
||||
}
|
||||
|
||||
if (*ptr == '<') {
|
||||
char *old_ptr = ptr;
|
||||
const char *old_ptr = ptr;
|
||||
// Invalid or incomplete key sequence, skip until the next '>' or *end.
|
||||
do {
|
||||
ptr++;
|
||||
@ -346,7 +345,7 @@ static uint8_t check_multiclick(int code, int grid, int row, int col)
|
||||
|
||||
// Mouse event handling code(Extract row/col if available and detect multiple
|
||||
// clicks)
|
||||
static unsigned handle_mouse_event(char **ptr, uint8_t *buf, unsigned bufsize)
|
||||
static unsigned handle_mouse_event(const char **ptr, uint8_t *buf, unsigned bufsize)
|
||||
{
|
||||
int mouse_code = 0;
|
||||
int type = 0;
|
||||
|
@ -1412,7 +1412,7 @@ static int cstrncmp(char *s1, char *s2, int *n)
|
||||
|
||||
// if it failed and it's utf8 and we want to combineignore:
|
||||
if (result != 0 && rex.reg_icombine) {
|
||||
char *str1, *str2;
|
||||
const char *str1, *str2;
|
||||
int c1, c2, c11, c12;
|
||||
int junk;
|
||||
|
||||
@ -1422,8 +1422,8 @@ static int cstrncmp(char *s1, char *s2, int *n)
|
||||
str2 = s2;
|
||||
c1 = c2 = 0;
|
||||
while ((int)(str1 - s1) < *n) {
|
||||
c1 = mb_ptr2char_adv((const char **)&str1);
|
||||
c2 = mb_ptr2char_adv((const char **)&str2);
|
||||
c1 = mb_ptr2char_adv(&str1);
|
||||
c2 = mb_ptr2char_adv(&str2);
|
||||
|
||||
// decompose the character if necessary, into 'base' characters
|
||||
// because I don't care about Arabic, I will hard-code the Hebrew
|
||||
|
@ -2238,10 +2238,10 @@ static int find_region(const char *rp, const char *region)
|
||||
/// @param[in] end End of word or NULL for NUL delimited string
|
||||
///
|
||||
/// @returns Case type of word
|
||||
int captype(char *word, const char *end)
|
||||
int captype(const char *word, const char *end)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
// find first letter
|
||||
for (p = word; !spell_iswordp_nmw(p, curwin); MB_PTR_ADV(p)) {
|
||||
@ -2249,7 +2249,7 @@ int captype(char *word, const char *end)
|
||||
return 0; // only non-word characters, illegal word
|
||||
}
|
||||
}
|
||||
int c = mb_ptr2char_adv((const char **)&p);
|
||||
int c = mb_ptr2char_adv(&p);
|
||||
bool allcap;
|
||||
bool firstcap = allcap = SPELL_ISUPPER(c);
|
||||
bool past_second = false; // past second word char
|
||||
@ -2503,7 +2503,7 @@ static bool spell_iswordp_w(const int *p, const win_T *wp)
|
||||
// Uses the character definitions from the .spl file.
|
||||
// When using a multi-byte 'encoding' the length may change!
|
||||
// Returns FAIL when something wrong.
|
||||
int spell_casefold(const win_T *wp, char *str, int len, char *buf, int buflen)
|
||||
int spell_casefold(const win_T *wp, const char *str, int len, char *buf, int buflen)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (len >= buflen) {
|
||||
@ -2514,12 +2514,12 @@ int spell_casefold(const win_T *wp, char *str, int len, char *buf, int buflen)
|
||||
int outi = 0;
|
||||
|
||||
// Fold one character at a time.
|
||||
for (char *p = str; p < str + len;) {
|
||||
for (const char *p = str; p < str + len;) {
|
||||
if (outi + MB_MAXBYTES > buflen) {
|
||||
buf[outi] = NUL;
|
||||
return FAIL;
|
||||
}
|
||||
int c = mb_cptr2char_adv((const char **)&p);
|
||||
int c = mb_cptr2char_adv(&p);
|
||||
|
||||
// Exception: greek capital sigma 0x03A3 folds to 0x03C3, except
|
||||
// when it is the last character in a word, then it folds to
|
||||
@ -2668,10 +2668,10 @@ void ex_spellrepall(exarg_T *eap)
|
||||
/// @param[in] word source string to copy
|
||||
/// @param[in,out] wcopy copied string, with case of first letter changed
|
||||
/// @param[in] upper True to upper case, otherwise lower case
|
||||
void onecap_copy(char *word, char *wcopy, bool upper)
|
||||
void onecap_copy(const char *word, char *wcopy, bool upper)
|
||||
{
|
||||
char *p = word;
|
||||
int c = mb_cptr2char_adv((const char **)&p);
|
||||
const char *p = word;
|
||||
int c = mb_cptr2char_adv(&p);
|
||||
if (upper) {
|
||||
c = SPELL_TOUPPER(c);
|
||||
} else {
|
||||
@ -2683,11 +2683,11 @@ void onecap_copy(char *word, char *wcopy, bool upper)
|
||||
|
||||
// Make a copy of "word" with all the letters upper cased into
|
||||
// "wcopy[MAXWLEN]". The result is NUL terminated.
|
||||
void allcap_copy(char *word, char *wcopy)
|
||||
void allcap_copy(const char *word, char *wcopy)
|
||||
{
|
||||
char *d = wcopy;
|
||||
for (char *s = word; *s != NUL;) {
|
||||
int c = mb_cptr2char_adv((const char **)&s);
|
||||
for (const char *s = word; *s != NUL;) {
|
||||
int c = mb_cptr2char_adv(&s);
|
||||
|
||||
if (c == 0xdf) {
|
||||
c = 'S';
|
||||
@ -2802,7 +2802,7 @@ void spell_soundfold(slang_T *slang, char *inword, bool folded, char *res)
|
||||
|
||||
// Perform sound folding of "inword" into "res" according to SOFOFROM and
|
||||
// SOFOTO lines.
|
||||
static void spell_soundfold_sofo(slang_T *slang, char *inword, char *res)
|
||||
static void spell_soundfold_sofo(slang_T *slang, const char *inword, char *res)
|
||||
{
|
||||
int ri = 0;
|
||||
|
||||
@ -2810,8 +2810,8 @@ static void spell_soundfold_sofo(slang_T *slang, char *inword, char *res)
|
||||
|
||||
// The sl_sal_first[] table contains the translation for chars up to
|
||||
// 255, sl_sal the rest.
|
||||
for (char *s = inword; *s != NUL;) {
|
||||
int c = mb_cptr2char_adv((const char **)&s);
|
||||
for (const char *s = inword; *s != NUL;) {
|
||||
int c = mb_cptr2char_adv(&s);
|
||||
if (utf_class(c) == 0) {
|
||||
c = ' ';
|
||||
} else if (c < 256) {
|
||||
|
@ -1547,10 +1547,10 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
|
||||
|
||||
// Set the SOFOFROM and SOFOTO items in language "lp".
|
||||
// Returns SP_*ERROR flags when there is something wrong.
|
||||
static int set_sofo(slang_T *lp, char *from, char *to)
|
||||
static int set_sofo(slang_T *lp, const char *from, const char *to)
|
||||
{
|
||||
char *s;
|
||||
char *p;
|
||||
const char *s;
|
||||
const char *p;
|
||||
|
||||
// Use "sl_sal" as an array with 256 pointers to a list of wide
|
||||
// characters. The index is the low byte of the character.
|
||||
@ -1565,7 +1565,7 @@ static int set_sofo(slang_T *lp, char *from, char *to)
|
||||
// First count the number of items for each list. Temporarily use
|
||||
// sl_sal_first[] for this.
|
||||
for (p = from, s = to; *p != NUL && *s != NUL;) {
|
||||
const int c = mb_cptr2char_adv((const char **)&p);
|
||||
const int c = mb_cptr2char_adv(&p);
|
||||
MB_CPTR_ADV(s);
|
||||
if (c >= 256) {
|
||||
lp->sl_sal_first[c & 0xff]++;
|
||||
@ -1588,8 +1588,8 @@ static int set_sofo(slang_T *lp, char *from, char *to)
|
||||
// list.
|
||||
memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256);
|
||||
for (p = from, s = to; *p != NUL && *s != NUL;) {
|
||||
const int c = mb_cptr2char_adv((const char **)&p);
|
||||
const int i = mb_cptr2char_adv((const char **)&s);
|
||||
const int c = mb_cptr2char_adv(&p);
|
||||
const int i = mb_cptr2char_adv(&s);
|
||||
if (c >= 256) {
|
||||
// Append the from-to chars at the end of the list with
|
||||
// the low byte.
|
||||
@ -1657,13 +1657,13 @@ static void set_sal_first(slang_T *lp)
|
||||
|
||||
// Turn a multi-byte string into a wide character string.
|
||||
// Return it in allocated memory.
|
||||
static int *mb_str2wide(char *s)
|
||||
static int *mb_str2wide(const char *s)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
int *res = xmalloc(((size_t)mb_charlen(s) + 1) * sizeof(int));
|
||||
for (char *p = s; *p != NUL;) {
|
||||
res[i++] = mb_ptr2char_adv((const char **)&p);
|
||||
for (const char *p = s; *p != NUL;) {
|
||||
res[i++] = mb_ptr2char_adv(&p);
|
||||
}
|
||||
res[i] = NUL;
|
||||
|
||||
@ -5732,13 +5732,13 @@ static void init_spellfile(void)
|
||||
/// Set the spell character tables from strings in the .spl file.
|
||||
///
|
||||
/// @param cnt length of "flags"
|
||||
static void set_spell_charflags(const char *flags_in, int cnt, char *fol)
|
||||
static void set_spell_charflags(const char *flags_in, int cnt, const char *fol)
|
||||
{
|
||||
const uint8_t *flags = (uint8_t *)flags_in;
|
||||
// We build the new tables here first, so that we can compare with the
|
||||
// previous one.
|
||||
spelltab_T new_st;
|
||||
char *p = fol;
|
||||
const char *p = fol;
|
||||
int c;
|
||||
|
||||
clear_spell_chartab(&new_st);
|
||||
@ -5750,7 +5750,7 @@ static void set_spell_charflags(const char *flags_in, int cnt, char *fol)
|
||||
}
|
||||
|
||||
if (*p != NUL) {
|
||||
c = mb_ptr2char_adv((const char **)&p);
|
||||
c = mb_ptr2char_adv(&p);
|
||||
new_st.st_fold[i + 128] = (uint8_t)c;
|
||||
if (i + 128 != c && new_st.st_isu[i + 128] && c < 256) {
|
||||
new_st.st_upper[c] = (uint8_t)(i + 128);
|
||||
@ -5814,9 +5814,9 @@ static int write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv)
|
||||
}
|
||||
|
||||
// Use map string "map" for languages "lp".
|
||||
static void set_map_str(slang_T *lp, char *map)
|
||||
static void set_map_str(slang_T *lp, const char *map)
|
||||
{
|
||||
char *p;
|
||||
const char *p;
|
||||
int headc = 0;
|
||||
|
||||
if (*map == NUL) {
|
||||
@ -5835,7 +5835,7 @@ static void set_map_str(slang_T *lp, char *map)
|
||||
// "aaa/bbb/ccc/". Fill sl_map_array[c] with the character before c and
|
||||
// before the same slash. For characters above 255 sl_map_hash is used.
|
||||
for (p = map; *p != NUL;) {
|
||||
int c = mb_cptr2char_adv((const char **)&p);
|
||||
int c = mb_cptr2char_adv(&p);
|
||||
if (c == '/') {
|
||||
headc = 0;
|
||||
} else {
|
||||
|
@ -128,8 +128,6 @@ void tinput_init(TermInput *input, Loop *loop)
|
||||
input->in_fd = STDIN_FILENO;
|
||||
input->waiting_for_bg_response = 0;
|
||||
input->extkeys_type = kExtkeysNone;
|
||||
// The main thread is waiting for the UI thread to call CONTINUE, so it can
|
||||
// safely access global variables.
|
||||
input->ttimeout = (bool)p_ttimeout;
|
||||
input->ttimeoutlen = p_ttm;
|
||||
input->key_buffer = rbuffer_new(KEY_BUFFER_SIZE);
|
||||
@ -372,9 +370,10 @@ static void forward_mouse_event(TermInput *input, TermKeyKey *key)
|
||||
|
||||
if (ev == TERMKEY_MOUSE_UNKNOWN && !(key->code.mouse[0] & 0x20)) {
|
||||
int code = key->code.mouse[0] & ~0x3c;
|
||||
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Other-buttons
|
||||
if (code == 66 || code == 67) {
|
||||
ev = TERMKEY_MOUSE_PRESS;
|
||||
button = code - 60;
|
||||
button = code + 4 - 64;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1143,10 +1143,11 @@ bool uc_split_args_iter(const char *arg, size_t arglen, size_t *end, char *buf,
|
||||
}
|
||||
|
||||
/// split and quote args for <f-args>
|
||||
static char *uc_split_args(char *arg, char **args, const size_t *arglens, size_t argc, size_t *lenp)
|
||||
static char *uc_split_args(const char *arg, char **args, const size_t *arglens, size_t argc,
|
||||
size_t *lenp)
|
||||
{
|
||||
char *buf;
|
||||
char *p;
|
||||
const char *p;
|
||||
char *q;
|
||||
int len;
|
||||
|
||||
@ -1229,7 +1230,7 @@ static char *uc_split_args(char *arg, char **args, const size_t *arglens, size_t
|
||||
*q++ = ' ';
|
||||
*q++ = '"';
|
||||
} else {
|
||||
mb_copy_char((const char **)&p, &q);
|
||||
mb_copy_char(&p, &q);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1242,7 +1243,7 @@ static char *uc_split_args(char *arg, char **args, const size_t *arglens, size_t
|
||||
*q++ = '\\';
|
||||
*q++ = *p++;
|
||||
} else {
|
||||
mb_copy_char((const char **)&p, &q);
|
||||
mb_copy_char(&p, &q);
|
||||
}
|
||||
}
|
||||
if (i != argc - 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user