[PATCH] diff: rewrite V2. -1005 bytes

Denys Vlasenko vda.linux at googlemail.com
Fri Jan 15 01:31:27 UTC 2010


On Friday 15 January 2010 01:47, Matheus Izvekov wrote:
> > > The bug would be that when flag -b is set, and an EOF comes, the caller
> > > would see token 0xffffff20 instead of 0x20.
> > 
> > It would see tok == TOK_PRINT + TOK_EOF + TOK_EOL + TOK_SPACE + 0x20,
> > not 0xffffff20.
> > 
> 
> And then TOK2CHAR would convert that to 0xffffff20 instead of 0x20.
> 
> #define TOK2CHAR(t) (((t) << SHIFT_EOF) >> SHIFT_EOF)
> 
> SHIFT_EOF = (sizeof(token_t)*8 - 8) - 1 = 23
> 
> so (int)0x120 << 23 >> 23 = 0xffffff20 because of the sign extension.

Yep. I see now.

Do you have a real examples of files F1 and F2 where
it breaks "diff -ub F1 F2"? I want to add such an interesting
corner case to the testsuite.

--
vda


More information about the busybox mailing list