]> granicus.if.org Git - php/commitdiff
New parameter parsing API
authorOlivier Hill <ohill@php.net>
Wed, 25 Jun 2008 12:16:17 +0000 (12:16 +0000)
committerOlivier Hill <ohill@php.net>
Wed, 25 Jun 2008 12:16:17 +0000 (12:16 +0000)
28 files changed:
ext/standard/string.c
ext/standard/tests/strings/addcslashes_001.phpt
ext/standard/tests/strings/addcslashes_004.phpt
ext/standard/tests/strings/addslashes_error.phpt
ext/standard/tests/strings/addslashes_variation1.phpt
ext/standard/tests/strings/chr_ord.phpt
ext/standard/tests/strings/nl2br_error.phpt
ext/standard/tests/strings/nl2br_variation5.phpt
ext/standard/tests/strings/str_ireplace.phpt
ext/standard/tests/strings/str_pad.phpt
ext/standard/tests/strings/str_repeat.phpt
ext/standard/tests/strings/str_replace.phpt
ext/standard/tests/strings/strip_tags_error.phpt
ext/standard/tests/strings/strip_tags_variation1.phpt
ext/standard/tests/strings/strip_tags_variation3.phpt
ext/standard/tests/strings/stripslashes_error.phpt
ext/standard/tests/strings/stripslashes_variation1.phpt
ext/standard/tests/strings/strrev_error.phpt
ext/standard/tests/strings/strrev_variation4.phpt
ext/standard/tests/strings/strtr_error.phpt
ext/standard/tests/strings/strtr_variation5.phpt
ext/standard/tests/strings/strtr_variation7.phpt
ext/standard/tests/strings/strtr_variation9.phpt
ext/standard/tests/strings/substr.phpt
ext/standard/tests/strings/substr_count_error.phpt
ext/standard/tests/strings/substr_count_variation_001.phpt
ext/standard/tests/strings/ucwords_error.phpt
ext/standard/tests/strings/ucwords_variation1.phpt

