]> granicus.if.org Git - php/commitdiff
@- Fixed return of stristr() to no longer always be lowercased. (Andrei)
authorAndrei Zmievski <andrei@php.net>
Thu, 30 Mar 2000 14:34:46 +0000 (14:34 +0000)
committerAndrei Zmievski <andrei@php.net>
Thu, 30 Mar 2000 14:34:46 +0000 (14:34 +0000)
ext/standard/string.c

index 9c0482b13e622a87f8360ea64e52c952121c2687..dda667df4c4b373a0ad9bc449f20ee8404ebf1c0 100644 (file)
@@ -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);
 }
 /* }}} */