Re: Re: qsort fix

From: Date: Fri, 28 May 1999 16:49:28 +0000
Subject: Re: Re: qsort fix
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-6174@lists.php.net to get a copy of this message
> This is definitely a problem in Solaris's qsort(). The problem is > that we're really doing something that is kind of non-kosher. > Everybody else's qsort() seems to handly it fine, though. Since qsort() takes a user-supplied comparison function, the implementation should be robust enough to not crash regardless of what this comparison function returns. The Solaris man page for qsort just says: The function must return an integer less than, equal to, or greater than zero to indicate if the first argument is to be considered less than, equal to, or greater than the second argument. and then under the NOTES: The comparison function need not compare every byte, so arbitrary data may be contained in the elements in addition to the values being compared. The relative order in the output of two items that compare as equal is unpredictable. So, basically going from the first blurb there, they say, "if the first argument should be considered less than..." They don't say "if the first argument *is* less than..." which to me means that it should be valid to not use the same criteria on every iteration to determine which argument should be considered less than another. And they definitely don't explicitly say that the comparison function must always use the same criteria for comparing two values. Silly Sun... -Rasmus -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#6174) next »