]> granicus.if.org Git - php/commitdiff
Bug fixes for substr_replace().
authorAndrei Zmievski <andrei@php.net>
Wed, 20 Sep 2006 20:30:19 +0000 (20:30 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 20 Sep 2006 20:30:19 +0000 (20:30 +0000)
Zend/zend_API.c
ext/standard/array.c
ext/standard/string.c
unicode-progress.txt

index 923cad496063a5f3df539875b6277f1962c2f896..7c65a8e4d3f353ac768e28ff53f923eb1aa5a3a8 100644 (file)
@@ -3460,7 +3460,7 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, in
 ZEND_API zend_uchar zend_get_unified_string_type(int num_args TSRMLS_DC, ...)
 {
        va_list ap;
-       int best_type = UG(unicode) ? IS_UNICODE : IS_STRING;
+       int best_type = ZEND_STR_TYPE;
        int type;
 
        if (num_args <= 0) return (zend_uchar)-1;
index 54623a9e9521562947b5f93371a66e6dc32b1850..ac284f45f18776fe75e7bdf3d9eb337daeeb75bf 100644 (file)
@@ -1690,10 +1690,6 @@ PHP_FUNCTION(range)
 
        /* Unify types */
        str_type = zend_get_unified_string_type(2 TSRMLS_CC, Z_TYPE_P(zlow), Z_TYPE_P(zhigh));
-       if (str_type == (zend_uchar)-1) {
-               zend_error(E_WARNING, "Cannot mix binary and Unicode parameters");
-               return;
-       }
        convert_to_explicit_type(zlow, str_type);
        convert_to_explicit_type(zhigh, str_type);
 
index c738b87fbd83f7212f1b194ec3c9774ae38ae69f..12e38db77641f0a2c418c2de35c9b942b906d1b2 100644 (file)
@@ -2319,10 +2319,6 @@ PHP_FUNCTION(stristr)
                }
                if (Z_TYPE_PP(haystack) != Z_TYPE_PP(needle)) {
                        str_type = zend_get_unified_string_type(2 TSRMLS_CC, Z_TYPE_PP(haystack), Z_TYPE_PP(needle));
-                       if (str_type == (zend_uchar)-1) {
-                               zend_error(E_WARNING, "Cannot mix binary and Unicode parameters");
-                               return;
-                       }
                        convert_to_explicit_type_ex(haystack, str_type);
                        convert_to_explicit_type_ex(needle, str_type);
                }
@@ -2628,10 +2624,6 @@ PHP_FUNCTION(stripos)
                }
                if (Z_TYPE_PP(haystack) != Z_TYPE_PP(needle)) {
                        str_type = zend_get_unified_string_type(2 TSRMLS_CC, Z_TYPE_PP(haystack), Z_TYPE_PP(needle));
-                       if (str_type == (zend_uchar)-1) {
-                               zend_error(E_WARNING, "Cannot mix binary and Unicode parameters");
-                               return;
-                       }
                        convert_to_explicit_type_ex(haystack, str_type);
                        convert_to_explicit_type_ex(needle, str_type);
                }
