From: Ilia Alshanetsky Date: Mon, 26 Sep 2005 23:08:10 +0000 (+0000) Subject: Allow substr_compare() to take a negative offset to facilitate start of the X-Git-Tag: RELEASE_0_9_0~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=200d5924cf844b43ffe089ced760452e6a89bc71;p=php Allow substr_compare() to take a negative offset to facilitate start of the comparison from the end of string. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 4f255d4d8e..09d68c1123 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -5770,6 +5770,10 @@ PHP_FUNCTION(substr_compare) RETURN_FALSE; } + if (offset < 0) { /* negative offset, start comparison at the end of string */ + offset = s1_len + offset; + } + if (len && offset >= s1_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length."); RETURN_FALSE;