mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: Replace vim_strcat() with xstrlcat().
This commit is contained in:
parent
6c467f3f7e
commit
7e799b6e91
@ -1544,8 +1544,8 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
|
|||||||
/* Look for named resource file in runtimepath */
|
/* Look for named resource file in runtimepath */
|
||||||
STRCPY(buffer, "print");
|
STRCPY(buffer, "print");
|
||||||
add_pathsep((char *)buffer);
|
add_pathsep((char *)buffer);
|
||||||
vim_strcat(buffer, (char_u *)name, MAXPATHL);
|
xstrlcat((char *)buffer, name, MAXPATHL);
|
||||||
vim_strcat(buffer, (char_u *)".ps", MAXPATHL);
|
xstrlcat((char *)buffer, ".ps", MAXPATHL);
|
||||||
resource->filename[0] = NUL;
|
resource->filename[0] = NUL;
|
||||||
retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename)
|
retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename)
|
||||||
&& resource->filename[0] != NUL);
|
&& resource->filename[0] != NUL);
|
||||||
|
@ -2507,8 +2507,9 @@ void msgmore(long n)
|
|||||||
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
|
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
|
||||||
_("%" PRId64 " fewer lines"), (int64_t)pn);
|
_("%" PRId64 " fewer lines"), (int64_t)pn);
|
||||||
}
|
}
|
||||||
if (got_int)
|
if (got_int) {
|
||||||
vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN);
|
xstrlcat((char *)msg_buf, _(" (Interrupted)"), MSG_BUF_LEN);
|
||||||
|
}
|
||||||
if (msg(msg_buf)) {
|
if (msg(msg_buf)) {
|
||||||
set_keep_msg(msg_buf, 0);
|
set_keep_msg(msg_buf, 0);
|
||||||
keep_msg_more = TRUE;
|
keep_msg_more = TRUE;
|
||||||
|
@ -2126,7 +2126,7 @@ static void qf_msg(qf_info_T *qi, int which, char *lead)
|
|||||||
memset(buf + len, ' ', 34 - len);
|
memset(buf + len, ' ', 34 - len);
|
||||||
buf[34] = NUL;
|
buf[34] = NUL;
|
||||||
}
|
}
|
||||||
vim_strcat(buf, (char_u *)title, IOSIZE);
|
xstrlcat((char *)buf, title, IOSIZE);
|
||||||
}
|
}
|
||||||
trunc_string(buf, buf, (int)Columns - 1, IOSIZE);
|
trunc_string(buf, buf, (int)Columns - 1, IOSIZE);
|
||||||
msg(buf);
|
msg(buf);
|
||||||
|
@ -344,24 +344,6 @@ void del_trailing_spaces(char_u *ptr)
|
|||||||
*q = NUL;
|
*q = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Like strcat(), but make sure the result fits in "tosize" bytes and is
|
|
||||||
* always NUL terminated.
|
|
||||||
*/
|
|
||||||
void vim_strcat(char_u *restrict to, const char_u *restrict from,
|
|
||||||
size_t tosize)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
|
||||||
{
|
|
||||||
size_t tolen = STRLEN(to);
|
|
||||||
size_t fromlen = STRLEN(from);
|
|
||||||
|
|
||||||
if (tolen + fromlen + 1 > tosize) {
|
|
||||||
memcpy(to + tolen, from, tosize - tolen - 1);
|
|
||||||
to[tosize - 1] = NUL;
|
|
||||||
} else
|
|
||||||
STRCPY(to + tolen, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP))
|
#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP))
|
||||||
/*
|
/*
|
||||||
* Compare two strings, ignoring case, using current locale.
|
* Compare two strings, ignoring case, using current locale.
|
||||||
|
@ -6902,8 +6902,8 @@ static int highlight_list_arg(int id, int didh, int type, int iarg, char_u *sarg
|
|||||||
for (i = 0; hl_attr_table[i] != 0; ++i) {
|
for (i = 0; hl_attr_table[i] != 0; ++i) {
|
||||||
if (iarg & hl_attr_table[i]) {
|
if (iarg & hl_attr_table[i]) {
|
||||||
if (buf[0] != NUL)
|
if (buf[0] != NUL)
|
||||||
vim_strcat(buf, (char_u *)",", 100);
|
xstrlcat((char *)buf, ",", 100);
|
||||||
vim_strcat(buf, (char_u *)hl_name_table[i], 100);
|
xstrlcat((char *)buf, hl_name_table[i], 100);
|
||||||
iarg &= ~hl_attr_table[i]; /* don't want "inverse" */
|
iarg &= ~hl_attr_table[i]; /* don't want "inverse" */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user