Denys Vlasenko schrieb:
> On Friday 20 February 2009 04:06:30 pm walter harms wrote:
>> Hi List,
>> i was traceing a bug and found that tr (bb 13.0) seems to have a bug:
>>
>>
>> echo "19AFH" |./tr -cd "[0-9]"
>> 19
>>
>> echo "19AFH" |./tr -cd "[0-9A-F]"
>> bash: echo: write error: Datenübergabe unterbrochen (broken pipe)
>
> You do not show that tr complains about bad command format
> (by showing usage screen). Is it a test in telepathy,
> or do you compigured out help text? (that't why
> attaching your .config isn't such a bad idea).
>
>
>> ./tr -cd "[0-9A-F]" <xx
>> echo $?
>> 1
>> reading from a file seems to indicate an error ?
>
> I see this:
>
> # ./busybox tr -cd "[0-9A-F]" <AUTHORS; echo $?
> BusyBox v1.14.0.svn (2009-03-01 04:13:26 CET) multi-call binary
>
> Usage: tr [-cds] STRING1 [STRING2]
>
> Translate, squeeze, and/or delete characters from
> standard input, writing to standard output
>
> Options:
> -c Take complement of STRING1
> -d Delete input characters coded STRING1
> -s Squeeze multiple output characters of STRING2 into one
> character
>
> 1
>
> So, no, reading from a file does not indicate the error,
> the error here is that tr misinterprets "[0-9A-F]"
>
>> (echo "19AFH" |./tr -cd "[0-9A-F]" works fine with gnu tr)
>>
>> btw: my first version was echo "19AFH" |./tr -cd "[:xdigit:]" what simply
>> eats anything.
>
> Try attached patch, it fixes all these problems in my testing.
I have tested the patch and it seems to work ok.
[:xdigit:] seems to work
While testing i noticed that tr -dc [z-A] behaver differs from GNU tr
GNU:
tr -dc [z-A]
tr: range-endpoints of `z-A' are in reverse collating sequence order
therefor i suggest a patch like that:
--- coreutils/tr.c.org 2009-03-15 16:07:41.000000000 +0100
+++ coreutils/tr.c 2009-03-15 16:14:06.000000000 +0100
@@ -62,6 +62,9 @@
continue; /* next iter will copy '-' and stop */
}
i = *arg;
+ if (arg[0]>arg[3])
+ bb_error_msg_and_die("Endpoints in reverse order");
+
while (i <= ac) /* ok: i is unsigned _int_ */
*buffer++ = i++;
arg += 3; /* skip 0-9 */
It should be noted that the -C (Upper C) is not supported.
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -C , [:graph:], [:print:] not
supported*/
hope that helps,
re,
wh
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox