Re: [RFC]strn(case)cmp supporting negative length as third parameter
| From: | Ángel González | Date: | Thu, 28 Jul 2011 18:20:34 +0000 |
| Subject: | Re: [RFC]strn(case)cmp supporting negative length as third parameter | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-54234@lists.php.net to get a copy of this message | ||
Laruence wrote:
Hi: strn(case)cmp dosen't support a negative length as its third paramter, while substr dose.
here is the rfc: https://wiki.php.net/rfc/strncmpnegativelen any question? plz worte me back. thanksWhat do you exactly mean by "in the reverse order" in
if the abs of the negative length is greater than any strlen of the first two parameters, then strn(case)cmp will work as strncmp in the reverse order with the abs value:Looking at
var_dump <http://www.php.net/var_dump>(strncmp <http://www.php.net/strncmp>("prefix_num", "num", -10)); //outpu: int(7) it seems to mean that it would be equivalent to
var_dump(strncmp("mun_xiferp", "mun", 10));However, if I'm reading the patch correctly, it would be taking the smaller string. Ie. it would be equivalent to
var_dump <http://www.php.net/var_dump>(strncmp <http://www.php.net/strncmp>("prefix_num", "num", -3));Seems an implementation bug.