On Fri, Apr 25, 2008 at 08:13:45PM +0200, Justus Winter wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
It's hard to get anything past you guys... revised patches are attached.
By the way, if you still think there's something wrong with them, please adjust them accordingly (like checking the return value of snprintf, reducing the size of buf (a 64 byte long char buffer should be enough for the hexadecimal representation of 244 bit wide pointers plus '0x' and the final 0, right? :) ).
Cheers, Justus - -- gpg key fingerprint: C82D 382A AB38 1A54 5290 19D6 A0F9 B035 686C 6996 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIEh9ZoPmwNWhsaZYRAj50AJ9QWcxALBx1fuLIqEBAbNKsGn5PogCbBRRV QjvTVKQJnI1yzOamX2KwOy8= =TVic -----END PGP SIGNATURE-----
diff -pru dillo2/src/dialog.cc dillo2-cur/src/dialog.cc --- dillo2/src/dialog.cc 2008-04-11 14:51:24.000000000 +0200 +++ dillo2-cur/src/dialog.cc 2008-04-24 00:19:39.000000000 +0200 @@ -11,6 +11,7 @@
// UI dialogs
+#include <inttypes.h> #include <math.h> // for rint()
#include <fltk/events.h> // for the unfortunate (temporary?) event key testing @@ -246,7 +247,7 @@ static int choice5_answer;
void choice5_cb(Widget *button, void *number) { - choice5_answer = (int)number; + choice5_answer = (intptr_t)number; _MSG("choice5_cb: %d\n", choice5_answer); button->window()->make_exec_return(true); }
diff -pru dw2/lout/object.cc dw2-cur/lout/object.cc --- dw2/lout/object.cc 2007-10-26 14:17:43.000000000 +0200 +++ dw2-cur/lout/object.cc 2008-04-25 19:01:34.000000000 +0200 @@ -22,6 +22,7 @@
#include "object.hh" #include <stdio.h> +#include <inttypes.h>
namespace object {
@@ -114,28 +115,13 @@ bool Pointer::equals(Object *other)
int Pointer::hashValue() { - if(sizeof (int) == sizeof (void*)) - return (int)value; - else if (2 * sizeof (int) == sizeof (void*)) - return ((int*)value)[0] ^ ((int*)value)[1]; - else { - // unhandled case - misc::assertNotReached (); - return 0; - } + return (intptr_t)value; }
The xor-stuff in the 64bit case ensures a equal distribution of hash values. I'm not sure a simple cast to int is enough on all systems (well, it probabely is..). intptr_t v = (intptr_t) value; return (int) v ^ (v >> (sizeof int * 8)); for the 64bit case would be a more conservative fix - if it compiles :-)
void Pointer::intoStringBuffer(misc::StringBuffer *sb) { char buf[64]; - if(sizeof (int) == sizeof (void*)) - sprintf(buf, "0x%x", (int)value); - else if (sizeof (long) == sizeof (void*)) - sprintf(buf, "0x%lx", (long)value); - else { - // unhandled case - misc::assertNotReached (); - } + snprintf(buf, sizeof(buf), "0x%p", value); sb->append(buf); }
Nice simplification! Johannes