[VOTE]strn(case)cmp supporting a negative length as its third paramter

php.internals

Laruence

15 years ago
Hi everyone: plz vote for this : "strn(case)cmp supporting a negative length as its third paramter" RFC: https://wiki.php.net/rfc/strncmpnegativelen#vote if you have any objection, plz write back. thanks
-- Laruence  Xinchen Hui http://www.laruence.com/

Jan Dolecek

15 years ago
This would make perfect sense with constant strings and constant length, when using variables this may lead to some magic bugs, which would be normally reported as E_WARNING. Not sure if it's a good idea :( Jan Dolecek juzna.cz@gmail.com On Mon, Aug 1, 2011 at 7:40 AM, Laruence <laruence@php.net> wrote:

Laruence

15 years ago
Hi: I am not good at english, so I could not explain the idea very clearly but I really think it was a good idea,, could someone plz make a decision that make this patch applied to svn trunk? thanks 2011/8/2 Jan Dolecek <juzna.cz@gmail.com>:
> This would make perfect sense with constant strings and constant > length, when using variables this may lead to some magic bugs, which > would be normally reported as E_WARNING. Not sure if it's a good idea > :( > > Jan Dolecek > juzna.cz@gmail.com > > > > On Mon, Aug 1, 2011 at 7:40 AM, Laruence <laruence@php.net> wrote: >> Hi everyone: >> >>   plz vote for this : "strn(case)cmp supporting a negative length as >> its third paramter" >> >>   RFC: https://wiki.php.net/rfc/strncmpnegativelen#vote >> >>   if you have any objection, plz write back. >> >> thanks >> >> -- >> Laruence  Xinchen Hui >> http://www.laruence.com/ >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >
-- Laruence  Xinchen Hui http://www.laruence.com/

Laruence

15 years ago
HI: and I don't think this was diffcult to accepted it was a little improve, and make a litte change, even no bc break... thanks 2011/8/6 Laruence <laruence@php.net>:
> Hi: >  I am not good at english, so I could not explain the idea very clearly >  but I really think it was a good idea,, > >  could someone plz make a decision that make this patch applied to svn trunk? > >  thanks > > 2011/8/2 Jan Dolecek <juzna.cz@gmail.com>: >> This would make perfect sense with constant strings and constant >> length, when using variables this may lead to some magic bugs, which >> would be normally reported as E_WARNING. Not sure if it's a good idea >> :( >> >> Jan Dolecek >> juzna.cz@gmail.com >> >> >> >> On Mon, Aug 1, 2011 at 7:40 AM, Laruence <laruence@php.net> wrote: >>> Hi everyone: >>> >>>   plz vote for this : "strn(case)cmp supporting a negative length as >>> its third paramter" >>> >>>   RFC: https://wiki.php.net/rfc/strncmpnegativelen#vote >>> >>>   if you have any objection, plz write back. >>> >>> thanks >>> >>> -- >>> Laruence  Xinchen Hui >>> http://www.laruence.com/ >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> > > > > -- > Laruence  Xinchen Hui > http://www.laruence.com/ >
-- Laruence  Xinchen Hui http://www.laruence.com/

Laruence

