andrey Thu Sep 12 04:04:43 2002 EDT
Modified files:
/php4/ext/standard array.c
Log:
Removed magic numbers about the behavior of php_array_diff - proposed by
Andi and Jon Parise.
#It is strange that I commited ZTS code but after that Edin fixed ZTS build
#when I updated - it wasn't ZTS. hmmm. anyway fixing ZTS build.
Index: php4/ext/standard/array.c
diff -u php4/ext/standard/array.c:1.190 php4/ext/standard/array.c:1.191
--- php4/ext/standard/array.c:1.190 Wed Sep 11 19:09:11 2002
+++ php4/ext/standard/array.c Thu Sep 12 04:04:42 2002
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.190 2002/09/11 23:09:11 edink Exp $ */
+/* $Id: array.c,v 1.191 2002/09/12 08:04:42 andrey Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -75,6 +75,9 @@
#define COUNT_NORMAL 0
#define COUNT_RECURSIVE 1
+#define DIFF_NORMAL 0
+#define DIFF_ASSOC 1
+
PHP_MINIT_FUNCTION(array)
{
#ifdef ZTS
@@ -2621,7 +2624,7 @@
}
/* }}} */
-static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior)
+static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior TSRMLS_DC)
{
zval ***args = NULL;
HashTable *hash;
@@ -2660,9 +2663,9 @@
*list++ = p;
}
*list = NULL;
- if (behavior == 0) {
+ if (behavior == DIFF_NORMAL) {
zend_qsort((void *) lists[i], hash->nNumOfElements,
sizeof(Bucket *), array_data_compare TSRMLS_CC);
- } else if (behavior == 1) {
+ } else if (behavior == DIFF_ASSOC) {
zend_qsort((void *) lists[i], hash->nNumOfElements,
sizeof(Bucket *), array_key_compare TSRMLS_CC);
}
}
@@ -2676,22 +2679,22 @@
while (*ptrs[0]) {
c = 1;
for (i = 1; i < argc; i++) {
- if (behavior == 0) {
+ if (behavior == DIFF_NORMAL) {
while (*ptrs[i] && (0 < (c =
array_data_compare(ptrs[0], ptrs[i] TSRMLS_CC)))) {
ptrs[i]++;
}
- } else if (behavior == 1) {
+ } else if (behavior == DIFF_ASSOC) {
while (*ptrs[i] && (0 < (c =
array_key_compare(ptrs[0], ptrs[i] TSRMLS_CC)))) {
ptrs[i]++;
}
}
if (!c) {
- if (behavior == 0) {
+ if (behavior == DIFF_NORMAL) {
if (*ptrs[i]) {
ptrs[i]++;
}
break;
- } else if (behavior == 1) {
+ } else if (behavior == DIFF_ASSOC) {
if (*ptrs[i]) {
if (array_data_compare(ptrs[0],
ptrs[i] TSRMLS_CC) != 0) {
c = -1;
@@ -2715,11 +2718,11 @@
if (!*++ptrs[0]) {
goto out;
}
- if (behavior == 0) {
+ if (behavior == DIFF_NORMAL) {
if (array_data_compare(ptrs[0] - 1, ptrs[0]
TSRMLS_CC)) {
break;
}
- } else if (behavior == 1) {
+ } else if (behavior == DIFF_ASSOC) {
/* in this case no array_key_compare is needed
*/
break;
}
@@ -2731,11 +2734,11 @@
if (!*++ptrs[0]) {
goto out;
}
- if (behavior == 0) {
+ if (behavior == DIFF_NORMAL) {
if (array_data_compare(ptrs[0]-1, ptrs[0]
TSRMLS_CC)) {
break;
}
- } else if (behavior == 1) {
+ } else if (behavior == DIFF_ASSOC) {
/* in this case no array_key_compare is needed
*/
break;
}
@@ -2756,7 +2759,7 @@
Returns the entries of arr1 that have values which are not present in any of the
others arguments */
PHP_FUNCTION(array_diff)
{
- php_array_diff(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ php_array_diff(INTERNAL_FUNCTION_PARAM_PASSTHRU, DIFF_NORMAL TSRMLS_CC);
}
/* }}} */
@@ -2764,7 +2767,7 @@
Returns the entries of arr1 that have values which are not present in any of the
others arguments but do additional checks whether the keys are equal */
PHP_FUNCTION(array_diff_assoc)
{
- php_array_diff(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+ php_array_diff(INTERNAL_FUNCTION_PARAM_PASSTHRU, DIFF_ASSOC TSRMLS_CC);
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php