[PATCH] diff: rewrite V2. -1005 bytes

Matheus Izvekov mizvekov at gmail.com
Fri Jan 15 02:19:43 UTC 2010


On 02:31 Fri 15 Jan     , Denys Vlasenko wrote:
> 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

Try two files which are otherwise the same except:
one ends without a newline, and that last character is not a space
b ends with any space character.

So for example:
echo -n "oi" > a

echo -n "oi " > b
or even
echo "oi" > b

and then diff both with flag -b
current busybox does not handle this correctly.


More information about the busybox mailing list