diff options
author | Pierre Joye <pajoye@php.net> | 2006-02-09 15:33:53 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2006-02-09 15:33:53 +0000 |
commit | 8600417c790b5dde763f986c834f9e4f46ebc2fc (patch) | |
tree | b573780e8bf2804df18f9795dd3ff413bda5fa8b /ext/standard/crc32.c | |
parent | f541b63e1fac60eb07d8f32604dd50c196379a85 (diff) | |
download | php-git-8600417c790b5dde763f986c834f9e4f46ebc2fc.tar.gz |
- 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
Diffstat (limited to 'ext/standard/crc32.c')
-rw-r--r-- | ext/standard/crc32.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 02bc54e623..774564a715 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -22,25 +22,23 @@ #include "basic_functions.h" #include "crc32.h" -/* {{{ proto string crc32(string str) - 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); } -/* }}} */ /* * Local variables: |