|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-02-21 17:13 UTC] erw dot dongen at wxs dot nl
// Ran into this when using strcasecmp as user-sort function for usort()
echo strcasecmp("B", "AAA"); // results in -1
// workaround: strcmp( strtolower($a), strtolower($b) )
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Jun 28 11:00:01 2026 UTC |
no, it isn't !!! strcasecmp("B","AAA") should be equal to strcmp("B","AAA") at least in the results sign the code for zend_binary_strcasecmp() in Zend/zend_operators.c is broken, the following diff should fix it: --- zend_operators.c 2000/03/01 13:59:51 1.53 +++ zend_operators.c 2000/03/05 19:56:43 @@ -1256,20 +1256,19 @@ ZEND_API int zend_binary_strcasecmp(char *s1, uint len1, char *s2, uint len2) { unsigned char c1 = 0, c2 = 0; + int len; - if (len1 != len2 || !len1) { - return len1 - len2; - } + len = MIN(len1,len2); - while (len1--) { + while (len--) { c1 = tolower(*s1++); c2 = tolower(*s2++); if (c1 != c2) { - break; + return c1 - c2; } } - return c1 - c2; + return len1 - len2; }