refactor: Replace vim_strcat() with xstrlcat().

This commit is contained in:
Justin M. Keyes 2017-01-23 14:34:47 +01:00
parent 6c467f3f7e
commit 7e799b6e91
5 changed files with 8 additions and 25 deletions

View File

@ -1544,8 +1544,8 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
/* Look for named resource file in runtimepath */
STRCPY(buffer, "print");
add_pathsep((char *)buffer);
vim_strcat(buffer, (char_u *)name, MAXPATHL);
vim_strcat(buffer, (char_u *)".ps", MAXPATHL);
xstrlcat((char *)buffer, name, MAXPATHL);
xstrlcat((char *)buffer, ".ps", MAXPATHL);
resource->filename[0] = NUL;
retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename)
&& resource->filename[0] != NUL);

View File

@ -2507,8 +2507,9 @@ void msgmore(long n)
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
_("%" PRId64 " fewer lines"), (int64_t)pn);
}
if (got_int)
vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN);
if (got_int) {
xstrlcat((char *)msg_buf, _(" (Interrupted)"), MSG_BUF_LEN);
}
if (msg(msg_buf)) {
set_keep_msg(msg_buf, 0);
keep_msg_more = TRUE;

View File

@ -2126,7 +2126,7 @@ static void qf_msg(qf_info_T *qi, int which, char *lead)
memset(buf + len, ' ', 34 - len);
buf[34] = NUL;
}
vim_strcat(buf, (char_u *)title, IOSIZE);
xstrlcat((char *)buf, title, IOSIZE);
}
trunc_string(buf, buf, (int)Columns - 1, IOSIZE);
msg(buf);

View File

@ -344,24 +344,6 @@ void del_trailing_spaces(char_u *ptr)
*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))
/*
* Compare two strings, ignoring case, using current locale.

View File

@ -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) {
if (iarg & hl_attr_table[i]) {
if (buf[0] != NUL)
vim_strcat(buf, (char_u *)",", 100);
vim_strcat(buf, (char_u *)hl_name_table[i], 100);
xstrlcat((char *)buf, ",", 100);
xstrlcat((char *)buf, hl_name_table[i], 100);
iarg &= ~hl_attr_table[i]; /* don't want "inverse" */
}
}