From 5ace96a71304c2d5d3b8b864df9b4b8ca40f417c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 23 Jul 2017 21:46:02 +0200 Subject: 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 --- shell/ash.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index c8b2adf4e..fa03f8a4e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -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); } } -- cgit v1.2.3