sed: shrink by 17 bytes
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
14b162f9ab
commit
d3e4be3ccb
@ -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)
|
static char *copy_parsing_escapes(const char *string, int len)
|
||||||
{
|
{
|
||||||
|
const char *s;
|
||||||
char *dest = xmalloc(len + 1);
|
char *dest = xmalloc(len + 1);
|
||||||
|
|
||||||
parse_escapes(dest, string, len, 'n', '\n');
|
/* sed recognizes \n */
|
||||||
/* GNU sed also recognizes \t and \r */
|
/* GNU sed also recognizes \t and \r */
|
||||||
parse_escapes(dest, dest, strlen(dest), 't', '\t');
|
for (s = "\nn\tt\rr"; *s; s += 2) {
|
||||||
parse_escapes(dest, dest, strlen(dest), 'r', '\r');
|
parse_escapes(dest, string, len, s[1], s[0]);
|
||||||
|
string = dest;
|
||||||
|
len = strlen(dest);
|
||||||
|
}
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user