From 5cc10ecec231640ea903992c9c84aa110441a211 Mon Sep 17 00:00:00 2001 From: "Thies C. Arntzen" Date: Sun, 21 Nov 1999 17:13:39 +0000 Subject: [PATCH] @- Fixed float-compare in min(),max(),a[r]sort(),[r]sort(). (Thies) convert_to_long() after compare_function() destroys float-compares! --- ext/standard/array.c | 34 ++++++++++++++++++++++++++++------ 1 file 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) -- 2.40.0