refactor: make char * parameters const in message.c

Add const to char * parameters in message.c functions and remove some
redundant casts.
This commit is contained in:
ii14
2023-04-07 19:39:04 +02:00
committed by GitHub
parent d675bd01b1
commit 1d2a29f75b
8 changed files with 23 additions and 23 deletions

View File

@@ -1206,7 +1206,7 @@ static void list_one_var_a(const char *prefix, const char *name, const ptrdiff_t
msg_putchar(' ');
}
msg_outtrans((char *)string);
msg_outtrans(string);
if (type == VAR_FUNC || type == VAR_PARTIAL) {
msg_puts("()");

View File

@@ -4745,7 +4745,7 @@ void ex_oldfiles(exarg_T *eap)
if (!message_filtered(fname)) {
msg_outnum(nr);
msg_puts(": ");
msg_outtrans((char *)tv_get_string(TV_LIST_ITEM_TV(li)));
msg_outtrans(tv_get_string(TV_LIST_ITEM_TV(li)));
msg_clr_eos();
msg_putchar('\n');
os_breakcheck();

View File

@@ -1639,7 +1639,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
msg_puts_attr(name, HL_ATTR(HLF_D));
msg_puts_attr("=", HL_ATTR(HLF_D));
}
msg_outtrans((char *)ts);
msg_outtrans(ts);
}
return didh;
}

View File

@@ -1488,17 +1488,17 @@ void msg_outnum(long n)
msg_puts(buf);
}
void msg_home_replace(char *fname)
void msg_home_replace(const char *fname)
{
msg_home_replace_attr(fname, 0);
}
void msg_home_replace_hl(char *fname)
void msg_home_replace_hl(const char *fname)
{
msg_home_replace_attr(fname, HL_ATTR(HLF_D));
}
static void msg_home_replace_attr(char *fname, int attr)
static void msg_home_replace_attr(const char *fname, int attr)
{
char *name = home_replace_save(NULL, fname);
msg_outtrans_attr(name, attr);
@@ -1510,7 +1510,7 @@ static void msg_home_replace_attr(char *fname, int attr)
/// Use attributes 'attr'.
///
/// @return the number of characters it takes on the screen.
int msg_outtrans(char *str)
int msg_outtrans(const char *str)
{
return msg_outtrans_attr(str, 0);
}
@@ -1529,7 +1529,7 @@ int msg_outtrans_len(const char *str, int len)
/// Handles multi-byte characters.
///
/// @return pointer to the next character.
char *msg_outtrans_one(char *p, int attr)
const char *msg_outtrans_one(const char *p, int attr)
{
int l;
@@ -1616,11 +1616,11 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
return retval;
}
void msg_make(char *arg)
void msg_make(const char *arg)
{
int i;
static char *str = "eeffoc";
static char *rs = "Plon#dqg#vxjduB";
static const char *str = "eeffoc";
static const char *rs = "Plon#dqg#vxjduB";
arg = skipwhite(arg);
for (i = 5; *arg && i >= 0; i--) {
@@ -1806,20 +1806,20 @@ void str2specialbuf(const char *sp, char *buf, size_t len)
}
/// print line for :print or :list command
void msg_prt_line(char *s, int list)
void msg_prt_line(const char *s, int list)
{
int c;
int col = 0;
int n_extra = 0;
int c_extra = 0;
int c_final = 0;
char *p_extra = NULL; // init to make SASC shut up
const char *p_extra = NULL; // init to make SASC shut up
int n;
int attr = 0;
char *lead = NULL;
const char *lead = NULL;
bool in_multispace = false;
int multispace_pos = 0;
char *trail = NULL;
const char *trail = NULL;
int l;
if (curwin->w_p_list) {
@@ -2011,12 +2011,12 @@ void msg_puts_title(const char *s)
/// Show a message in such a way that it always fits in the line. Cut out a
/// part in the middle and replace it with "..." when necessary.
/// Does not handle multi-byte characters!
void msg_outtrans_long_attr(char *longstr, int attr)
void msg_outtrans_long_attr(const char *longstr, int attr)
{
msg_outtrans_long_len_attr(longstr, (int)strlen(longstr), attr);
}
void msg_outtrans_long_len_attr(char *longstr, int len, int attr)
void msg_outtrans_long_len_attr(const char *longstr, int len, int attr)
{
int slen = len;
int room;

View File

@@ -1060,7 +1060,7 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
}
if (buf != NULL && buf->b_help) {
const size_t dlen = xstrlcpy(dst, path_tail((char *)src), dstlen);
const size_t dlen = xstrlcpy(dst, path_tail(src), dstlen);
return MIN(dlen, dstlen - 1);
}
@@ -1098,7 +1098,7 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
}
if (!one) {
src = skipwhite((char *)src);
src = skipwhite(src);
}
char *dst_p = dst;
while (*src && dstlen > 0) {

View File

@@ -876,7 +876,7 @@ static int do_os_system(char **argv, const char *input, size_t len, char **outpu
// Failed, probably 'shell' is not executable.
if (!silent) {
msg_puts(_("\nshell failed to start: "));
msg_outtrans((char *)os_strerror(status));
msg_outtrans(os_strerror(status));
msg_puts(": ");
msg_outtrans(prog);
msg_putchar('\n');

View File

@@ -3643,7 +3643,7 @@ static bool syn_list_keywords(const int id, const hashtab_T *const ht, bool did_
prev_skipempty = (kp->flags & HL_SKIPEMPTY);
}
}
msg_outtrans((char *)kp->keyword);
msg_outtrans(kp->keyword);
}
}
}

View File

@@ -795,8 +795,8 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
{
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
char *p;
char *command_end;
const char *p;
const char *command_end;
tagptrs_T tagp;
int taglen;
int attr;