pajoye          Thu Feb  9 15:48:18 2006 UTC

  Modified files:              
    /php-src/ext/standard       crc32.c 
    /php-src/ext/standard/tests/strings bug36306.phpt 
  Log:
  - MFB:
  - revert last fix
  - ensure that we are in 32bit
  - do not try to compare the decimal values but hex, php does not have
    unsigned integer
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/crc32.c?r1=1.18&r2=1.19&diff_format=u
Index: php-src/ext/standard/crc32.c
diff -u php-src/ext/standard/crc32.c:1.18 php-src/ext/standard/crc32.c:1.19
--- php-src/ext/standard/crc32.c:1.18   Tue Feb  7 00:24:56 2006
+++ php-src/ext/standard/crc32.c        Thu Feb  9 15:48:18 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: crc32.c,v 1.18 2006/02/07 00:24:56 pajoye Exp $ */
+/* $Id: crc32.c,v 1.19 2006/02/09 15:48:18 pajoye Exp $ */
 
 #include "php.h"
 #include "basic_functions.h"
@@ -26,19 +26,20 @@
    Calculate the crc32 polynomial of a string */
 PHP_NAMED_FUNCTION(php_if_crc32)
 {
-       unsigned int crc = ~0;
        char *p;
        int len, nr;
-       
+       php_uint32 crcinit = 0;
+       register php_uint32 crc;
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == 
FAILURE) {
                return;
        }
+       crc = crcinit^0xFFFFFFFF;
 
-       len = 0 ;
-       for (len += nr; nr--; ++p) {
-           CRC32(crc, *p);
+       for (len =+nr; nr--; ++p) {
+               crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF 
];
        }
-       RETVAL_LONG(~ (long) crc);
+       RETVAL_LONG(crc^0xFFFFFFFF);
 }
 /* }}} */
 
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/strings/bug36306.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/standard/tests/strings/bug36306.phpt
diff -u php-src/ext/standard/tests/strings/bug36306.phpt:1.2 
php-src/ext/standard/tests/strings/bug36306.phpt:1.3
--- php-src/ext/standard/tests/strings/bug36306.phpt:1.2        Tue Feb  7 
00:24:56 2006
+++ php-src/ext/standard/tests/strings/bug36306.phpt    Thu Feb  9 15:48:18 2006
@@ -2,7 +2,14 @@
 Bug #36306 crc32() 64bit
 --FILE--
 <?php
-echo crc32("platform independant") . "\n";
+
+/* as an example how to write crc32 tests
+   PHP does not have uint values, you cannot
+   display crc32 like a signed integer.
+   Have to find some small strings to truely reproduce
+   the problem, this example being not a problem
+*/
+echo dechex(crc32("platform independant")) . "\n";
 ?>
 --EXPECT--
--858128794
+ccd9fe66

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to