ash: use mempcpy() in more places

Most changes are taken from dash.

function                                             old     new   delta
single_quote                                         127     129      +2
stack_nputstr                                         28      29      +1
path_advance                                         209     202      -7
rmescapes                                            346     308     -38
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 3/-45)             Total: -42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-07-23 21:46:02 +02:00
parent e4f6bfd6fe
commit 5ace96a713

View File

@ -1658,7 +1658,7 @@ static char *
stack_nputstr(const char *s, size_t n, char *p)
{
p = makestrspace(n, p);
p = (char *)memcpy(p, s, n) + n;
p = (char *)mempcpy(p, s, n);
return p;
}
@ -1761,7 +1761,7 @@ single_quote(const char *s)
q = p = makestrspace(len + 3, p);
*q++ = '\'';
q = (char *)memcpy(q, s, len) + len;
q = (char *)mempcpy(q, s, len) + len;
*q++ = '\'';
s += len;
@ -1775,7 +1775,7 @@ single_quote(const char *s)
q = p = makestrspace(len + 3, p);
*q++ = '"';
q = (char *)memcpy(q, s - len, len) + len;
q = (char *)mempcpy(q, s - len, len);
*q++ = '"';
STADJUST(q - p, p);
@ -2453,8 +2453,7 @@ path_advance(const char **path, const char *name)
growstackblock();
q = stackblock();
if (p != start) {
memcpy(q, start, p - start);
q += p - start;
q = mempcpy(q, start, p - start);
*q++ = '/';
}
strcpy(q, name);
@ -5949,7 +5948,7 @@ rmescapes(char *str, int flag)
}
q = r;
if (len > 0) {
q = (char *)memcpy(q, str, len) + len;
q = (char *)mempcpy(q, str, len);
}
}