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 18:16:01 +02:00
parent 82cfedab50
commit 9c3edbe2c1
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_putchar(' ');
} }
msg_outtrans((char *)string); msg_outtrans(string);
if (type == VAR_FUNC || type == VAR_PARTIAL) { if (type == VAR_FUNC || type == VAR_PARTIAL) {
msg_puts("()"); msg_puts("()");

View File

@@ -4745,7 +4745,7 @@ void ex_oldfiles(exarg_T *eap)
if (!message_filtered(fname)) { if (!message_filtered(fname)) {
msg_outnum(nr); msg_outnum(nr);
msg_puts(": "); 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_clr_eos();
msg_putchar('\n'); msg_putchar('\n');
os_breakcheck(); 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(name, HL_ATTR(HLF_D));
msg_puts_attr("=", HL_ATTR(HLF_D)); msg_puts_attr("=", HL_ATTR(HLF_D));
} }
msg_outtrans((char *)ts); msg_outtrans(ts);
} }
return didh; return didh;
} }

View File

@@ -1488,17 +1488,17 @@ void msg_outnum(long n)
msg_puts(buf); msg_puts(buf);
} }
void msg_home_replace(char *fname) void msg_home_replace(const char *fname)
{ {
msg_home_replace_attr(fname, 0); 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)); 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); char *name = home_replace_save(NULL, fname);
msg_outtrans_attr(name, attr); msg_outtrans_attr(name, attr);
@@ -1510,7 +1510,7 @@ static void msg_home_replace_attr(char *fname, int attr)
/// Use attributes 'attr'. /// Use attributes 'attr'.
/// ///
/// @return the number of characters it takes on the screen. /// @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); return msg_outtrans_attr(str, 0);
} }
@@ -1529,7 +1529,7 @@ int msg_outtrans_len(const char *str, int len)
/// Handles multi-byte characters. /// Handles multi-byte characters.
/// ///
/// @return pointer to the next character. /// @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; int l;
@@ -1616,11 +1616,11 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
return retval; return retval;
} }
void msg_make(char *arg) void msg_make(const char *arg)
{ {
int i; int i;
static char *str = "eeffoc"; static const char *str = "eeffoc";
static char *rs = "Plon#dqg#vxjduB"; static const char *rs = "Plon#dqg#vxjduB";
arg = skipwhite(arg); arg = skipwhite(arg);
for (i = 5; *arg && i >= 0; i--) { 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 /// 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 c;
int col = 0; int col = 0;
int n_extra = 0; int n_extra = 0;
int c_extra = 0; int c_extra = 0;
int c_final = 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 n;
int attr = 0; int attr = 0;
char *lead = NULL; const char *lead = NULL;
bool in_multispace = false; bool in_multispace = false;
int multispace_pos = 0; int multispace_pos = 0;
char *trail = NULL; const char *trail = NULL;
int l; int l;
if (curwin->w_p_list) { 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 /// 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. /// part in the middle and replace it with "..." when necessary.
/// Does not handle multi-byte characters! /// 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); 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 slen = len;
int room; 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) { 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); 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) { if (!one) {
src = skipwhite((char *)src); src = skipwhite(src);
} }
char *dst_p = dst; char *dst_p = dst;
while (*src && dstlen > 0) { 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. // Failed, probably 'shell' is not executable.
if (!silent) { if (!silent) {
msg_puts(_("\nshell failed to start: ")); msg_puts(_("\nshell failed to start: "));
msg_outtrans((char *)os_strerror(status)); msg_outtrans(os_strerror(status));
msg_puts(": "); msg_puts(": ");
msg_outtrans(prog); msg_outtrans(prog);
msg_putchar('\n'); 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); 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; taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx; int tagstackidx = curwin->w_tagstackidx;
char *p; const char *p;
char *command_end; const char *command_end;
tagptrs_T tagp; tagptrs_T tagp;
int taglen; int taglen;
int attr; int attr;