Req #36944 [Com]: strncmp & negative len
| From: | php at mcq8 dot be | Date: | Sun, 11 Jun 2017 15:16:47 +0000 |
| Subject: | Req #36944 [Com]: strncmp & negative len | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209479@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=36944&edit=1
ID: 36944
Comment by: php at mcq8 dot be
Reported by: ms419 at freezone dot co dot uk
Summary: strncmp & negative len
Status: Open
Type: Feature/Change Request
Package: Strings related
Operating System: Debian
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
This is fixed in 5.1.3 https://3v4l.org/Ite0e
The bug can be closed.
Previous Comments:
------------------------------------------------------------------------
[2011-07-26 11:21:01] laruence@php.net
The following patch has been added/updated:
Patch Name: php-5-3-trunk-strncmp-supporting-negative-length
Revision: 1311679261
URL: https://bugs.php.net/patch-display.php?bug=36944&patch=php-5-3-trunk-strncmp-supporting-negative-length&revision=1311679261
------------------------------------------------------------------------
[2011-07-25 11:40:24] laruence@php.net
The following patch has been added/updated:
Patch Name: bug36944.phpt
Revision: 1311594024
URL: https://bugs.php.net/patch-display.php?bug=36944&patch=bug36944.phpt&revision=1311594024
------------------------------------------------------------------------
[2011-07-25 11:37:53] laruence@php.net
The following patch has been added/updated:
Patch Name: php-5-3-strn-case-cmp-supporting-negative-length
Revision: 1311593873
URL: https://bugs.php.net/patch-display.php?bug=36944&patch=php-5-3-strn-case-cmp-supporting-negative-length&revision=1311593873
------------------------------------------------------------------------
[2011-07-25 11:06:44] laruence@php.net
The following patch has been added/updated:
Patch Name: php-5-3-strncasecmp-supporting-negative-length
Revision: 1311592004
URL: https://bugs.php.net/patch-display.php?bug=36944&patch=php-5-3-strncasecmp-supporting-negative-length&revision=1311592004
------------------------------------------------------------------------
[2008-11-25 18:45:46] ms419 at freezone dot co dot uk
I wish to change this bug report to a feature request. I frequently need to check if a string begins
or ends with another string. To check if a string begins with another string, I often use strncmp():
ket% php -r 'var_dump(strncmp("HTTP_ACCEPT", "HTTP_", 5));'
int(0)
ket%
- but strncmp() is currently not able to check if a string ends with another string:
ket% php -r 'var_dump(strncmp("foo_wrapper", "_wrapper", -8));'
Warning: Length must be greater than or equal to 0 in Command line code on line 1
Call Stack:
0.0002 62840 1. {main}() Command line code:0
0.0002 62952 2. strncmp() Command line code:1
bool(false)
ket%
I wish strncmp() were able to check if a string ends with another string.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=36944
--
Edit this bug report at https://bugs.php.net/bug.php?id=36944&edit=1