mirror of
https://github.com/php/php-src.git
synced 2024-11-30 05:13:56 +08:00
@Fix min/max behaviour (Thies)
#Andrei: I left the convert_to_long() in there, it doesn't really make #much of a difference.
This commit is contained in:
parent
86418fde5b
commit
fdc6d630db
@ -738,9 +738,9 @@ static int array_data_compare(const void *a, const void *b)
|
||||
{
|
||||
Bucket *f;
|
||||
Bucket *s;
|
||||
pval result;
|
||||
pval *first;
|
||||
pval *second;
|
||||
double dfirst, dsecond;
|
||||
|
||||
f = *((Bucket **) a);
|
||||
s = *((Bucket **) b);
|
||||
@ -748,37 +748,18 @@ static int array_data_compare(const void *a, const void *b)
|
||||
first = *((pval **) f->pData);
|
||||
second = *((pval **) s->pData);
|
||||
|
||||
if ((first->type == IS_LONG || first->type == IS_DOUBLE) &&
|
||||
(second->type == IS_LONG || second->type == IS_DOUBLE)) {
|
||||
if (first->type == IS_LONG) {
|
||||
dfirst = (double) first->value.lval;
|
||||
} else {
|
||||
dfirst = first->value.dval;
|
||||
}
|
||||
if (second->type == IS_LONG) {
|
||||
dsecond = (double) second->value.lval;
|
||||
} else {
|
||||
dsecond = second->value.dval;
|
||||
}
|
||||
if (dfirst < dsecond) {
|
||||
return -1;
|
||||
} else if (dfirst == dsecond) {
|
||||
if (compare_function(&result, first, second) == FAILURE) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if ((first->type == IS_LONG || first->type == IS_DOUBLE) &&
|
||||
second->type == IS_STRING) {
|
||||
|
||||
convert_to_long(&result);
|
||||
if (result.value.lval < 0) {
|
||||
return -1;
|
||||
} else if ((first->type == IS_STRING) &&
|
||||
(second->type == IS_LONG || second->type == IS_DOUBLE)) {
|
||||
} else if (result.value.lval > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if (first->type == IS_STRING && second->type == IS_STRING) {
|
||||
return strcmp(first->value.str.val, second->value.str.val);
|
||||
}
|
||||
return 0; /* Anything else is equal as it can't be compared */
|
||||
}
|
||||
|
||||
static int array_reverse_data_compare(const void *a, const void *b)
|
||||
|
Loading…
Reference in New Issue
Block a user