@@ -2739,10 +2731,6 @@ PHP_FUNCTION(strrpos)
        if (Z_TYPE_PP(zneedle) == IS_UNICODE || Z_TYPE_PP(zneedle) == IS_STRING) {
                if (Z_TYPE_PP(zneedle) != Z_TYPE_PP(zhaystack)) {
                        str_type = zend_get_unified_string_type(2 TSRMLS_CC, Z_TYPE_PP(zhaystack), Z_TYPE_PP(zneedle));
-                       if (str_type == (zend_uchar)-1) {
-                               zend_error(E_WARNING, "Cannot mix binary and Unicode parameters");
-                               return;
-                       }
                        convert_to_explicit_type_ex(zhaystack, str_type);
                        convert_to_explicit_type_ex(zneedle, str_type);
                }
@@ -3264,8 +3252,8 @@ PHP_FUNCTION(substr_replace)
        zval **tmp_str = NULL, **tmp_from = NULL, **tmp_repl = NULL, **tmp_len= NULL;
        zend_uchar str_type;
 
-       if (argc < 3 || argc > 4 || zend_get_parameters_ex(argc, &str, &repl, &from, &len) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|Z", &str, &repl, &from, &len) == FAILURE) {
+               return;
        }
 
        if (Z_TYPE_PP(str) != IS_ARRAY && Z_TYPE_PP(str) != IS_UNICODE &&
@@ -3323,10 +3311,6 @@ PHP_FUNCTION(substr_replace)
 
                        if (tmp_repl && Z_TYPE_PP(str) != Z_TYPE_PP(tmp_repl)) {
                                str_type = zend_get_unified_string_type(2 TSRMLS_CC, Z_TYPE_PP(str), Z_TYPE_PP(tmp_repl));
-                               if (str_type == (zend_uchar)-1) {
-                                       zend_error(E_WARNING, "Cannot mix binary and Unicode types");
-                                       return;
-                               }
                                convert_to_explicit_type_ex(str, str_type);
                                convert_to_explicit_type_ex(tmp_repl, str_type);
                        }
@@ -3357,7 +3341,7 @@ PHP_FUNCTION(substr_replace)
 
                zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(str), &pos_str);
                while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(str), (void **) &tmp_str, &pos_str) == SUCCESS) {
-                       if (Z_TYPE_PP(tmp_str) != IS_UNICODE && Z_TYPE_PP(tmp_str) != IS_STRING && Z_TYPE_PP(tmp_str) != IS_STRING) {
+                       if (Z_TYPE_PP(tmp_str) != IS_UNICODE && Z_TYPE_PP(tmp_str) != IS_STRING) {
                                convert_to_text_ex(tmp_str);
                        }
 
@@ -3388,7 +3372,7 @@ PHP_FUNCTION(substr_replace)
 
                        if (Z_TYPE_PP(repl) == IS_ARRAY) {
                                if (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(repl), (void **) &tmp_repl, &pos_repl)) {
-                                       if (Z_TYPE_PP(repl) != IS_UNICODE && Z_TYPE_PP(repl) != IS_STRING && Z_TYPE_PP(repl) != IS_STRING) {
+                                       if (Z_TYPE_PP(tmp_repl) != IS_UNICODE && Z_TYPE_PP(tmp_repl) != IS_STRING) {
                                                convert_to_text_ex(tmp_repl);
                                        }
                                        zend_hash_move_forward_ex(Z_ARRVAL_PP(repl), &pos_repl);
@@ -3401,10 +3385,6 @@ PHP_FUNCTION(substr_replace)
 
                        if (tmp_repl && Z_TYPE_PP(tmp_str) != Z_TYPE_PP(tmp_repl)) {
                                str_type = zend_get_unified_string_type(2 TSRMLS_CC, Z_TYPE_PP(tmp_str), Z_TYPE_PP(tmp_repl));
-                               if (str_type == (zend_uchar)-1) {
-                                       zend_error(E_WARNING, "Cannot mix binary and Unicode types");
-                                       return;
-                               }
                                convert_to_explicit_type_ex(tmp_str, str_type);
                                convert_to_explicit_type_ex(tmp_repl, str_type);
                        }
index 392d0415c74783d0793b5fa9947717bba96013d2..e79126d09ad77638670f081f7a1de177a0a93b91 100644 (file)
@@ -72,16 +72,9 @@ ext/standard
     strnatcmp(), strnatcasecmp()
         Params API. The rest depends on porting of strnatcmp.c
 
-    strrchr()
-        Needs update so that it doesn't try to find half of a surrogate
-        pair.
-
     strtr()
         Check on Derick's progress.
 
-    substr_replace()
-        Params API, test
-
     wordwrap()
         Upgrade, do wordwrapping on codepoint (or glyph ?) level, maybe use
         additional whitespace chars instead of just space.
@@ -129,6 +122,7 @@ ext/standard
     max()
     range()
     shuffle()
+    strrchr()
 
     end(), prev(), next(), reset(), current(), key()