summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Bellard <pascal.bellard@ads-lu.com>2011-05-04 22:26:37 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2011-05-04 22:26:37 (GMT)
commitd3e4be3ccb1506cfabecc4c2f0baeb07fdd06723 (patch)
treeb09e5ca17445c0e1a8ca41d0a0729768279e79fe
parent14b162f9ab2c34cf5ffc9f5c8e9f90d58e8445eb (diff)
downloadbusybox-d3e4be3ccb1506cfabecc4c2f0baeb07fdd06723.tar.gz
busybox-d3e4be3ccb1506cfabecc4c2f0baeb07fdd06723.tar.bz2
sed: shrink by 17 bytes
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/sed.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 11c4763..99e56ff 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -215,12 +215,16 @@ static void parse_escapes(char *dest, const char *string, int len, char from, ch
static char *copy_parsing_escapes(const char *string, int len)
{
+ const char *s;
char *dest = xmalloc(len + 1);
- parse_escapes(dest, string, len, 'n', '\n');
+ /* sed recognizes \n */
/* GNU sed also recognizes \t and \r */
- parse_escapes(dest, dest, strlen(dest), 't', '\t');
- parse_escapes(dest, dest, strlen(dest), 'r', '\r');
+ for (s = "\nn\tt\rr"; *s; s += 2) {
+ parse_escapes(dest, string, len, s[1], s[0]);
+ string = dest;
+ len = strlen(dest);
+ }
return dest;
}