index 142e1f4ace7743cc8f11499633b818f7ed07b285..444734327b8845d416b1fe32f752d616f8fe3a7d 100644 (file)
@@ -2123,38 +2123,33 @@ PHP_FUNCTION(chunk_split)
    Returns part of a string */
 PHP_FUNCTION(substr)
 {
-       zval **str, **from, **len;
+       char *str;
        int l;
        int f;
+       int str_len;
        int argc = ZEND_NUM_ARGS();
-
-       if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &str, &from, &len) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", &str, &str_len, &f, &l) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(str);
-       convert_to_long_ex(from);
-
        if (argc > 2) {
-               convert_to_long_ex(len);
-               l = Z_LVAL_PP(len);
-               if ((l < 0 && -l > Z_STRLEN_PP(str))) {
+               if ((l < 0 && -l > str_len)) {
                        RETURN_FALSE;
-               } else if (l > Z_STRLEN_PP(str)) {
-                       l = Z_STRLEN_PP(str);
+               } else if (l > str_len) {
+                       l = str_len;
                }
        } else {
-               l = Z_STRLEN_PP(str);
+               l = str_len;
        }
        
-       f = Z_LVAL_PP(from);
-       if (f > Z_STRLEN_PP(str)) {
+       if (f > str_len) {
                RETURN_FALSE;
-       } else if (f < 0 && -f > Z_STRLEN_PP(str)) {
+       } else if (f < 0 && -f > str_len) {
                f = 0;
        }
 
-       if (l < 0 && (l + Z_STRLEN_PP(str) - f) < 0) {
+       if (l < 0 && (l + str_len - f) < 0) {
                RETURN_FALSE;
        }
 
@@ -2162,7 +2157,7 @@ PHP_FUNCTION(substr)
         * of the string
         */
        if (f < 0) {
-               f = Z_STRLEN_PP(str) + f;
+               f = str_len + f;
                if (f < 0) {
                        f = 0;
                }
@@ -2172,21 +2167,21 @@ PHP_FUNCTION(substr)
         * needed to stop that many chars from the end of the string
         */
        if (l < 0) {
-               l = (Z_STRLEN_PP(str) - f) + l;
+               l = (str_len - f) + l;
                if (l < 0) {
                        l = 0;
                }
        }
 
-       if (f >= Z_STRLEN_PP(str)) {
+       if (f >= str_len) {
                RETURN_FALSE;
        }
 
-       if ((f + l) > Z_STRLEN_PP(str)) {
-               l = Z_STRLEN_PP(str) - f;
+       if ((f + l) > str_len) {
+               l = str_len - f;
        }
 
-       RETURN_STRINGL(Z_STRVAL_PP(str) + f, l, 1);
+       RETURN_STRINGL(str + f, l, 1);
 }
 /* }}} */
 
@@ -2207,9 +2202,8 @@ PHP_FUNCTION(substr_replace)
        HashPosition pos_str, pos_from, pos_repl, pos_len;
        zval **tmp_str = NULL, **tmp_from = NULL, **tmp_repl = NULL, **tmp_len= NULL;
 
-
-       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) {
@@ -2424,26 +2418,23 @@ PHP_FUNCTION(substr_replace)
    Quotes meta characters */
 PHP_FUNCTION(quotemeta)
 {
-       zval **arg;
        char *str, *old;
        char *old_end;
        char *p, *q;
        char c;
-       
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-
-       convert_to_string_ex(arg);
-
-       old = Z_STRVAL_PP(arg);
-       old_end = Z_STRVAL_PP(arg) + Z_STRLEN_PP(arg);
+       int  old_len;
 
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &old, &old_len) == FAILURE) {
+               return;
+       }
+       
+       old_end = old + old_len;
+               
        if (old == old_end) {
                RETURN_FALSE;
        }
        
-       str = safe_emalloc(2, Z_STRLEN_PP(arg), 1);
+       str = safe_emalloc(2, old_len, 1);
        
        for (p = old, q = str; p != old_end; p++) {
                c = *p;
@@ -2475,14 +2466,14 @@ PHP_FUNCTION(quotemeta)
    Returns ASCII value of character */
 PHP_FUNCTION(ord)
 {
-       zval **str;
+       char *str;
+       int   str_len;
        
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
-
-       RETURN_LONG((unsigned char) Z_STRVAL_PP(str)[0]);
+       
+       RETURN_LONG((unsigned char) str[0]);
 }
 /* }}} */
 
@@ -2572,19 +2563,19 @@ PHP_FUNCTION(lcfirst)
    Uppercase the first character of every word in a string */
 PHP_FUNCTION(ucwords)
 {
-       zval **str;
+       char *str;
        register char *r, *r_end;
+       int str_len;
        
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
 
-       if (!Z_STRLEN_PP(str)) {
+       if (!str_len) {
                RETURN_EMPTY_STRING();
        }
 
-       ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
+       ZVAL_STRINGL(return_value, str, str_len, 1);
        r = Z_STRVAL_P(return_value);
 
        *r = toupper((unsigned char) *r);
@@ -2734,11 +2725,13 @@ static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *
    Translates characters in str using given translation tables */
 PHP_FUNCTION(strtr)
 {                                                              
-       zval **str, **from, **to;
+       zval **from;
+       char *str, *to;
+       int str_len, to_len;
        int ac = ZEND_NUM_ARGS();
-
-       if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &str, &from, &to) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sZ|s", &str, &str_len, &from, &to, &to_len) == FAILURE) {
+               return;
        }
        
        if (ac == 2 && Z_TYPE_PP(from) != IS_ARRAY) {
@@ -2746,27 +2739,24 @@ PHP_FUNCTION(strtr)
                RETURN_FALSE;
        }
 
-       convert_to_string_ex(str);
-
        /* shortcut for empty string */
-       if (Z_STRLEN_PP(str) == 0) {
+       if (str_len == 0) {
                RETURN_EMPTY_STRING();
        }
 
        if (ac == 2) {
-               php_strtr_array(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), HASH_OF(*from));
+               php_strtr_array(return_value, str, str_len, HASH_OF(*from));
        } else {
                convert_to_string_ex(from);
-               convert_to_string_ex(to);
 
-               ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
+               ZVAL_STRINGL(return_value, str, str_len, 1);
                
                php_strtr(Z_STRVAL_P(return_value),
                                  Z_STRLEN_P(return_value),
                                  Z_STRVAL_PP(from),
-                                 Z_STRVAL_PP(to),
+                                 to,
                                  MIN(Z_STRLEN_PP(from), 
-                                 Z_STRLEN_PP(to)));
+                                 to_len));
        }
 }
 /* }}} */
@@ -2775,27 +2765,26 @@ PHP_FUNCTION(strtr)
    Reverse a string */
 PHP_FUNCTION(strrev)
 {
-       zval **str;
-       char *s, *e, *n, *p;
+       char *str;
+       char *e, *n, *p;
+       int  str_len;
        
-       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
        
-       n = emalloc(Z_STRLEN_PP(str)+1);
+       n = emalloc(str_len+1);
        p = n;
        
-       s = Z_STRVAL_PP(str);
-       e = s + Z_STRLEN_PP(str);
+       e = str + str_len;
        
-       while (--e>=s) {
+       while (--e>=str) {
                *p++ = *e;
        }
        
        *p = '\0';
        
-       RETVAL_STRINGL(n, Z_STRLEN_PP(str), 0);
+       RETVAL_STRINGL(n, str_len, 0);
 }
 /* }}} */
 
@@ -2849,22 +2838,21 @@ static int php_similar_char(const char *txt1, int len1, const char *txt2, int le
    Calculates the similarity between two strings */
 PHP_FUNCTION(similar_text)
 {
-       zval **t1, **t2, **percent;
+       char *t1, *t2;
+       zval **percent;
        int ac = ZEND_NUM_ARGS();
        int sim;
+       int t1_len, t2_len;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|Z", &t1, &t1_len, &t2, &t2_len, &percent) == FAILURE) {
+               return;
+       }
        
-       if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &t1, &t2, &percent) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }       
-
-       convert_to_string_ex(t1);
-       convert_to_string_ex(t2);
-
        if (ac > 2) {
                convert_to_double_ex(percent);
        }
        
-       if (Z_STRLEN_PP(t1) + Z_STRLEN_PP(t2) == 0) {
+       if (t1_len + t2_len == 0) {
                if (ac > 2) {
                        Z_DVAL_PP(percent) = 0;
                }
@@ -2872,10 +2860,10 @@ PHP_FUNCTION(similar_text)
                RETURN_LONG(0);
        }
        
-       sim = php_similar_char(Z_STRVAL_PP(t1), Z_STRLEN_PP(t1), Z_STRVAL_PP(t2), Z_STRLEN_PP(t2));     
+       sim = php_similar_char(t1, t1_len, t2, t2_len); 
 
        if (ac > 2) {
-               Z_DVAL_PP(percent) = sim * 200.0 / (Z_STRLEN_PP(t1) + Z_STRLEN_PP(t2));
+               Z_DVAL_PP(percent) = sim * 200.0 / (t1_len + t2_len);
        }
 
        RETURN_LONG(sim);
@@ -2957,23 +2945,22 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
    Escapes all chars mentioned in charlist with backslash. It creates octal representations if asked to backslash characters with 8th bit set or with ASCII<32 (except '\n', '\r', '\t' etc...) */
 PHP_FUNCTION(addcslashes)
 {
-       zval **str, **what;
+       char *str, *what;
+       int str_len, what_len;
 
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &str, &what) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &str, &str_len, &what, &what_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
-       convert_to_string_ex(what);
 
-       if (Z_STRLEN_PP(str) == 0) {
+       if (str_len == 0) {
                RETURN_EMPTY_STRING();
        }
 
-       if (Z_STRLEN_PP(what) == 0) {
-               RETURN_STRINGL(Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
+       if (what_len == 0) {
+               RETURN_STRINGL(str, str_len, 1);
        }
 
-       Z_STRVAL_P(return_value) = php_addcslashes(Z_STRVAL_PP(str), Z_STRLEN_PP(str), &Z_STRLEN_P(return_value), 0, Z_STRVAL_PP(what), Z_STRLEN_PP(what) TSRMLS_CC);
+       Z_STRVAL_P(return_value) = php_addcslashes(str, str_len, &Z_STRLEN_P(return_value), 0, what, what_len TSRMLS_CC);
        RETURN_STRINGL(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), 0);
 }
 /* }}} */
@@ -2982,19 +2969,19 @@ PHP_FUNCTION(addcslashes)
    Escapes single quote, double quotes and backslash characters in a string with backslashes */
 PHP_FUNCTION(addslashes)
 {
-       zval **str;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *str;
+       int  str_len;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
 
-       if (Z_STRLEN_PP(str) == 0) {
+       if (str_len == 0) {
                RETURN_EMPTY_STRING();
        }
 
-       RETURN_STRING(php_addslashes(Z_STRVAL_PP(str),
-                                    Z_STRLEN_PP(str)
+       RETURN_STRING(php_addslashes(str,
+                                    str_len
                                     &Z_STRLEN_P(return_value), 0 
                                     TSRMLS_CC), 0);
 }
@@ -3004,14 +2991,14 @@ PHP_FUNCTION(addslashes)
    Strips backslashes from a string. Uses C-style conventions */
 PHP_FUNCTION(stripcslashes)
 {
-       zval **str;
+       char *str;
+       int  str_len;
        
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
 
-       ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
+       ZVAL_STRINGL(return_value, str, str_len, 1);
        php_stripcslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value));
 }
 /* }}} */
@@ -3020,14 +3007,14 @@ PHP_FUNCTION(stripcslashes)
    Strips backslashes from a string */
 PHP_FUNCTION(stripslashes)
 {
-       zval **str;
+       char *str;
+       int  str_len;
        
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
 
-       ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
+       ZVAL_STRINGL(return_value, str, str_len, 1);
        php_stripslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value) TSRMLS_CC);
 }
 /* }}} */
@@ -3637,9 +3624,8 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
        int count = 0;
        int argc = ZEND_NUM_ARGS();
 
-       if (argc < 3 || argc > 4 ||
-          zend_get_parameters_ex(argc, &search, &replace, &subject, &zcount) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|Z", &search, &replace, &subject, &zcount) == FAILURE) {
+               return;
        }
 
        SEPARATE_ZVAL(search);
@@ -3718,42 +3704,26 @@ PHP_FUNCTION(str_ireplace)
  */
 static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
 {
-       zval **str, **max_chars_per_line;
+       char *str;
        char *heb_str, *tmp, *target, *broken_str;
        int block_start, block_end, block_type, block_length, i;
        long max_chars=0;
        int begin, end, char_count, orig_begin;
-
+       int str_len;
        
-       switch (ZEND_NUM_ARGS()) {
-               case 1:
-                       if (zend_get_parameters_ex(1, &str) == FAILURE) {
-                               RETURN_FALSE;
-                       }
-                       break;
-               case 2:
-                       if (zend_get_parameters_ex(2, &str, &max_chars_per_line) == FAILURE) {
-                               RETURN_FALSE;
-                       }
-                       convert_to_long_ex(max_chars_per_line);
-                       max_chars = Z_LVAL_PP(max_chars_per_line);
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
-                       break;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &max_chars) == FAILURE) {
+               return;
        }
        
-       convert_to_string_ex(str);
-       
-       if (Z_STRLEN_PP(str) == 0) {
+       if (str_len == 0) {
                RETURN_FALSE;
        }
 
-       tmp = Z_STRVAL_PP(str);
+       tmp = str;
        block_start=block_end=0;
 
-       heb_str = (char *) emalloc(Z_STRLEN_PP(str)+1);
-       target = heb_str+Z_STRLEN_PP(str);
+       heb_str = (char *) emalloc(str_len+1);
+       target = heb_str+str_len;
        *target = 0;
        target--;
 
@@ -3767,13 +3737,13 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
        
        do {
                if (block_type == _HEB_BLOCK_TYPE_HEB) {
-                       while ((isheb((int)*(tmp+1)) || _isblank((int)*(tmp+1)) || ispunct((int)*(tmp+1)) || (int)*(tmp+1)=='\n' ) && block_end<Z_STRLEN_PP(str)-1) {
+                       while ((isheb((int)*(tmp+1)) || _isblank((int)*(tmp+1)) || ispunct((int)*(tmp+1)) || (int)*(tmp+1)=='\n' ) && block_end<str_len-1) {
                                tmp++;
                                block_end++;
                                block_length++;
                        }
                        for (i = block_start; i<= block_end; i++) {
-                               *target = Z_STRVAL_PP(str)[i];
+                               *target = str[i];
                                switch (*target) {
                                        case '(':
                                                *target = ')';
@@ -3812,7 +3782,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
                        }
                        block_type = _HEB_BLOCK_TYPE_ENG;
                } else {
-                       while (!isheb(*(tmp+1)) && (int)*(tmp+1)!='\n' && block_end < Z_STRLEN_PP(str)-1) {
+                       while (!isheb(*(tmp+1)) && (int)*(tmp+1)!='\n' && block_end < str_len-1) {
                                tmp++;
                                block_end++;
                                block_length++;
@@ -3822,17 +3792,17 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
                                block_end--;
                        }
                        for (i = block_end; i >= block_start; i--) {
-                               *target = Z_STRVAL_PP(str)[i];
+                               *target = str[i];
                                target--;
                        }
                        block_type = _HEB_BLOCK_TYPE_HEB;
                }
                block_start=block_end+1;
-       } while (block_end < Z_STRLEN_PP(str)-1);
+       } while (block_end < str_len-1);
 
 
-       broken_str = (char *) emalloc(Z_STRLEN_PP(str)+1);
-       begin=end=Z_STRLEN_PP(str)-1;
+       broken_str = (char *) emalloc(str_len+1);
+       begin=end=str_len-1;
        target = broken_str;
                
        while (1) {
@@ -3891,11 +3861,11 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
        efree(heb_str);
 
        if (convert_newlines) {
-               php_char_to_str(broken_str, Z_STRLEN_PP(str),'\n', "<br />\n", 7, return_value);
+               php_char_to_str(broken_str, str_len,'\n', "<br />\n", 7, return_value);
                efree(broken_str);
        } else {
                Z_STRVAL_P(return_value) = broken_str;
-               Z_STRLEN_P(return_value) = Z_STRLEN_PP(str);
+               Z_STRLEN_P(return_value) = str_len;
                Z_TYPE_P(return_value) = IS_STRING;
        }
 }
@@ -3922,48 +3892,44 @@ PHP_FUNCTION(hebrevc)
 PHP_FUNCTION(nl2br)
 {
        /* in brief this inserts <br /> before matched regexp \n\r?|\r\n? */
-       zval    **zstr;
        char    *tmp, *str;
        int     new_length;
        char    *end, *target;
        int     repl_cnt = 0;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstr) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       int     str_len;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+               return;
        }
        
-       convert_to_string_ex(zstr);
-
-       str = Z_STRVAL_PP(zstr);
-       end = str + Z_STRLEN_PP(zstr);
+       tmp = str;
+       end = str + str_len;
        
        /* it is really faster to scan twice and allocate mem once insted scanning once
           and constantly reallocing */
-       while (str < end) {
-               if (*str == '\r') {
-                       if (*(str+1) == '\n') {
-                               str++;
+       while (tmp < end) {
+               if (*tmp == '\r') {
+                       if (*(tmp+1) == '\n') {
+                               tmp++;
                        }
                        repl_cnt++;
-               } else if (*str == '\n') {
-                       if (*(str+1) == '\r') {
-                               str++;
+               } else if (*tmp == '\n') {
+                       if (*(tmp+1) == '\r') {
+                               tmp++;
                        }
                        repl_cnt++;
                }
                
-               str++;
+               tmp++;
        }
        
        if (repl_cnt == 0) {
-               RETURN_STRINGL(Z_STRVAL_PP(zstr), Z_STRLEN_PP(zstr), 1);
+               RETURN_STRINGL(str, str_len, 1);
        }
 
-       new_length = Z_STRLEN_PP(zstr) + repl_cnt * (sizeof("<br />") - 1);
+       new_length = str_len + repl_cnt * (sizeof("<br />") - 1);
        tmp = target = emalloc(new_length + 1);
 
-       str = Z_STRVAL_PP(zstr);
-
        while (str < end) {
                switch (*str) {
                        case '\r':
@@ -3997,32 +3963,26 @@ PHP_FUNCTION(nl2br)
 PHP_FUNCTION(strip_tags)
 {
        char *buf;
-       zval **str, **allow=NULL;
+       char *str;
+       zval **allow=NULL;
        char *allowed_tags=NULL;
        int allowed_tags_len=0;
+       int str_len;
        size_t retval_len;
 
-       switch (ZEND_NUM_ARGS()) {
-               case 1:
-                       if (zend_get_parameters_ex(1, &str) == FAILURE) {
-                               RETURN_FALSE;
-                       }
-                       break;
-               case 2:
-                       if (zend_get_parameters_ex(2, &str, &allow) == FAILURE) {
-                               RETURN_FALSE;
-                       }
-                       convert_to_string_ex(allow);
-                       allowed_tags = Z_STRVAL_PP(allow);
-                       allowed_tags_len = Z_STRLEN_PP(allow);
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
-                       break;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Z", &str, &str_len, &allow) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(str);
-       buf = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
-       retval_len = php_strip_tags_ex(buf, Z_STRLEN_PP(str), NULL, allowed_tags, allowed_tags_len, 0);
+       
+       /* To maintain a certain BC, we allow anything for the second parameter and return original string */
+       if (allow != NULL) {
+               convert_to_string_ex(allow);
+               allowed_tags = Z_STRVAL_PP(allow);
+               allowed_tags_len = Z_STRLEN_PP(allow);
+       }
+
+       buf = estrndup(str, str_len);
+       retval_len = php_strip_tags_ex(buf, str_len, NULL, allowed_tags, allowed_tags_len, 0);
        RETURN_STRINGL(buf, retval_len, 0);
 }
 /* }}} */
@@ -4135,24 +4095,23 @@ PHP_FUNCTION(setlocale)
    Parses GET/POST/COOKIE data and sets global variables */
 PHP_FUNCTION(parse_str)
 {
-       zval **arg;
-       zval **arrayArg;
+       char *arg;
+       zval **arrayArg = NULL;
        zval *sarg;
        char *res = NULL;
-       int argCount;
+       int arglen;
 
-       argCount = ZEND_NUM_ARGS();
-       if (argCount < 1 || argCount > 2 || zend_get_parameters_ex(argCount, &arg, &arrayArg) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Z", &arg, &arglen, &arrayArg) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(arg);
-       sarg = *arg;
-       if (Z_STRVAL_P(sarg) && *Z_STRVAL_P(sarg)) {
-               res = estrndup(Z_STRVAL_P(sarg), Z_STRLEN_P(sarg));
+       if (!arglen) {
+               return;
        }
 
-       if (argCount == 1) {
+       res = estrndup(arg, arglen);
+
+       if (arrayArg == NULL) {
                zval tmp;
 
                if (!EG(active_symbol_table)) {
@@ -4496,45 +4455,39 @@ reg_char:
    Returns the input string repeat mult times */
 PHP_FUNCTION(str_repeat)
 {
-       zval            **input_str;            /* Input string */
-       zval            **mult;                 /* Multiplier */
+       char            *input_str;             /* Input string */
+       int             input_len;
+       int             mult;                   /* Multiplier */
        char            *result;                /* Resulting string */
        size_t          result_len;             /* Length of the resulting string */
        
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &input_str, &mult) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &input_str, &input_len, &mult) == FAILURE) {
+               return;
        }
-       
-       /* Make sure we're dealing with proper types */
-       convert_to_string_ex(input_str);
-       convert_to_long_ex(mult);
-       
-       if (Z_LVAL_PP(mult) < 0) {
+
+       if (mult < 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second argument has to be greater than or equal to 0");
                return;
        }
 
        /* Don't waste our time if it's empty */
-       if (Z_STRLEN_PP(input_str) == 0)
-               RETURN_STRINGL("", 0, 1);
-       
        /* ... or if the multiplier is zero */
-       if (Z_LVAL_PP(mult) == 0)
-               RETURN_STRINGL("", 0, 1);
-       
+       if (input_len == 0 || mult == 0)
+               RETURN_EMPTY_STRING();
+
        /* Initialize the result string */      
-       result_len = Z_STRLEN_PP(input_str) * Z_LVAL_PP(mult);
-       result = (char *)safe_emalloc(Z_STRLEN_PP(input_str), Z_LVAL_PP(mult), 1);
+       result_len = input_len * mult;
+       result = (char *)safe_emalloc(input_len, mult, 1);
        
        /* Heavy optimization for situations where input string is 1 byte long */
-       if (Z_STRLEN_PP(input_str) == 1) {
-               memset(result, *(Z_STRVAL_PP(input_str)), Z_LVAL_PP(mult)); 
+       if (input_len == 1) {
+               memset(result, *(input_str), mult); 
        } else {
                char *s, *e, *ee;
                int l=0;
-               memcpy(result, Z_STRVAL_PP(input_str), Z_STRLEN_PP(input_str));
+               memcpy(result, input_str, input_len);
                s = result;
-               e = result + Z_STRLEN_PP(input_str);
+               e = result + input_len;
                ee = result + result_len;
                
                while (e<ee) {
@@ -4554,33 +4507,24 @@ PHP_FUNCTION(str_repeat)
    Returns info about what characters are used in input */
 PHP_FUNCTION(count_chars)
 {
-       zval **input, **mode;
+       char *input;
        int chars[256];
-       int ac=ZEND_NUM_ARGS();
        int mymode=0;
        unsigned char *buf;
        int len, inx;
        char retstr[256];
        int retlen=0;
 
-       if (ac < 1 || ac > 2 || zend_get_parameters_ex(ac, &input, &mode) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &input, &len, &mymode) == FAILURE) {
+               return;
        }
-       
-       convert_to_string_ex(input);
 
-       if (ac == 2) {
-               convert_to_long_ex(mode);
-               mymode = Z_LVAL_PP(mode);
-               
-               if (mymode < 0 || mymode > 4) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown mode");
-                       RETURN_FALSE;
-               }
+       if (mymode < 0 || mymode > 4) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown mode");
+               RETURN_FALSE;
        }
-       
-       len = Z_STRLEN_PP(input);
-       buf = (unsigned char *) Z_STRVAL_PP(input);
+
+       buf = (unsigned char *) input;
        memset((void*) chars, 0, sizeof(chars));
 
        while (len > 0) {
@@ -4631,17 +4575,15 @@ PHP_FUNCTION(count_chars)
  */
 static void php_strnatcmp(INTERNAL_FUNCTION_PARAMETERS, int fold_case)
 {
-       zval **s1, **s2;
+       char *s1, *s2;
+       int s1_len, s2_len;
 
-       if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &s1, &s2) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(s1);
-       convert_to_string_ex(s2);
-
-       RETURN_LONG(strnatcmp_ex(Z_STRVAL_PP(s1), Z_STRLEN_PP(s1),
-                                                        Z_STRVAL_PP(s2), Z_STRLEN_PP(s2),
+       RETURN_LONG(strnatcmp_ex(s1, s1_len,
+                                                        s2, s2_len,
                                                         fold_case));
 }
 /* }}} */
@@ -4752,63 +4694,60 @@ PHP_FUNCTION(strnatcasecmp)
    Returns the number of times a substring occurs in the string */
 PHP_FUNCTION(substr_count)
 {
-       zval **haystack, **needle, **offset, **length;
+       char *haystack, *needle;
+       int offset = 0;
+       int length;
        int ac = ZEND_NUM_ARGS();
        int count = 0;
+       int haystack_len, needle_len;
        char *p, *endp, cmp;
 
-       if (ac < 2 || ac > 4 || zend_get_parameters_ex(ac, &haystack, &needle, &offset, &length) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &haystack, &haystack_len, &needle, &needle_len, &offset, &length) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(haystack);
-       convert_to_string_ex(needle);
-
-       if (Z_STRLEN_PP(needle) == 0) {
+       if (needle_len == 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty substring");
                RETURN_FALSE;
        }
        
-       p = Z_STRVAL_PP(haystack);
-       endp = p + Z_STRLEN_PP(haystack);
-       
-       if (ac > 2) {
-               convert_to_long_ex(offset);
-               if (Z_LVAL_PP(offset) < 0) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset should be greater than or equal to 0");
-                       RETURN_FALSE;           
-               }
+       p = haystack;
+       endp = p + haystack_len;
 
-               if (Z_LVAL_PP(offset) > Z_STRLEN_PP(haystack)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length", Z_LVAL_PP(offset));
+       if (offset < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset should be greater than or equal to 0");
+               RETURN_FALSE;           
+       }
+
+       if (offset > haystack_len) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length", offset);
+               RETURN_FALSE;           
+       }
+       p += offset;
+
+       if (ac == 4) {
+
+               if (length <= 0) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0");
                        RETURN_FALSE;           
                }
-               p += Z_LVAL_PP(offset);
-
-               if (ac == 4) {
-                       convert_to_long_ex(length);
-                       if (Z_LVAL_PP(length) <= 0) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0");
-                               RETURN_FALSE;           
-                       }
-                       if (Z_LVAL_PP(length) > (Z_STRLEN_PP(haystack) - Z_LVAL_PP(offset))) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length", Z_LVAL_PP(length));
-                               RETURN_FALSE;
-                       }
-                       endp = p + Z_LVAL_PP(length);
+               if (length > (haystack_len - offset)) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length", length);
+                       RETURN_FALSE;
                }
+               endp = p + length;
        }
        
-       if (Z_STRLEN_PP(needle) == 1) {
-               cmp = Z_STRVAL_PP(needle)[0];
+       if (needle_len == 1) {
+               cmp = needle[0];
 
                while ((p = memchr(p, cmp, endp - p))) {
                        count++;
                        p++;
                }
        } else {
-               while ((p = php_memnstr(p, Z_STRVAL_PP(needle), Z_STRLEN_PP(needle), endp))) {
-                       p += Z_STRLEN_PP(needle);
+               while ((p = php_memnstr(p, needle, needle_len, endp))) {
+                       p += needle_len;
                        count++;
                }
        }
@@ -4822,10 +4761,9 @@ PHP_FUNCTION(substr_count)
 PHP_FUNCTION(str_pad)
 {
        /* Input arguments */
-       zval **input,                           /* Input string */
-                **pad_length,                  /* Length to pad to */
-                **pad_string,                  /* Padding string */
-                **pad_type;                    /* Padding type (left/right/both) */
+       char *input;                            /* Input string */
+       int  input_len;
+       int      pad_length;                    /* Length to pad to */
        
        /* Helper variables */
        int        num_pad_chars;               /* Number of padding characters (total - input size) */
@@ -4836,45 +4774,30 @@ PHP_FUNCTION(str_pad)
        int        pad_type_val = STR_PAD_RIGHT; /* The padding type value */
        int        i, left_pad=0, right_pad=0;
 
-
-       if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 4 ||
-               zend_get_parameters_ex(ZEND_NUM_ARGS(), &input, &pad_length, &pad_string, &pad_type) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|sl", &input, &input_len, &pad_length,
+                                                                                                                                 &pad_str_val, &pad_str_len, &pad_type_val) == FAILURE) {
+               return;
        }
 
-       /* Perform initial conversion to expected data types. */
-       convert_to_string_ex(input);
-       convert_to_long_ex(pad_length);
-
-       num_pad_chars = Z_LVAL_PP(pad_length) - Z_STRLEN_PP(input);
+       num_pad_chars = pad_length - input_len;
 
        /* If resulting string turns out to be shorter than input string,
           we simply copy the input and return. */
-       if (Z_LVAL_PP(pad_length) < 0 || num_pad_chars < 0) {
-               RETURN_ZVAL(*input, 1, 0);
+       if (pad_length < 0 || num_pad_chars < 0) {
+               RETURN_STRINGL(input, input_len, 1);
        }
 
-       /* Setup the padding string values if specified. */
-       if (ZEND_NUM_ARGS() > 2) {
-               convert_to_string_ex(pad_string);
-               if (Z_STRLEN_PP(pad_string) == 0) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty");
-                       return;
-               }
-               pad_str_val = Z_STRVAL_PP(pad_string);
-               pad_str_len = Z_STRLEN_PP(pad_string);
-
-               if (ZEND_NUM_ARGS() > 3) {
-                       convert_to_long_ex(pad_type);
-                       pad_type_val = Z_LVAL_PP(pad_type);
-                       if (pad_type_val < STR_PAD_LEFT || pad_type_val > STR_PAD_BOTH) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH");
-                               return;
-                       }
-               }
+       if (pad_str_len == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty");
+               return;
+       }
+       
+       if (pad_type_val < STR_PAD_LEFT || pad_type_val > STR_PAD_BOTH) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH");
+               return;
        }
 
-       result = (char *)emalloc(Z_STRLEN_PP(input) + num_pad_chars + 1);
+       result = (char *)emalloc(input_len + num_pad_chars + 1);
 
        /* We need to figure out the left/right padding lengths. */
        switch (pad_type_val) {
@@ -4899,8 +4822,8 @@ PHP_FUNCTION(str_pad)
                result[result_len++] = pad_str_val[i % pad_str_len];
 
        /* Then we copy the input string. */
-       memcpy(result + result_len, Z_STRVAL_PP(input), Z_STRLEN_PP(input));
-       result_len += Z_STRLEN_PP(input);
+       memcpy(result + result_len, input, input_len);
+       result_len += input_len;
 
        /* Finally, we pad on the right. */
        for (i = 0; i < right_pad; i++)
@@ -4952,14 +4875,14 @@ static char rot13_to[] = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM";
    Perform the rot13 transform on a string */
 PHP_FUNCTION(str_rot13)
 {
-       zval **arg;
+       char *arg;
+       int arglen;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arglen) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(arg);
-       RETVAL_ZVAL(*arg, 1, 0);
+       RETVAL_STRINGL(arg, arglen, 1);
 
        php_strtr(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), rot13_from, rot13_to, 52);
 }
@@ -4995,14 +4918,14 @@ static void php_string_shuffle(char *str, long len TSRMLS_DC) /* {{{ */
    Shuffles string. One permutation of all possible is created */
 PHP_FUNCTION(str_shuffle)
 {
-       zval **arg;
-       
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg)) {
-               WRONG_PARAM_COUNT;
+       char *arg;
+       int arglen;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arglen) == FAILURE) {
+               return;
        }
-       
-       convert_to_string_ex(arg);
-       RETVAL_ZVAL(*arg, 1, 0);
+
+       RETVAL_STRINGL(arg, arglen, 1);
        if (Z_STRLEN_P(return_value) > 1) { 
                php_string_shuffle(Z_STRVAL_P(return_value), (long) Z_STRLEN_P(return_value) TSRMLS_CC);
        }
index ba45504c3ad6f27ac6d727b6dc02781782bbcffe..74e0dbfe1af2995de11d5de2524c270df5b81827 100644 (file)
Binary files a/ext/standard/tests/strings/addcslashes_001.phpt and b/ext/standard/tests/strings/addcslashes_001.phpt differ
index 8f314fb557c0c70c09b2bb8a6f89fee4a605c4c3..db2b6f88589f6c5814c15e4c8f9dd3019c45f8e5 100644 (file)
@@ -19,12 +19,12 @@ echo "Done\n";
 --EXPECTF--
 *** Testing error conditions ***
 
-Warning: Wrong parameter count for addcslashes() in %s on line %d
+Warning: addcslashes() expects exactly 2 parameters, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for addcslashes() in %s on line %d
+Warning: addcslashes() expects exactly 2 parameters, 1 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for addcslashes() in %s on line %d
+Warning: addcslashes() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 Done
index b5127169340d240b732ddb6e79264f04496287b4..4ebd8878565791e76928aef46753c5fd56320d7d 100644 (file)
@@ -33,12 +33,12 @@ echo "Done\n";
 
 -- Testing addslashes() function with Zero arguments --
 
-Warning: Wrong parameter count for addslashes() in %s on line %d
+Warning: addslashes() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing addslashes() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for addslashes() in %s on line %d
+Warning: addslashes() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 string(15) ""hello"\"world""
 Done
index a86f86d058784995919b2267d26527c8ed0c675c..4c98a6c0986dd932c6b958f9bccf1af05c7c7763 100644 (file)
@@ -125,24 +125,24 @@ string(7) "1.06E-9"
 string(3) "0.5"
 -- Iteration 10 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: addslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 11 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: addslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 12 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: addslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 13 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: addslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 14 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: addslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 15 --
 string(1) "1"
 -- Iteration 16 --
@@ -162,7 +162,9 @@ string(0) ""
 -- Iteration 23 --
 string(7) "obj\'ct"
 -- Iteration 24 --
-string(%d) "Resource id #%d"
+
+Warning: addslashes() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 -- Iteration 25 --
 string(0) ""
 -- Iteration 26 --
index 8c91b4cba07af3092aa78cb29d8424655e632fe8..b5015a010822e72352edfbc5b593e3280fbabcf9 100644 (file)
Binary files a/ext/standard/tests/strings/chr_ord.phpt and b/ext/standard/tests/strings/chr_ord.phpt differ
index c600dddda6b436d64b711522c22848955fad8b10..8aa2820d3187d6de6104f84b1bd9d6b8b184e90c 100644 (file)
@@ -25,10 +25,10 @@ echo "Done";
 *** Testing nl2br() : error conditions ***
 
 -- Testing nl2br() function with Zero arguments --
-Warning: Wrong parameter count for nl2br() in %s on line %d
+Warning: nl2br() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing nl2br() function with more than expected no. of arguments --
-Warning: Wrong parameter count for nl2br() in %s on line %d
+Warning: nl2br() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 Done
index 066d642cdcb511a0fd50cd4de353ea51595da8fb..beebe03fe217c03092b3bfd02dbae6594aaad78c 100644 (file)
@@ -109,24 +109,24 @@ string(7) "1.06E-9"
 string(3) "0.5"
 -- Iteration 10 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: nl2br() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 11 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: nl2br() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 12 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: nl2br() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 13 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: nl2br() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 14 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: nl2br() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 15 --
 string(0) ""
 -- Iteration 16 --
@@ -140,7 +140,9 @@ string(1) "1"
 -- Iteration 20 --
 string(0) ""
 -- Iteration 21 --
-string(%d) "Resource id #%d"
+
+Warning: nl2br() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 -- Iteration 22 --
 string(9) "My String"
 -- Iteration 23 --
index 4d4fee8f90934d881ff301001408126906c683d1..b127424dfea0346d92eab886abdc949e36faf5f6 100644 (file)
@@ -48,13 +48,13 @@ var_dump($Data = str_ireplace("\n", "<br>", $Data));
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for str_ireplace() in %s on line %d
+Warning: str_ireplace() expects at least 3 parameters, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for str_ireplace() in %s on line %d
+Warning: str_ireplace() expects at least 3 parameters, 1 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for str_ireplace() in %s on line %d
+Warning: str_ireplace() expects at least 3 parameters, 2 given in %s on line %d
 NULL
 string(0) ""
 string(8) "aaaaaaaT"
index 5509d9d9e201f1745ffe983a9ae0daf98d895ac6..645d8ff385798f2c52399fba53d69657cdf1b572 100644 (file)
Binary files a/ext/standard/tests/strings/str_pad.phpt and b/ext/standard/tests/strings/str_pad.phpt differ
index 49d0ab09868e43e23c5983c1c7e71e9e586063a4..73c193b6d73ae9f6233ed8331df32ac939104812 100644 (file)
Binary files a/ext/standard/tests/strings/str_repeat.phpt and b/ext/standard/tests/strings/str_repeat.phpt differ
index 2408c82f09f9d11a72542787979809f1b5721902..830378b9a1541e9b5dee67f270960df0c899cd86 100644 (file)
@@ -940,18 +940,18 @@ string(5) "FOUND"
 string(5) "FOUND"
 
 *** Testing error conditions ***
-Warning: Wrong parameter count for str_replace() in %s on line %d
+Warning: str_replace() expects at least 3 parameters, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for str_replace() in %s on line %d
+Warning: str_replace() expects at least 3 parameters, 1 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for str_replace() in %s on line %d
+Warning: str_replace() expects at least 3 parameters, 1 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for str_replace() in %s on line %d
+Warning: str_replace() expects at least 3 parameters, 2 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for str_replace() in %s on line %d
+Warning: str_replace() expects at most 4 parameters, 5 given in %s on line %d
 NULL
 Done
index 2f159cd0cde380ea6deb1f4c6b6f6e331289c3b2..c45cbb115a15c8b229eed60a1e42dd9fcb730c0b 100644 (file)
@@ -30,11 +30,11 @@ echo "Done";
 
 -- Testing strip_tags() function with Zero arguments --
 
-Warning: Wrong parameter count for strip_tags() in %s on line %d
+Warning: strip_tags() expects at least 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing strip_tags() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for strip_tags() in %s on line %d
+Warning: strip_tags() expects at most 2 parameters, 3 given in %s on line %d
 NULL
 Done
index 9b34ef4509c578094dde9aef36c55c527740274c..2601a964b08280ea17d922202e64e283e5e22403 100644 (file)
@@ -112,24 +112,24 @@ string(7) "1.06E-9"
 string(3) "0.5"
 -- Iteration 10 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 11 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 12 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 13 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 14 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 15 --
 string(0) ""
 -- Iteration 16 --
@@ -153,5 +153,7 @@ string(0) ""
 -- Iteration 25 --
 string(0) ""
 -- Iteration 26 --
-string(%d) "Resource id #%d"
+
+Warning: strip_tags() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 Done
index 1065fc626e5082e238c7f8ad3ca6398f3c42db1b..813dd73ad88d4893b4e1ff45e610b0ca00a33d1b 100644 (file)
@@ -112,34 +112,24 @@ string(7) "1.06E-9"
 string(3) "0.5"
 -- Iteration 10 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 11 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 12 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 13 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 14 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 15 --
 string(0) ""
 -- Iteration 16 --
@@ -163,5 +153,7 @@ string(0) ""
 -- Iteration 25 --
 string(0) ""
 -- Iteration 26 --
-string(%d) "Resource id #%d"
+
+Warning: strip_tags() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 Done
index cef09fc2df8bb38ce2df772da6cb727eeeb913fa..99d877fd696be49829a7d0fffa5a6402f9f4e3f2 100644 (file)
@@ -32,12 +32,12 @@ echo "Done\n";
 
 -- Testing stripslashes() function with Zero arguments --
 
-Warning: Wrong parameter count for stripslashes() in %s on line %d
+Warning: stripslashes() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing stripslashes() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for stripslashes() in %s on line %d
+Warning: stripslashes() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 string(18) "\"hello\"\"world\""
 Done
index 4d58fd7a0543e60dfe317752a3380f6bdcd0e6d0..ed56dce6ed51b2546f6955f557762bb34fc7a00c 100644 (file)
@@ -125,24 +125,24 @@ string(7) "1.06E-9"
 string(3) "0.5"
 -- Iteration 10 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: stripslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 11 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: stripslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 12 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: stripslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 13 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: stripslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 14 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: stripslashes() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 15 --
 string(1) "1"
 -- Iteration 16 --
@@ -162,7 +162,9 @@ string(0) ""
 -- Iteration 23 --
 string(6) "obj'ct"
 -- Iteration 24 --
-string(%d) "Resource id #%d"
+
+Warning: stripslashes() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 -- Iteration 25 --
 string(0) ""
 -- Iteration 26 --
index e1fd9f8248eca4b3fd107074512ae1ccb7816273..ef64e80afda59434d645ec1ef474da29390b15da 100644 (file)
@@ -18,10 +18,10 @@ echo "*** Done ***";
 --EXPECTF--
 *** Testing strrev() : error conditions ***
 -- Testing strrev() function with Zero arguments --
-Warning: Wrong parameter count for strrev() in %s on line %d
+Warning: strrev() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing strrev() function with more than expected no. of arguments --
-Warning: Wrong parameter count for strrev() in %s on line %d
+Warning: strrev() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 *** Done ***
index bf4a7fad9fbb74a6b0ee025ce433ed6356fba083..fa347cd2fd0203d8e8c26e9bf5e27ce49eb1fe21 100644 (file)
@@ -119,28 +119,28 @@ string(3) "5.0"
 
 -- Iterator 10 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "yarrA"
+Warning: strrev() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iterator 11 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "yarrA"
+Warning: strrev() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iterator 12 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "yarrA"
+Warning: strrev() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iterator 13 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "yarrA"
+Warning: strrev() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iterator 14 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "yarrA"
+Warning: strrev() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iterator 15 --
 string(0) ""
@@ -170,7 +170,9 @@ string(0) ""
 string(6) "tcejbo"
 
 -- Iterator 24 --
-string(%d) "%d# di ecruoseR"
+
+Warning: strrev() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 
 -- Iterator 25 --
 string(0) ""
index 8466a92011bbc7fc3a54ffeac9b71bd309695ecb..f34085fb4deff581a602ef546cfc72fd310fa604 100644 (file)
@@ -28,14 +28,14 @@ echo "Done";
 *** Testing strtr() : error conditions ***
 
 -- Testing strtr() function with Zero arguments --
-Warning: Wrong parameter count for strtr() in %s on line %d
+Warning: strtr() expects at least 2 parameters, 0 given in %s on line %d
 NULL
 
 -- Testing strtr() function with less than expected no. of arguments --
-Warning: Wrong parameter count for strtr() in %s on line %d
+Warning: strtr() expects at least 2 parameters, 1 given in %s on line %d
 NULL
 
 -- Testing strtr() function with more than expected no. of arguments --
-Warning: Wrong parameter count for strtr() in %s on line %d
+Warning: strtr() expects at most 3 parameters, 4 given in %s on line %d
 NULL
 Done
index 7bd1704734a1dd207fd4ba7d0916562e98796805..7c99e5b9ee442ef903d56ca89b514f1ce81749b9 100644 (file)
@@ -104,16 +104,16 @@ string(5) "-ma.5"
 string(12) "ta5aaaaaaaaa"
 -- Iteration 7 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Arr0y"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 8 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Arr0y"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 9 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Arr0y"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 10 --
 string(1) "t"
 -- Iteration 11 --
@@ -129,7 +129,9 @@ string(0) ""
 -- Iteration 16 --
 string(13) "s02ple objec1"
 -- Iteration 17 --
-string(%d) "Resource id #%d"
+
+Warning: strtr() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 -- Iteration 18 --
 string(0) ""
 -- Iteration 19 --
index 04b742f31219e88e0b47d8686edb6ef530776fad..cf7e777cee44008afbe794b7aba17be0628a9c21 100644 (file)
@@ -111,18 +111,18 @@ string(6) "000105"
 
 -- Iteration 7 --
 
-Notice: Array to string conversion in %s on line %d
-string(6) "ay2Arr"
+Warning: strtr() expects parameter 3 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 8 --
 
-Notice: Array to string conversion in %s on line %d
-string(6) "ay2Arr"
+Warning: strtr() expects parameter 3 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 9 --
 
-Notice: Array to string conversion in %s on line %d
-string(6) "ay2Arr"
+Warning: strtr() expects parameter 3 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 10 --
 string(6) "0121tm"
@@ -146,7 +146,9 @@ string(6) "012atm"
 string(6) "plesam"
 
 -- Iteration 17 --
-string(6) "ourRes"
+
+Warning: strtr() expects parameter 3 to be string, resource given in %s on line %d
+NULL
 
 -- Iteration 18 --
 string(6) "012atm"
index 0f5875c723ae0367bca90b3c3f05fbd8411eb95c..835b8b3fa7b74c45095d51f8997802d5c5e13aa4 100644 (file)
@@ -123,63 +123,43 @@ bool(false)
 
 -- Iteration 7 --
 
-Notice: Array to string conversion in %s on line %d
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 8 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 9 --
 
-Notice: Array to string conversion in %s on line %d
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 10 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 11 --
 
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
 -- Iteration 12 --
 string(1) "1"
@@ -224,10 +204,12 @@ Warning: strtr(): The second argument is not an array in %s on line %d
 bool(false)
 
 -- Iteration 19 --
-string(%d) "Resource id #%d"
 
-Warning: strtr(): The second argument is not an array in %s on line %d
-bool(false)
+Warning: strtr() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: strtr() expects parameter 1 to be string, resource given in %s on line %d
+NULL
 
 -- Iteration 20 --
 string(0) ""
index c6366d2ceea4a733e9b16cce5df29a02b2e19537..5a8db16a54ffa3f03e4de7087ef751e6e3ad2732 100644 (file)
Binary files a/ext/standard/tests/strings/substr.phpt and b/ext/standard/tests/strings/substr.phpt differ
index f8284c3a1da9c70fb2b340a3f01ad498ecfbd26c..6f7e7728b1bc6c9cd8d915ee6bdcdd9d8d8b2a2e 100644 (file)
@@ -30,12 +30,12 @@ echo "Done\n";
 --EXPECTF--
 *** Testing error conditions ***
 
-Warning: Wrong parameter count for substr_count() in %s on line %d
+Warning: substr_count() expects at least 2 parameters, 0 given in %s on line %d
 NULL
 
 Notice: Undefined variable: str in %s on line %d
 
-Warning: Wrong parameter count for substr_count() in %s on line %d
+Warning: substr_count() expects at most 4 parameters, 5 given in %s on line %d
 NULL
 
 Notice: Undefined variable: str in %s on line %d
@@ -55,8 +55,8 @@ bool(false)
 
 Notice: Undefined variable: str in %s on line %d
 
-Warning: substr_count(): Length should be greater than 0 in %s on line %d
-bool(false)
+Warning: substr_count() expects parameter 3 to be long, string given in %s on line %d
+NULL
 
 Notice: Undefined variable: str in %s on line %d
 
index cb6fc6bd3ede66644afac236c13e4964fc88d822..6277d4ddb5c6c6ff8e18136ab88b5eb903aa5fa1 100644 (file)
@@ -57,13 +57,25 @@ echo "Done\n";
 -- 3rd or 4th arg as string --
 int(1)
 int(1)
+
+Notice: A non well formed numeric value encountered in %s on line %d
 int(2)
+
+Notice: A non well formed numeric value encountered in %s on line %d
+
+Notice: A non well formed numeric value encountered in %s on line %d
 int(2)
 
 -- 3rd or 4th arg as NULL --
-int(2)
-int(0)
-int(2)
+
+Warning: substr_count() expects parameter 3 to be long, string given %s on line %d
+NULL
+
+Warning: substr_count() expects parameter 3 to be long, string given %s on line %d
+NULL
+
+Warning: substr_count() expects parameter 3 to be long, string given %s on line %d
+NULL
 int(0)
 int(2)
 
index cd6e7513c3d0f8a1b2915b4e3d6418d0754b25ff..69a388ce847aad4d89732abc56d42837184696a6 100644 (file)
@@ -31,12 +31,12 @@ echo "Done\n";
 
 -- Testing ucwords() function with Zero arguments --
 
-Warning: Wrong parameter count for ucwords() in %s on line %d
+Warning: ucwords() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing ucwords() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for ucwords() in %s on line %d
+Warning: ucwords() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 string(10) "string_val"
 Done
index b7d61ab5da0e3a6f938e54b5ba6f5c4a9f246c53..22c29163c45899d32532fbbdb0348d09cfe97dd3 100644 (file)
@@ -146,24 +146,24 @@ string(13) "1.07654321E-9"
 string(3) "0.5"
 -- Iteration 16 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: ucwords() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 17 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: ucwords() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 18 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: ucwords() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 19 --
 
-Notice: Array to string conversion in %s on line %d
-string(5) "Array"
+Warning: ucwords() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 20 --
 
-Notice: Array to string conversion in %s on line 101
-string(5) "Array"
+Warning: ucwords() expects parameter 1 to be string, array given in %s on line %d
+NULL
 -- Iteration 21 --
 string(1) "1"
 -- Iteration 22 --
@@ -195,5 +195,7 @@ string(0) ""
 -- Iteration 35 --
 string(0) ""
 -- Iteration 36 --
-string(%d) "Resource Id #%d"
-Done
\ No newline at end of file
+
+Warning: ucwords() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+Done