diff options
| author | Andrei Zmievski <andrei@php.net> | 2000-03-30 14:34:46 +0000 |
|---|---|---|
| committer | Andrei Zmievski <andrei@php.net> | 2000-03-30 14:34:46 +0000 |
| commit | 5cd7bf59b3f81057b72410441df9410557d789e8 (patch) | |
| tree | 049966b259a3cf73e78e48ca9f02e12e601d84d5 /ext/standard/string.c | |
| parent | e282cefe203a2f8cd72408c8b67fc06753d66975 (diff) | |
| download | php-git-5cd7bf59b3f81057b72410441df9410557d789e8.tar.gz | |
@- Fixed return of stristr() to no longer always be lowercased. (Andrei)
Diffstat (limited to 'ext/standard/string.c')
| -rw-r--r-- | ext/standard/string.c | 10 |
1 files changed, 9 insertions, 1 deletions
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); } /* }}} */ |
