Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-07 Thread Marco Schuster
Hi, I ran into 32-bit problems, too, when working with 2GB files (in this case, raw DVD ISO images) on a 32-bit system (I couldn't find a reliable(!!) way to read a 4-byte absolute offset and seek to it). Of course, this warning is mentioned in the manpage, but really, not having at least a class

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-07 Thread Jakub Zelenka
Hi, On Sat, Sep 7, 2013 at 6:44 PM, Marco Schuster ma...@m-s-d.eu wrote: I ran into 32-bit problems, too, when working with 2GB files (in this case, raw DVD ISO images) on a 32-bit system (I couldn't find a reliable(!!) way to read a 4-byte absolute offset and seek to it). Of course, this

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-02 Thread Stas Malyshev
Hi! Yes, all of these problems can be solved - I am well aware of that. I am also painfully aware of how much time it can take to solve them reliably. I just would like to see a solution rather than a bunch of work-arounds - not for my own sake, my problem is solved, but for the sake of

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-02 Thread Rasmus Schultz
No, just this thread of e-mails. What I'm suggesting is simply a set of alternative functions to ip2long() and crc32() that return consistent values on all platforms, e.g. 32-bit signed integer values - a couple of new functions and a couple of quick updates to the documentation explaining why

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-02 Thread Stas Malyshev
Hi! What I'm suggesting is simply a set of alternative functions to ip2long() and crc32() that return consistent values on all platforms, e.g. 32-bit signed integer values - a couple of new functions and a couple of quick updates to the documentation explaining why you might want to use

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-02 Thread Rasmus Schultz
if I wanted strings or something else, that would be simple enough - sprintf() will do the job. in my case, I needed a scalar value that I can actually persist to the database. On Mon, Sep 2, 2013 at 4:21 PM, Stas Malyshev smalys...@sugarcrm.com wrote: Hi! What I'm suggesting is simply a

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-09-01 Thread Rasmus Schultz
Matthew, Yes, all of these problems can be solved - I am well aware of that. I am also painfully aware of how much time it can take to solve them reliably. I just would like to see a solution rather than a bunch of work-arounds - not for my own sake, my problem is solved, but for the sake of

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-08-30 Thread Matthew Leverton
On Fri, Aug 30, 2013 at 10:29 AM, Rasmus Schultz ras...@mindplay.dk wrote: No replies probably means no one cares. oh well. For the record, the examples I posted are wrong - the correct way to convert the long values consistently appears to be: list($v) = array_values(unpack('l', pack('l',

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-08-30 Thread Rasmus Schultz
Matthew, To give another example: var_dump(array(sprintf('%u', ip2long('127.0.0.1')) = 'foo', sprintf('%u', ip2long('255.255.255.0')) = 'bar')); array(2) { [2130706433]= string(3) foo [4294967040]= string(3) bar } The keys are now two different types (string vs int) on 32-bit

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-08-30 Thread Rasmus Schultz
Perhaps this illustrates the problem better: $value = sprintf('%u', ip2long('255.255.255.0')); var_dump($value, (int) $value); $a = array(); $a[$value] = 'foo'; var_dump($a); Output on 64-bit: string(10) 4294967040 int(4294967040) array(1) { [4294967040]= string(3) foo } No problem. But

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-08-30 Thread Matthew Leverton
On Fri, Aug 30, 2013 at 11:48 AM, Rasmus Schultz ras...@mindplay.dk wrote: array(2) { [2130706433]= string(3) foo [4294967040]= string(3) bar } The keys are now two different types (string vs int) on 32-bit platforms, which leads to problems with strict comparison. Prefix your

[PHP-DEV] Re: crc32() and ip2long() return values

2013-08-30 Thread Rasmus Schultz
No replies probably means no one cares. oh well. For the record, the examples I posted are wrong - the correct way to convert the long values consistently appears to be: list($v) = array_values(unpack('l', pack('l', ip2long('255.255.255.0'; I missed the fact that array_values() returns an

Re: [PHP-DEV] Re: crc32() and ip2long() return values

2013-08-30 Thread Tjerk Meesters
Hi, On 30 Aug, 2013, at 11:29 PM, Rasmus Schultz ras...@mindplay.dk wrote: No replies probably means no one cares. oh well. For the record, the examples I posted are wrong - the correct way to convert the long values consistently appears to be: list($v) = array_values(unpack('l',

Re: [PHP-DEV] Re: crc32

2005-09-14 Thread Marcus Boerger
Hello Sara, nice and helpfull idea best regards marcus Tuesday, September 6, 2005, 3:57:38 PM, you wrote: I'd suggest a set of filters as an add-on to the mhash extension: mhash.crc32 mhash.md5 mhash.sha1 mhash.sha256 etc -Sara - Original Message - From: Ron Korving

[PHP-DEV] Re: crc32

2005-09-06 Thread Wojtek Meler
Ron Korving wrote: Wouldn't it be more practical to implement these as stream filters? Sure - I was not aware PHP5 streams - I'm still using PHP4 string.base64 is good choice. But I'm not sure if crc fit to streams. You can always implement fast userland filter with such function ;) . Wojtek

[PHP-DEV] Re: crc32

2005-09-06 Thread Ron Korving
With a crc function the way you propose it, such a filter could be effectively made in userspace, but you could of course also implement such a filter in the core of php which could do the same trick. Maybe both would be nice. Ron Wojtek Meler [EMAIL PROTECTED] schreef in bericht news:[EMAIL

[PHP-DEV] Re: crc32

2005-09-06 Thread Sara Golemon
I'd suggest a set of filters as an add-on to the mhash extension: mhash.crc32 mhash.md5 mhash.sha1 mhash.sha256 etc -Sara - Original Message - From: Ron Korving [EMAIL PROTECTED] Newsgroups: php.internals To: internals@lists.php.net Sent: Tuesday, September 06, 2005 4:48 AM

[PHP-DEV] Re: crc32

2005-09-05 Thread Wojtek Meler
Oops !!! I've left old license header. Here is smaller clean version that apply to CVS HEAD. Index: crc32.c === RCS file: /repository/php-src/ext/standard/crc32.c,v retrieving revision 1.16 diff -u -r1.16 crc32.c --- crc32.c 3 Aug

[PHP-DEV] Re: crc32

2005-09-05 Thread Ron Korving
Wouldn't it be more practical to implement these as stream filters? Ron Wojtek Meler [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] I've patched original crc32 PHP function to allow incremental crc32 counting. It touches only a few lines of original code. New crc32 function

[PHP-DEV] Re: crc32, md5 sha1 functions

2005-03-21 Thread Sara Golemon
crc32, md5 and sha1 functions, implemented in PHP, are widely used for computing fingerprint of any data. But current implementation has not very good limitation - there is no way to get/set current state vector of these functions. So, we have to pass whole amount of data as argument of these

[PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Alexander Valyalkin
On Sun, 13 Jun 2004 11:24:12 +0200, Ard Biesheuvel [EMAIL PROTECTED] wrote: First of all, crc32tab is no longer in the .text segment, so it will not be shared between forked processes, taking more memory space than necessary. Each process will have to initialise it as well, so the init loop

Re: [PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Derick Rethans
On Mon, 14 Jun 2004, Alexander Valyalkin wrote: Thank you for good explanation and comments. Now I understood that the current crc32 implementation is better than mine. But it consists some ugly bugs (read my comments): PHP_NAMED_FUNCTION(php_if_crc32) { unsigned int crc = ~0;

Re: [PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Alexander Valyalkin
On Mon, 14 Jun 2004 11:00:33 +0200 (CEST), Derick Rethans [EMAIL PROTECTED] wrote: if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p, nr) == FAILURE) { return; } /* !!! there is no error check nr 0 */ Of course not, that's pointless as a string can never have

Re: [PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Christian Schneider
Alexander Valyalkin wrote: It is only idle talk. Can you provide any string from my code which violates your coding standards? Calm down. As I said before (obviously not clearly enough, I was hoping one of the 'project managers' would do that for me ;-)) you are missing the point why people

Re: [PHP-DEV] Re: crc32() improvements

2004-06-14 Thread Mike Benoit
On Mon, 2004-06-14 at 12:48 +0200, Christian Schneider wrote: Alexander Valyalkin wrote: It is only idle talk. Can you provide any string from my code which violates your coding standards? Calm down. As I said before (obviously not clearly enough, I was hoping one of the 'project

[PHP-DEV] Re: crc32() improvements

2004-06-13 Thread Ard Biesheuvel
Alexander Valyalkin wrote: 1) Automatic initialization of crc32tab[] at first call. So, the file crc32.h with definition of this tab is not nessesary any more now. First of all, crc32tab is no longer in the .text segment, so it will not be shared between forked processes, taking more memory