[BusyBox] tar bug and tr -s patch
Matt Kraai
kraai at alumni.carnegiemellon.edu
Wed Dec 6 22:27:42 UTC 2000
On Wed, Dec 06, 2000 at 01:21:19PM -0800, kent robotti wrote:
> This problem was reported last month in
> this list, tr doesn't squeeze repeats.
>
> # cat file
> 1 2 3
>
> # tr -s " " < file
> 1 2 3
>
> It's supposed to output this.
> 1 2 3
>
> This is a patch to fix the problem, don't know
> if it's the correct way to do it.
>
> --- tr.c.orig Mon Sep 25 21:58:01 2000
> +++ tr.c Wed Dec 6 21:06:59 2000
> @@ -70,7 +70,7 @@
> coded = vector[c];
> if (del_fl && invec[c])
> continue;
> - if (sq_fl && last == coded && outvec[coded])
> + if (sq_fl && last == coded && invec[coded])
> continue;
> output[out_index++] = last = coded;
> if (out_index == BUFSIZ) {
This doesn't work for the following case:
echo aa | tr -s b a
GNU tr, and the current busybox tr, produce a single a. With your patch
two are output. I think the following patch should work.
--- tr.c 2000/09/25 21:45:58 1.15
+++ tr.c 2000/12/06 22:23:57
@@ -70,7 +63,7 @@
coded = vector[c];
if (del_fl && invec[c])
continue;
- if (sq_fl && last == coded && outvec[coded])
+ if (sq_fl && last == coded && (invec[c] || outvec[coded]))
continue;
output[out_index++] = last = coded;
if (out_index == BUFSIZ) {
Matt
More information about the busybox
mailing list