15 years ago
Dear all: I am going to close strn(case)cmp supporting negative length vote, since it has been calling for vote near two weeks, and no new feedback . the Voting result is: Support : 6 felipe pajoye pierrick gwynne tyrael laruence Decline : 3 iliaa rasmus salathe it wins 2/3 vote, so I think this supposed to mean that accept, right? thanks 2011/8/6 Laruence <laruence@php.net>:
> HI: >   and I don't think this was diffcult to accepted >   it was a little improve, and make a litte change, even no bc break... > > thanks > > 2011/8/6 Laruence <laruence@php.net>: >> Hi: >>  I am not good at english, so I could not explain the idea very clearly >>  but I really think it was a good idea,, >> >>  could someone plz make a decision that make this patch applied to svn trunk? >> >>  thanks >> >> 2011/8/2 Jan Dolecek <juzna.cz@gmail.com>: >>> This would make perfect sense with constant strings and constant >>> length, when using variables this may lead to some magic bugs, which >>> would be normally reported as E_WARNING. Not sure if it's a good idea >>> :( >>> >>> Jan Dolecek >>> juzna.cz@gmail.com >>> >>> >>> >>> On Mon, Aug 1, 2011 at 7:40 AM, Laruence <laruence@php.net> wrote: >>>> Hi everyone: >>>> >>>>   plz vote for this : "strn(case)cmp supporting a negative length as >>>> its third paramter" >>>> >>>>   RFC: https://wiki.php.net/rfc/strncmpnegativelen#vote >>>> >>>>   if you have any objection, plz write back. >>>> >>>> thanks >>>> >>>> -- >>>> Laruence  Xinchen Hui >>>> http://www.laruence.com/ >>>> >>>> -- >>>> PHP Internals - PHP Runtime Development Mailing List >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >>>> >>> >> >> >> >> -- >> Laruence  Xinchen Hui >> http://www.laruence.com/ >> > > > > -- > Laruence  Xinchen Hui > http://www.laruence.com/ >
-- Laruence  Xinchen Hui http://www.laruence.com/

Derick Rethans

15 years ago
On Sat, 13 Aug 2011, Laruence wrote:
> Dear all: > I am going to close strn(case)cmp supporting negative length vote, > since it has been calling for vote near two weeks, and no new feedback > . > > the Voting result is: > Support : 6 felipe pajoye pierrick gwynne tyrael laruence > Decline : 3 iliaa rasmus salathe > > it wins 2/3 vote, so I think this supposed to mean that accept, right?
I voted against too. Also, you started the vote with not even a week between RFC announcement and call for voting, so I guess that makes this invalid? Just looked over the RFC, and this whole example is weird: <?php var_dump(strncmp("prefix_num", "num", -10)); ?> Why does it even find the substring as you can't do "-10" from the end? If the number is too high, it should give you a warning. cheers, Derick
-- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug

Ferenc Kovacs

15 years ago
On Sun, Aug 14, 2011 at 1:24 PM, Derick Rethans <derick@php.net> wrote:
> On Sat, 13 Aug 2011, Laruence wrote: > >> Dear all: >>     I am going to close strn(case)cmp supporting negative length vote, >> since it has been calling for vote near two weeks, and no new feedback >> . >> >>     the Voting result is: >>      Support :  6  felipe pajoye pierrick gwynne tyrael laruence >>      Decline :  3  iliaa rasmus salathe >> >>     it wins 2/3 vote,   so I think this supposed to mean that accept,  right? > > I voted against too. Also, you started the vote with not even a week > between RFC announcement and call for voting, so I guess that makes this > invalid? > > > Just looked over the RFC, and this whole example is weird: > > <?php > var_dump(strncmp("prefix_num", "num", -10)); > ?> > > Why does it even find the substring as you can't do "-10" from the end? > If the number is too high, it should give you a warning.
imo the patch is consistent with how substr works: tyrael@thor:~$ php -d display_errors=1 -d error_reporting=-1 -r 'echo substr("prefix_num", -100);' prefix_num
-- Ferenc Kovács @Tyr43l - http://tyrael.hu

Derick Rethans

15 years ago
On Sun, 14 Aug 2011, Ferenc Kovacs wrote:
> On Sun, Aug 14, 2011 at 1:24 PM, Derick Rethans <derick@php.net> wrote: > > On Sat, 13 Aug 2011, Laruence wrote: > > > >> Dear all: > >>     I am going to close strn(case)cmp supporting negative length vote, > >> since it has been calling for vote near two weeks, and no new feedback > >> . > >> > >>     the Voting result is: > >>      Support :  6  felipe pajoye pierrick gwynne tyrael laruence > >>      Decline :  3  iliaa rasmus salathe > >> > >>     it wins 2/3 vote,   so I think this supposed to mean that accept,  right? > > > > I voted against too. Also, you started the vote with not even a week > > between RFC announcement and call for voting, so I guess that makes this > > invalid? > > > > > > Just looked over the RFC, and this whole example is weird: > > > > <?php > > var_dump(strncmp("prefix_num", "num", -10)); > > ?> > > > > Why does it even find the substring as you can't do "-10" from the end? > > If the number is too high, it should give you a warning. > > imo the patch is consistent with how substr works: > tyrael@thor:~$ php -d display_errors=1 -d error_reporting=-1 -r 'echo > substr("prefix_num", -100);' > prefix_num
Maybe, but I would classify *that* as a bug as it makes no sense at all. Derick
-- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug

Ferenc Kovacs

15 years ago
>> imo the patch is consistent with how substr works: >> tyrael@thor:~$ php -d display_errors=1 -d error_reporting=-1 -r 'echo >> substr("prefix_num", -100);' >> prefix_num > > Maybe, but I would classify *that* as a bug as it makes no sense at all. >
I don't mind that, and imho laruence would be happy to change the patch, after we fix this "bug". But thats a separate issue, and we should also keep in mind the BC break for that.
-- Ferenc Kovács @Tyr43l - http://tyrael.hu

Laruence

15 years ago
Hi: this just to say that stncasecmp has the same behavior of either negative or postive length argument. why you insist to this point? as strncmp("aaaa", "bbb", 1000000) works with no warning, why negative length need trigger warnings? thanks 2011/8/14 Derick Rethans <derick@php.net>:
> On Sun, 14 Aug 2011, Ferenc Kovacs wrote: > >> On Sun, Aug 14, 2011 at 1:24 PM, Derick Rethans <derick@php.net> wrote: >> > On Sat, 13 Aug 2011, Laruence wrote: >> > >> >> Dear all: >> >>     I am going to close strn(case)cmp supporting negative length vote, >> >> since it has been calling for vote near two weeks, and no new feedback >> >> . >> >> >> >>     the Voting result is: >> >>      Support :  6  felipe pajoye pierrick gwynne tyrael laruence >> >>      Decline :  3  iliaa rasmus salathe >> >> >> >>     it wins 2/3 vote,   so I think this supposed to mean that accept,  right? >> > >> > I voted against too. Also, you started the vote with not even a week >> > between RFC announcement and call for voting, so I guess that makes this >> > invalid? >> > >> > >> > Just looked over the RFC, and this whole example is weird: >> > >> > <?php >> > var_dump(strncmp("prefix_num", "num", -10)); >> > ?> >> > >> > Why does it even find the substring as you can't do "-10" from the end? >> > If the number is too high, it should give you a warning. >> >> imo the patch is consistent with how substr works: >> tyrael@thor:~$ php -d display_errors=1 -d error_reporting=-1 -r 'echo >> substr("prefix_num", -100);' >> prefix_num > > Maybe, but I would classify *that* as a bug as it makes no sense at all. > > Derick > > -- > http://derickrethans.nl | http://xdebug.org > Like Xdebug? Consider a donation: http://xdebug.org/donate.php > twitter: @derickr and @xdebug
-- Laruence  Xinchen Hui http://www.laruence.com/

Laruence

15 years ago
Hi: I think what I was done is try to describe a image, that we can make follow codes more simple: if (strncmp(substr("num_suffix", 0, -5), "suffix", 5) == 0) { echo "they have the same suffix"; } yes, there is must something not good in my patch, but I think I can tweak it as you wish. the only thing I want you to accept is : " should this behavior is more make sense for some occassion?" thanks 2011/8/14 Laruence <laruence@php.net>:
> Hi: >   this just to say that stncasecmp has the same behavior of either > negative or postive length argument. > >   why you insist to this point?  as strncmp("aaaa", "bbb",  1000000) > works with no warning,  why negative length need trigger warnings? > > thanks > > 2011/8/14 Derick Rethans <derick@php.net>: >> On Sun, 14 Aug 2011, Ferenc Kovacs wrote: >> >>> On Sun, Aug 14, 2011 at 1:24 PM, Derick Rethans <derick@php.net> wrote: >>> > On Sat, 13 Aug 2011, Laruence wrote: >>> > >>> >> Dear all: >>> >>     I am going to close strn(case)cmp supporting negative length vote, >>> >> since it has been calling for vote near two weeks, and no new feedback >>> >> . >>> >> >>> >>     the Voting result is: >>> >>      Support :  6  felipe pajoye pierrick gwynne tyrael laruence >>> >>      Decline :  3  iliaa rasmus salathe >>> >> >>> >>     it wins 2/3 vote,   so I think this supposed to mean that accept,  right? >>> > >>> > I voted against too. Also, you started the vote with not even a week >>> > between RFC announcement and call for voting, so I guess that makes this >>> > invalid? >>> > >>> > >>> > Just looked over the RFC, and this whole example is weird: >>> > >>> > <?php >>> > var_dump(strncmp("prefix_num", "num", -10)); >>> > ?> >>> > >>> > Why does it even find the substring as you can't do "-10" from the end? >>> > If the number is too high, it should give you a warning. >>> >>> imo the patch is consistent with how substr works: >>> tyrael@thor:~$ php -d display_errors=1 -d error_reporting=-1 -r 'echo >>> substr("prefix_num", -100);' >>> prefix_num >> >> Maybe, but I would classify *that* as a bug as it makes no sense at all. >> >> Derick >> >> -- >> http://derickrethans.nl | http://xdebug.org >> Like Xdebug? Consider a donation: http://xdebug.org/donate.php >> twitter: @derickr and @xdebug > > > > -- > Laruence  Xinchen Hui > http://www.laruence.com/ >
-- Laruence  Xinchen Hui http://www.laruence.com/

Stas Malyshev

15 years ago
Hi!
>> imo the patch is consistent with how substr works: >> tyrael@thor:~$ php -d display_errors=1 -d error_reporting=-1 -r 'echo >> substr("prefix_num", -100);' >> prefix_num > > Maybe, but I would classify *that* as a bug as it makes no sense at all.
It makes some sense, if you take the meaning of argument as "at most 100 characters". I'm not sure how useful it'd be backwards, but forward something like "at most 100 chars" is very useful and warning, on the contrary, in such situation would be useless and annoying. Why not make backwards case symmetrical?
-- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

Stas Malyshev

15 years ago
Hi!
>> Maybe, but I would classify *that* as a bug as it makes no sense at all.
Thinking more about it, something like: if(strncasecmp($filename, ".php", -4) === 0) { /* got php file! */ } seems to me just fine and better than doing the same with substr. I would definitely be against the warning in this case.
-- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

Stas Malyshev

15 years ago
Hi! On 8/13/11 5:17 AM, Laruence wrote:
> Dear all: > I am going to close strn(case)cmp supporting negative length vote, > since it has been calling for vote near two weeks, and no new feedback
I think we need some more time to discuss it. Give it a week, then let's see.
-- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227