Bug in wc.
walter harms
wharms at bfs.de
Mon Mar 8 17:10:02 UTC 2010
Michael Abbott schrieb:
> On Sun, 7 Mar 2010, Rob Landley wrote:
>> [...]
>> The underlying behavioral wonkiness in busybox "cut" is:
>>
>> $ busybox wc -c vmlinux
>> 3335777 vmlinux
>> $ wc -c vmlinux
>> 3335777 vmlinux
>>
>> Note that we have leading whitespace, the gnu version doesn't. [...]
>>
>> Why do we have unnecessary leading whitespace? What happend to small
>> and simple and doing no more than absolutely necessary?
>
> Presumably the code contains a format string of the form "% 9d"
> written like that so the output looks pretty on multiple files.
>
> In fact, that's got to be the case. Look at the frankly horrible thing
> that gnu wc does on multiple files:
>
> $ wc -c wc.c yes.c
> 4974 wc.c
> 823 yes.c
> 5797 total
> $
>
> There must be code in gnu wc to remember the maximum count length and
> format accordingly, so what busybox does is indeed simpler ... but not
> quite clever enough it would seem
>
> I'm sure the 9-space formatting would suffice for multiple outputs, but
> clearly for a single file it has to be avoided. Afraid I'm too witless
> today to work up a patch, but it should be easy enough.
perhaps it is more easy adding a 'tr -s " "' to the linux kernel build script ?
that would leave only one space to worry about no matter how much there where
originaly.
re,
wh
More information about the busybox
mailing list