summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
authorStig Venaas <venaas@php.net>2000-10-22 11:18:21 +0000
committerStig Venaas <venaas@php.net>2000-10-22 11:18:21 +0000
commite8c7fd7f5f5b6aae7073af9e33be720cdc858bd5 (patch)
tree8f8c7fb8aeb5e0a90a96e643ff27fd9e25598a19 /ext/standard/array.c
parent989d4716435df3d3361a541d9da029da7d19d12d (diff)
downloadphp-git-e8c7fd7f5f5b6aae7073af9e33be720cdc858bd5.tar.gz
Fixed array_type_data_compare(). I want strings to always differ from
numbers, but not say 7 and 7.0 to differ.
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r--ext/standard/array.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 4c049888be..f6b9ae5708 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -256,6 +256,9 @@ PHP_FUNCTION(count)
/* Numbers are always smaller than strings int this function as it
* anyway doesn't make much sense to compare two different data types.
* This keeps it consistant and simple.
+ *
+ * This is not correct any more, if you want this behavior, use
+ * array_type_data_compare().
*/
static int array_data_compare(const void *a, const void *b)
{
@@ -346,7 +349,8 @@ static int array_natural_case_compare(const void *a, const void *b)
return array_natural_general_compare(a, b, 1);
}
-/* Compare types first, and compare data only if same type */
+/* Compare types first, if exactly one argument is a string, return the
+ * type difference, thus numbers are always smaller than strings */
static int array_type_data_compare(const void *a, const void *b)
{
Bucket *f;
@@ -364,10 +368,9 @@ static int array_type_data_compare(const void *a, const void *b)
second = *((pval **) s->pData);
diff = first->type - second->type;
- if (diff)
+ if (diff && ((first->type == IS_STRING) || (second->type == IS_STRING)))
return diff;
-
if (ARRAYG(compare_func)(&result, first, second) == FAILURE) {
return 0;
}