mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor: remove some casts to char *
This commit is contained in:
@@ -204,7 +204,7 @@ static inline void clear_hist_entry(histentry_T *hisptr)
|
|||||||
/// If 'move_to_front' is true, matching entry is moved to end of history.
|
/// If 'move_to_front' is true, matching entry is moved to end of history.
|
||||||
///
|
///
|
||||||
/// @param move_to_front Move the entry to the front if it exists
|
/// @param move_to_front Move the entry to the front if it exists
|
||||||
static int in_history(int type, char *str, int move_to_front, int sep)
|
static int in_history(int type, const char *str, int move_to_front, int sep)
|
||||||
{
|
{
|
||||||
int last_i = -1;
|
int last_i = -1;
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ static int in_history(int type, char *str, int move_to_front, int sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
list_T *const list = history[type][i].additional_elements;
|
list_T *const list = history[type][i].additional_elements;
|
||||||
str = history[type][i].hisstr;
|
char *const save_hisstr = history[type][i].hisstr;
|
||||||
while (i != hisidx[type]) {
|
while (i != hisidx[type]) {
|
||||||
if (++i >= hislen) {
|
if (++i >= hislen) {
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -248,7 +248,7 @@ static int in_history(int type, char *str, int move_to_front, int sep)
|
|||||||
}
|
}
|
||||||
tv_list_unref(list);
|
tv_list_unref(list);
|
||||||
history[type][i].hisnum = ++hisnum[type];
|
history[type][i].hisnum = ++hisnum[type];
|
||||||
history[type][i].hisstr = str;
|
history[type][i].hisstr = save_hisstr;
|
||||||
history[type][i].timestamp = os_time();
|
history[type][i].timestamp = os_time();
|
||||||
history[type][i].additional_elements = NULL;
|
history[type][i].additional_elements = NULL;
|
||||||
return true;
|
return true;
|
||||||
@@ -295,7 +295,7 @@ static int last_maptick = -1; // last seen maptick
|
|||||||
/// @param histype may be one of the HIST_ values.
|
/// @param histype may be one of the HIST_ values.
|
||||||
/// @param in_map consider maptick when inside a mapping
|
/// @param in_map consider maptick when inside a mapping
|
||||||
/// @param sep separator character used (search hist)
|
/// @param sep separator character used (search hist)
|
||||||
void add_to_history(int histype, char *new_entry, int in_map, int sep)
|
void add_to_history(int histype, const char *new_entry, int in_map, int sep)
|
||||||
{
|
{
|
||||||
histentry_T *hisptr;
|
histentry_T *hisptr;
|
||||||
|
|
||||||
@@ -538,7 +538,7 @@ void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_history();
|
init_history();
|
||||||
add_to_history(histype, (char *)str, false, NUL);
|
add_to_history(histype, str, false, NUL);
|
||||||
rettv->vval.v_number = true;
|
rettv->vval.v_number = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -873,8 +873,7 @@ static void f_confirm(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
rettv->vval.v_number = do_dialog(type, NULL, (char *)message, (char *)buttons, def, NULL,
|
rettv->vval.v_number = do_dialog(type, NULL, message, buttons, def, NULL, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -389,7 +389,7 @@ typedef struct {
|
|||||||
static int string_compare(const void *s1, const void *s2) FUNC_ATTR_NONNULL_ALL
|
static int string_compare(const void *s1, const void *s2) FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (sort_lc) {
|
if (sort_lc) {
|
||||||
return strcoll((char *)s1, (char *)s2);
|
return strcoll((const char *)s1, (const char *)s2);
|
||||||
}
|
}
|
||||||
return sort_ic ? STRICMP(s1, s2) : strcmp(s1, s2);
|
return sort_ic ? STRICMP(s1, s2) : strcmp(s1, s2);
|
||||||
}
|
}
|
||||||
|
@@ -3511,8 +3511,8 @@ void msg_advance(int col)
|
|||||||
/// @param textfiel IObuff for inputdialog(), NULL otherwise
|
/// @param textfiel IObuff for inputdialog(), NULL otherwise
|
||||||
/// @param ex_cmd when true pressing : accepts default and starts Ex command
|
/// @param ex_cmd when true pressing : accepts default and starts Ex command
|
||||||
/// @returns 0 if cancelled, otherwise the nth button (1-indexed).
|
/// @returns 0 if cancelled, otherwise the nth button (1-indexed).
|
||||||
int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutton, char *textfield,
|
int do_dialog(int type, const char *title, const char *message, const char *buttons, int dfltbutton,
|
||||||
int ex_cmd)
|
const char *textfield, int ex_cmd)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
char *hotkeys;
|
char *hotkeys;
|
||||||
@@ -3619,7 +3619,7 @@ static int copy_char(const char *from, char *to, bool lowercase)
|
|||||||
/// corresponding button has a hotkey
|
/// corresponding button has a hotkey
|
||||||
///
|
///
|
||||||
/// @return Pointer to memory allocated for storing hotkeys
|
/// @return Pointer to memory allocated for storing hotkeys
|
||||||
static char *console_dialog_alloc(const char *message, char *buttons, bool has_hotkey[])
|
static char *console_dialog_alloc(const char *message, const char *buttons, bool has_hotkey[])
|
||||||
{
|
{
|
||||||
int lenhotkey = HOTK_LEN; // count first button
|
int lenhotkey = HOTK_LEN; // count first button
|
||||||
has_hotkey[0] = false;
|
has_hotkey[0] = false;
|
||||||
@@ -3627,7 +3627,7 @@ static char *console_dialog_alloc(const char *message, char *buttons, bool has_h
|
|||||||
// Compute the size of memory to allocate.
|
// Compute the size of memory to allocate.
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
char *r = buttons;
|
const char *r = buttons;
|
||||||
while (*r) {
|
while (*r) {
|
||||||
if (*r == DLG_BUTTON_SEP) {
|
if (*r == DLG_BUTTON_SEP) {
|
||||||
len += 3; // '\n' -> ', '; 'x' -> '(x)'
|
len += 3; // '\n' -> ', '; 'x' -> '(x)'
|
||||||
@@ -3673,7 +3673,7 @@ static char *console_dialog_alloc(const char *message, char *buttons, bool has_h
|
|||||||
/// The hotkeys can be multi-byte characters, but without combining chars.
|
/// The hotkeys can be multi-byte characters, but without combining chars.
|
||||||
///
|
///
|
||||||
/// @return an allocated string with hotkeys.
|
/// @return an allocated string with hotkeys.
|
||||||
static char *msg_show_console_dialog(char *message, char *buttons, int dfltbutton)
|
static char *msg_show_console_dialog(const char *message, const char *buttons, int dfltbutton)
|
||||||
FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
bool has_hotkey[HAS_HOTKEY_LEN] = { false };
|
bool has_hotkey[HAS_HOTKEY_LEN] = { false };
|
||||||
@@ -3693,7 +3693,7 @@ static char *msg_show_console_dialog(char *message, char *buttons, int dfltbutto
|
|||||||
/// @param has_hotkey An element in this array is true if corresponding button
|
/// @param has_hotkey An element in this array is true if corresponding button
|
||||||
/// has a hotkey
|
/// has a hotkey
|
||||||
/// @param[out] hotkeys_ptr Pointer to the memory location where hotkeys will be copied
|
/// @param[out] hotkeys_ptr Pointer to the memory location where hotkeys will be copied
|
||||||
static void copy_hotkeys_and_msg(const char *message, char *buttons, int default_button_idx,
|
static void copy_hotkeys_and_msg(const char *message, const char *buttons, int default_button_idx,
|
||||||
const bool has_hotkey[], char *hotkeys_ptr)
|
const bool has_hotkey[], char *hotkeys_ptr)
|
||||||
{
|
{
|
||||||
*confirm_msg = '\n';
|
*confirm_msg = '\n';
|
||||||
@@ -3716,7 +3716,7 @@ static void copy_hotkeys_and_msg(const char *message, char *buttons, int default
|
|||||||
}
|
}
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
char *r = buttons;
|
const char *r = buttons;
|
||||||
while (*r) {
|
while (*r) {
|
||||||
if (*r == DLG_BUTTON_SEP) {
|
if (*r == DLG_BUTTON_SEP) {
|
||||||
*msgp++ = ',';
|
*msgp++ = ',';
|
||||||
|
@@ -1810,7 +1810,7 @@ bool path_with_extension(const char *path, const char *extension)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if "name" is a full (absolute) path name or URL.
|
/// Return true if "name" is a full (absolute) path name or URL.
|
||||||
bool vim_isAbsName(char *name)
|
bool vim_isAbsName(const char *name)
|
||||||
{
|
{
|
||||||
return path_with_url(name) != 0 || path_is_absolute(name);
|
return path_with_url(name) != 0 || path_is_absolute(name);
|
||||||
}
|
}
|
||||||
@@ -1871,7 +1871,7 @@ char *fix_fname(const char *fname)
|
|||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
return FullName_save(fname, true);
|
return FullName_save(fname, true);
|
||||||
#else
|
#else
|
||||||
if (!vim_isAbsName((char *)fname)
|
if (!vim_isAbsName(fname)
|
||||||
|| strstr(fname, "..") != NULL
|
|| strstr(fname, "..") != NULL
|
||||||
|| strstr(fname, "//") != NULL
|
|| strstr(fname, "//") != NULL
|
||||||
# ifdef BACKSLASH_IN_FILENAME
|
# ifdef BACKSLASH_IN_FILENAME
|
||||||
|
@@ -248,8 +248,8 @@ StlClickDefinition *stl_alloc_click_defs(StlClickDefinition *cdp, long width, si
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fill the click definitions array if needed.
|
/// Fill the click definitions array if needed.
|
||||||
void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_recs, char *buf,
|
void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_recs,
|
||||||
int width, bool tabline)
|
const char *buf, int width, bool tabline)
|
||||||
{
|
{
|
||||||
if (click_defs == NULL) {
|
if (click_defs == NULL) {
|
||||||
return;
|
return;
|
||||||
@@ -270,7 +270,7 @@ void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_r
|
|||||||
} else {
|
} else {
|
||||||
xfree(cur_click_def.func);
|
xfree(cur_click_def.func);
|
||||||
}
|
}
|
||||||
buf = (char *)click_recs[i].start;
|
buf = click_recs[i].start;
|
||||||
cur_click_def = click_recs[i].def;
|
cur_click_def = click_recs[i].def;
|
||||||
if (!tabline && !(cur_click_def.type == kStlClickDisabled
|
if (!tabline && !(cur_click_def.type == kStlClickDisabled
|
||||||
|| cur_click_def.type == kStlClickFuncRun)) {
|
|| cur_click_def.type == kStlClickFuncRun)) {
|
||||||
@@ -2077,9 +2077,9 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
|
|||||||
// to be moved backwards.
|
// to be moved backwards.
|
||||||
if (stl_items[i].start >= trunc_end_p) {
|
if (stl_items[i].start >= trunc_end_p) {
|
||||||
stl_items[i].start -= item_offset;
|
stl_items[i].start -= item_offset;
|
||||||
|
} else {
|
||||||
// Anything inside the truncated area is set to start
|
// Anything inside the truncated area is set to start
|
||||||
// at the `<` truncation character.
|
// at the `<` truncation character.
|
||||||
} else {
|
|
||||||
stl_items[i].start = trunc_p;
|
stl_items[i].start = trunc_p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user