Hi:
  first of all, yes , you are right about the reverse order thing:

 and then, they are not equal:

 <?php
 echo "strncmp:\n";
   var_dump(strncmp("laruence", "nce", -10));
   var_dump(strncmp("ecneural", "ecn", 10));

   var_dump(strncmp("ecneural", "ecn", 3));
   var_dump(strncmp("laruence", "nce", -3));
?>

will output:
  strncmp:
  int(5)
  int(5)
  int(0)
  int(0)


thanks

2011/7/29 Ángel González <keis...@gmail.com>:
> 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.
>>
>>  thanks
>
> What 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.
>
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to