Tiny shrink (10 bytes): Re: [git commit] sed: support \r in s command

Denys Vlasenko vda.linux at googlemail.com
Wed May 4 22:27:16 UTC 2011


On Tuesday 03 May 2011 10:11, Pascal Bellard wrote:
> My 2p...
> 
>    text    data     bss     dec     hex filename
>    5899       0       0    5899    170b busybox.org/editors/sed.o
>    5889       0       0    5889    1701 busybox/editors/sed.o
> --- busybox.org/editors/sed.c   Tue May  3 00:52:22 2011
> +++ busybox/editors/sed.c       Tue May  3 09:49:54 2011
> @@ -215,12 +215,15 @@
> 
>  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');
>         /* 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;
>  }

Applied, thanks!
-- 
vda


More information about the busybox mailing list