Re: cvs: php-src /ext/standard/tests/strings pack.phpt

From: Date: Mon, 20 Nov 2006 18:09:57 +0000
Subject: Re: cvs: php-src /ext/standard/tests/strings pack.phpt
References: 1 2 3 4  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-41650@lists.php.net to get a copy of this message
Yes, the patch fixes it, but please don't use C++ comments in C code. On 11/20/2006 08:45 PM, David Soria Parra wrote:
------------------------------------------------------------------------ Index: ext/standard/pack.c =================================================================== RCS file: /repository/php-src/ext/standard/pack.c,v retrieving revision 1.57.2.5.2.1 diff -u -r1.57.2.5.2.1 pack.c --- ext/standard/pack.c 19 Nov 2006 18:20:48 -0000 1.57.2.5.2.1 +++ ext/standard/pack.c 20 Nov 2006 17:30:56 -0000 @@ -90,6 +90,19 @@ convert_to_long_ex(val); v = (char *) &Z_LVAL_PP(val); + // we have to fake an overflow, to
+    // get the same results on machines where int and long differs (e.g. x86_64 machines)
+ if (sizeof(long) > size) { + if (!machine_little_endian) { + v+= sizeof(long) - size; + } + if (Z_LVAL_PP(val) < -INT_MAX) { + memset(v, 0, sizeof(int)); + v[machine_endian_long_map[3]] = 0x80; + } + + } + for (i = 0; i < size; i++) { *output++ = v[map[i]]; } @@ -783,7 +796,7 @@ map = little_endian_long_map; } - if (sizeof(long) > 4 && (input[inputpos + machine_endian_long_map[3]] & 0x80) == 0x80) { + if (sizeof(long) > 4 && (input[inputpos + map[3]] & 0x80) == 0x80) { v = ~INT_MAX; }
-- Wbr, Antony Dovgal

« previous php.cvs (#41650) next »