summaryrefslogtreecommitdiffhomepage
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-24 02:17:05 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-24 02:17:05 +0200
commit0675b03de44b75f5f5fc7a54c164628e9ee01e9c (patch)
tree462d77c8a4e44b349c4d1ebd454a3aeb6fcee3a6 /shell
parent94af83eb8d92252339098b37826768b610e3e34b (diff)
hush: use mempcpy where useful
function old new delta o_addblock 58 42 -16 expand_one_var 1618 1555 -63 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-79) Total: -79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 170d5f33b..309ed2139 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2662,9 +2662,8 @@ static void o_delchr(o_string *o)
static void o_addblock(o_string *o, const char *str, int len)
{
o_grow_by(o, len);
- memcpy(&o->data[o->length], str, len);
+ ((char*)mempcpy(&o->data[o->length], str, len))[0] = '\0';
o->length += len;
- o->data[o->length] = '\0';
}
static void o_addstr(o_string *o, const char *str)
@@ -5519,17 +5518,15 @@ static char *replace_pattern(char *val, const char *pattern, const char *repl, c
break;
result = xrealloc(result, res_len + (s - val) + repl_len + 1);
- memcpy(result + res_len, val, s - val);
- res_len += s - val;
- strcpy(result + res_len, repl);
- res_len += repl_len;
+ strcpy(mempcpy(result + res_len, val, s - val), repl);
+ res_len += (s - val) + repl_len;
debug_printf_varexp("val:'%s' s:'%s' result:'%s'\n", val, s, result);
val = s + size;
if (exp_op == '/')
break;
}
- if (val[0] && result) {
+ if (*val && result) {
result = xrealloc(result, res_len + strlen(val) + 1);
strcpy(result + res_len, val);
debug_printf_varexp("val:'%s' result:'%s'\n", val, result);