aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/cmdexpand.c10
-rw-r--r--src/nvim/ops.c10
2 files changed, 11 insertions, 9 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 38be6573c8..aef471a17b 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -899,7 +899,6 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
// Concatenate all matching names. Unless interrupted, this can be slow
// and the result probably won't be used.
- // TODO(philix): use xstpcpy instead of strcat in a loop (ExpandOne)
if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int) {
size_t len = 0;
for (int i = 0; i < xp->xp_numfiles; i++) {
@@ -914,18 +913,19 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
}
ss = xmalloc(len);
*ss = NUL;
+ char *ssp = ss;
for (int i = 0; i < xp->xp_numfiles; i++) {
if (i > 0) {
if (xp->xp_prefix == XP_PREFIX_NO) {
- STRCAT(ss, "no");
+ ssp = xstpcpy(ssp, "no");
} else if (xp->xp_prefix == XP_PREFIX_INV) {
- STRCAT(ss, "inv");
+ ssp = xstpcpy(ssp, "inv");
}
}
- STRCAT(ss, xp->xp_files[i]);
+ ssp = xstpcpy(ssp, xp->xp_files[i]);
if (i != xp->xp_numfiles - 1) {
- STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " ");
+ ssp = xstpcpy(ssp, (options & WILD_USE_NL) ? "\n" : " ");
}
}
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index f4eaf3a320..cb8d1dabc0 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -983,10 +983,12 @@ static int stuff_yank(int regname, char *p)
yankreg_T *reg = get_yank_register(regname, YREG_YANK);
if (is_append_register(regname) && reg->y_array != NULL) {
char **pp = &(reg->y_array[reg->y_size - 1]);
- char *lp = xmalloc(strlen(*pp) + strlen(p) + 1);
- STRCPY(lp, *pp);
- // TODO(philix): use xstpcpy() in stuff_yank()
- STRCAT(lp, p);
+ const size_t ppl = strlen(*pp);
+ const size_t pl = strlen(p);
+ char *lp = xmalloc(ppl + pl + 1);
+ memcpy(lp, *pp, ppl);
+ memcpy(lp + ppl, p, pl);
+ *(lp + ppl + pl) = NUL;
xfree(p);
xfree(*pp);
*pp = lp;