Re: com php-src: Fixed bug 67043: NEWS ext/standard/string.c ext/standard/tests/strings/substr_compare.phpt
| From: | Ferenc Kovacs | Date: | Wed, 09 Apr 2014 11:44:57 +0000 |
| Subject: | Re: com php-src: Fixed bug 67043: NEWS ext/standard/string.c ext/standard/tests/strings/substr_compare.phpt | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-76745@lists.php.net to get a copy of this message | ||
Hi,
ext/standard/tests/strings/substr_compare.phpt seems to be failing now:
https://travis-ci.org/php/php-src/builds/22598738
could you look into it, please?
On Wed, Apr 9, 2014 at 1:33 AM, Tjerk Anne Meesters <datibbaw@php.net>wrote:
> Commit: 032921d80cd97d1d8a696348ce6bb0fd17e597e8
> Author: Tjerk Meesters <datibbaw@php.net> Wed, 9 Apr 2014
> 07:33:55 +0800
> Parents: 4141ceb7951eb5b003e8616774d39e665b9914c7
> Branches: PHP-5.5 PHP-5.6 master
>
> Link:
>
> http://git.php.net/?p=php-src.git;a=commitdiff;h=032921d80cd97d1d8a696348ce6bb0fd17e597e8
>
> Log:
> Fixed bug 67043
>
> Bugs:
> https://bugs.php.net/67043
>
> Changed paths:
> M NEWS
> M ext/standard/string.c
> M ext/standard/tests/strings/substr_compare.phpt
>
>
> Diff:
> diff --git a/NEWS b/NEWS
> index 29e6c89..53220d7 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -7,6 +7,7 @@ PHP
> NEWS
> UNIX sockets). (Mike)
> . Fixed bug #66182 (exit in stream filter produces segfault). (Mike)
> . Fixed bug #66736 (fpassthru broken). (Mike)
> + . Fixed bug #67043 (substr_compare broke by previous change) (Tjerk)
>
> - Embed:
> . Fixed bug #65715 (php5embed.lib isn't provided anymore). (Anatol).
> diff --git a/ext/standard/string.c b/ext/standard/string.c
> index 10d5ed9..58aad8d 100644
> --- a/ext/standard/string.c
> +++ b/ext/standard/string.c
> @@ -5590,14 +5590,19 @@ PHP_FUNCTION(substr_compare)
> int s1_len, s2_len;
> long offset, len=0;
> zend_bool cs=0;
> + uint cmp_len;
>
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb",
> &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) {
> RETURN_FALSE;
> }
>
> - if (ZEND_NUM_ARGS() >= 4 && len < 0) {
> - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length
> must be greater than or equal to zero");
> - RETURN_FALSE;
> + if (ZEND_NUM_ARGS() >= 4 && len <= 0) {
> + if (len == 0) {
> + RETURN_LONG(0L);
> + } else {
> + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The
> length must be greater than or equal to zero");
> + RETURN_FALSE;
> + }
> }
>
> if (offset < 0) {
> @@ -5610,10 +5615,12 @@ PHP_FUNCTION(substr_compare)
> RETURN_FALSE;
> }
>
> + cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));
> +
> if (!cs) {
> - RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len -
> offset), s2, s2_len, (uint)len));
> + RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len -
> offset), s2, s2_len, cmp_len));
> } else {
> - RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len
> - offset), s2, s2_len, (uint)len));
> + RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len
> - offset), s2, s2_len, cmp_len));
> }
> }
> /* }}} */
> diff --git a/ext/standard/tests/strings/substr_compare.phpt
> b/ext/standard/tests/strings/substr_compare.phpt
> index 8477771..191a77e 100644
> --- a/ext/standard/tests/strings/substr_compare.phpt
> +++ b/ext/standard/tests/strings/substr_compare.phpt
> @@ -3,6 +3,7 @@ substr_compare()
> --FILE--
> <?php
>
> +var_dump(substr_compare("abcde", "df", -2));
> var_dump(substr_compare("abcde", "bc", 1, 2));
> var_dump(substr_compare("abcde", "bcg", 1, 2));
> var_dump(substr_compare("abcde", "BC", 1, 2, true));
> @@ -20,6 +21,7 @@ var_dump(substr_compare("abcde", -1, 0, "str", new
> stdClass));
> echo "Done\n";
> ?>
> --EXPECTF--
> +int(-1)
> int(0)
> int(0)
> int(0)
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu