Re: Bug #3556 Updated: strcasecmp() compares lengths instead of string contents
| From: | Sascha Schumann | Date: | Sun, 05 Mar 2000 20:18:12 +0000 |
| Subject: | Re: Bug #3556 Updated: strcasecmp() compares lengths instead of string contents | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-16427@lists.php.net to get a copy of this message | ||
On Sun, Mar 05, 2000 at 08:04:57PM -0000, Bug Database wrote:
> ID: 3556
> Updated by: hholzgra
> Reported By: erw.dongen@wxs.nl
> Status: Analyzed
> Bug Type: Misbehaving function
> Assigned To:
> Comments:
>
> no, it isn't !!!
One "!" is usually enough.
> 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:
Nope, the return value cannot be computed from the length of the strings.
Also see http://www.opengroup.org/onlinepubs/007908799/xsh/strcasecmp.html
>
> --- 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;
> - }
This optimization (?) is invalid. This was carried over from php3 into Zend.
I've fixed this locally already, but still need to test it.
- Sascha