cvs: php4 /ext/standard array.c

From: Date: Sun, 22 Oct 2000 11:18:22 +0000
Subject: cvs: php4 /ext/standard array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2210@lists.php.net to get a copy of this message
venaas Sun Oct 22 04:18:22 2000 EDT Modified files: /php4/ext/standard array.c Log: Fixed array_type_data_compare(). I want strings to always differ from numbers, but not say 7 and 7.0 to differ. Index: php4/ext/standard/array.c diff -u php4/ext/standard/array.c:1.77 php4/ext/standard/array.c:1.78 --- php4/ext/standard/array.c:1.77 Sat Oct 21 11:12:30 2000 +++ php4/ext/standard/array.c Sun Oct 22 04:18:21 2000 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.77 2000/10/21 18:12:30 venaas Exp $ */ +/* $Id: array.c,v 1.78 2000/10/22 11:18:21 venaas Exp $ */ #include "php.h" #include "php_ini.h" @@ -256,6 +256,9 @@ /* 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 @@ 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,9 +368,8 @@ 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;

« previous php.cvs (#2210) next »