From: Andrei Zmievski Date: Thu, 30 Mar 2000 14:34:46 +0000 (+0000) Subject: @- Fixed return of stristr() to no longer always be lowercased. (Andrei) X-Git-Tag: php-4.0RC2~571 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cd7bf59b3f81057b72410441df9410557d789e8;p=php @- Fixed return of stristr() to no longer always be lowercased. (Andrei) --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 9c0482b13e..dda667df4c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -573,6 +573,8 @@ PHP_FUNCTION(stristr) { zval **haystack, **needle; char *found = NULL; + int found_offset; + char *haystack_orig; char needle_char[2]; if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &haystack, &needle) == @@ -583,10 +585,13 @@ PHP_FUNCTION(stristr) SEPARATE_ZVAL(haystack); SEPARATE_ZVAL(needle); convert_to_string_ex(haystack); + haystack_orig = estrndup((*haystack)->value.str.val, + (*haystack)->value.str.len); if ((*needle)->type == IS_STRING) { if ((*needle)->value.str.len==0) { php_error(E_WARNING,"Empty delimiter"); + efree(haystack_orig); RETURN_FALSE; } @@ -602,10 +607,13 @@ PHP_FUNCTION(stristr) } if (found) { - RETVAL_STRING(found, 1); + found_offset = found - (*haystack)->value.str.val; + RETVAL_STRINGL(haystack_orig + found_offset, + (*haystack)->value.str.len - found_offset, 1); } else { RETVAL_FALSE; } + efree(haystack_orig); } /* }}} */