From 53600591311a129717abd2e3bcaa302622a6ce67 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 23 Oct 2010 21:06:06 +0200 Subject: libbb: introduce and use strcpy_and_process_escape_sequences function old new delta strcpy_and_process_escape_sequences - 50 +50 bb_process_escape_sequence 148 138 -10 printf_main 789 776 -13 getty_main 1897 1831 -66 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 50/-89) Total: -39 bytes Signed-off-by: Denys Vlasenko --- loginutils/getty.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'loginutils') diff --git a/loginutils/getty.c b/loginutils/getty.c index b1cd235fb..ab55ea4b0 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -188,21 +188,9 @@ static void parse_args(char **argv, struct options *op, char **fakehost_p) &(op->login), &op->timeout); argv += optind; if (op->flags & F_INITSTRING) { - const char *p = op->initstring; - char *q; - - op->initstring = q = xstrdup(p); - /* copy optarg into op->initstring decoding \ddd - octal codes into chars */ - while (*p) { - if (*p == '\\') { - p++; - *q++ = bb_process_escape_sequence(&p); - } else { - *q++ = *p++; - } - } - *q = '\0'; + op->initstring = xstrdup(op->initstring); + /* decode \ddd octal codes into chars */ + strcpy_and_process_escape_sequences((char*)op->initstring, op->initstring); } op->flags ^= F_ISSUE; /* invert flag "show /etc/issue" */ debug("after getopt\n"); -- cgit v1.2.3