[PHP-DEV] Re: [PATCH] For Bug #38770

2006-11-17 Thread David Soria Parra
Are there no opinions about that?

It's just that if u pack an integer u get an integer and are not
influenced by the convert to the long as it is stored in a zval struct.
It's just about handling an int as an int (which is also 4byte on x64) and 
avoid problems if the long is bigger than the int as in x64 but not in
x x84 (on x84 int is 4byte and long is 4byte)

would be great to get some feedback.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: [PATCH] For Bug #38770

2006-11-17 Thread David Soria Parra
I also attached the patch against PHP_5_2 CVS

Index: ext/standard/pack.c
===
RCS file: /repository/php-src/ext/standard/pack.c,v
retrieving revision 1.57.2.5
diff -u -r1.57.2.5 pack.c
--- ext/standard/pack.c  26 Feb 2006 10:49:50 -  1.57.2.5
+++ ext/standard/pack.c  17 Nov 2006 17:54:24 -
@@ -756,11 +756,15 @@
long v;
int issigned = 0;
 
-   if (type == 'i') {
issigned = 
input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)]  0x80;
+
+   if (sizeof(long)  sizeof(int) 
 issigned) {
+   v = ~INT_MAX;
+   } else {
+   v = 0;
}
 
-   v = 
php_unpack(input[inputpos], sizeof(int), issigned, int_map);
+   v |= 
php_unpack(input[inputpos], sizeof(int), (type=='i')?issigned:0, int_map);
add_assoc_long(return_value, n, 
v);
break;
}
@@ -781,7 +785,14 @@
map = 
little_endian_long_map;
}
 
-   v = 
php_unpack(input[inputpos], 4, issigned, map);
+   if (sizeof(long)  4  
(input[inputpos + map[3]]  0x80) == 0x80) {
+   v = ~INT_MAX;
+   } else {
+   v = 0;
+   }
+
+   v |= 
php_unpack(input[inputpos], 4, issigned, map);
+
add_assoc_long(return_value, n, 
v);
break;
}

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php