summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThies C. Arntzen <thies@php.net>1999-11-21 17:13:39 +0000
committerThies C. Arntzen <thies@php.net>1999-11-21 17:13:39 +0000
commit5cc10ecec231640ea903992c9c84aa110441a211 (patch)
tree672dd69047502beaa9b042f70f0205a6e5be7f6b
parent09299854149bd6731a7ac7959b5522601e69142e (diff)
downloadphp-git-5cc10ecec231640ea903992c9c84aa110441a211.tar.gz
@- Fixed float-compare in min(),max(),a[r]sort(),[r]sort(). (Thies)
convert_to_long() after compare_function() destroys float-compares!
-rw-r--r--ext/standard/array.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index fb5e0f8042..dbf7fc9075 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -154,14 +154,25 @@ static int array_key_compare(const void *a, const void *b)
return 0;
}
+ if (result.type == IS_DOUBLE) {
+ if (result.value.dval < 0) {
+ return -1;
+ } else if (result.value.dval > 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
convert_to_long(&result);
+
if (result.value.lval < 0) {
return -1;
} else if (result.value.lval > 0) {
return 1;
- } else {
- return 0;
- }
+ }
+
+ return 0;
}
static int array_reverse_key_compare(const void *a, const void *b)
@@ -251,14 +262,25 @@ static int array_data_compare(const void *a, const void *b)
return 0;
}
+ if (result.type == IS_DOUBLE) {
+ if (result.value.dval < 0) {
+ return -1;
+ } else if (result.value.dval > 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
convert_to_long(&result);
+
if (result.value.lval < 0) {
return -1;
} else if (result.value.lval > 0) {
return 1;
- } else {
- return 0;
- }
+ }
+
+ return 0;
}
static int array_reverse_data_compare(const void *a, const void *b)