Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18676 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12285 invoked by uid 1010); 5 Sep 2005 11:37:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12270 invoked from network); 5 Sep 2005 11:37:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Sep 2005 11:37:58 -0000 X-Host-Fingerprint: 212.77.105.136 it.wp-sa.pl Received: from ([212.77.105.136:24335] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id C5/9B-33268-51E2C134 for ; Mon, 05 Sep 2005 07:37:57 -0400 Message-ID: To: internals@lists.php.net Date: Mon, 05 Sep 2005 13:37:55 +0200 User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 References: <431C2738.2040602@wp.pl> In-Reply-To: <431C2738.2040602@wp.pl> Content-Type: multipart/mixed; boundary="------------030604070000080302080901" X-Posted-By: 212.77.105.136 Subject: Re: crc32 From: wmeler@wp.pl (Wojtek Meler) --------------030604070000080302080901 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Oops !!! I've left old license header. Here is smaller clean version that apply to CVS HEAD. --------------030604070000080302080901 Content-Type: text/x-patch; name="crc.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="crc.patch" 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 2005 14:07:57 -0000 1.16 +++ crc32.c 5 Sep 2005 11:35:23 -0000 @@ -22,20 +22,19 @@ #include "basic_functions.h" #include "crc32.h" -/* {{{ proto string crc32(string str) +/* {{{ proto int crc32(string str[,int prev_crc]) Calculate the crc32 polynomial of a string */ PHP_NAMED_FUNCTION(php_if_crc32) { - unsigned int crc = ~0; + unsigned int crc = 0; char *p; - int len, nr; + int len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &p, &len, &crc) == FAILURE) { return; } - - len = 0 ; - for (len += nr; nr--; ++p) { + crc = ~crc; + for (; len--; ++p) { CRC32(crc, *p); } RETVAL_LONG(~crc); --------------030604070000080302080901--