[MERGE][1.0] update C PatienceDiff to allow for non-strings
John Arbash Meinel
john at arbash-meinel.com
Wed Dec 19 15:11:09 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lukáš Lalinský wrote:
> On St, 2007-12-05 at 09:28 -0600, John Arbash Meinel wrote:
>> - const char *data;
>> + const PyObject *data;
>
> I think this should be just PyObject *, to avoid the const -> non-const
> type casting below.
'const' seems more correct, from a "the data should be treated as const"
standpoint. It is just that "PyObject_Compare" should take const pointers.
Though could there be side-effects from Compare?
Anyway, I'm willing to change it.
>
>> @@ -151,8 +151,8 @@
>> static inline int
>> compare_lines(struct line *a, struct line *b)
>> {
>> - return ((a->hash != b->hash) || (a->len != b->len) ||
>> - memcmp(a->data, b->data, a->len));
>> + return ((a->hash != b->hash) || (a->len != b->len)
>> + || PyObject_Compare((PyObject *)a->data, (PyObject *)b->data));
>> }
>
...
> This is incorrect. The code above might generate hash -1 and the hash is
> still valid. It should fail only if -1 is returned from PyObject_Hash.
>
> Lukas
Thanks for catching it.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHaTSNJdeBCYSNAAMRAtEOAJ9L/GH2Nc5X0oJppvxpmpVLGkOpawCgvV5q
99xHTBRgowYNKeXCh5BD4u0=
=k7GT
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list