]> granicus.if.org Git - php/commitdiff
- New parameter parsing API (for *printf())
authorFelipe Pena <felipe@php.net>
Sun, 10 Aug 2008 21:48:22 +0000 (21:48 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 10 Aug 2008 21:48:22 +0000 (21:48 +0000)
ext/standard/formatted_print.c
ext/standard/tests/strings/printf.phpt
ext/standard/tests/strings/sprintf_error.phpt
ext/standard/tests/strings/vfprintf_error4.phpt
ext/standard/tests/strings/vsprintf_error.phpt

index d8d1fb88b0a3f3db963f29d93f1e77f84a153082..49bc3dad5b6b0134142a70de99af8adc97524173 100644 (file)
@@ -980,16 +980,13 @@ static zstr php_u_formatted_print(int ht, int *len, int use_array, int format_of
        int always_sign;
        zstr result_str;
 
-       argc = ZEND_NUM_ARGS();
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
+               return NULL_ZSTR;
+       }
 
        /* verify the number of args */
        if ((use_array && argc != (2 + format_offset)) 
                        || (!use_array && argc < (1 + format_offset))) {
-               WRONG_PARAM_COUNT_WITH_RETVAL(NULL_ZSTR);
-       }
-       args = (zval ***)safe_emalloc(argc, sizeof(zval *), 0);
-
-       if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
                efree(args);
                WRONG_PARAM_COUNT_WITH_RETVAL(NULL_ZSTR);
        }
@@ -1364,19 +1361,19 @@ PHP_FUNCTION(vprintf)
 PHP_FUNCTION(fprintf)
 {
        php_stream *stream;
-       zval **arg1, **arg2;
+       zval *arg1, **arg2;
        zstr result;
        int len, ret;
        
        if (ZEND_NUM_ARGS() < 2) {
                WRONG_PARAM_COUNT;
        }
-       
-       if (zend_get_parameters_ex(2, &arg1, &arg2)==FAILURE) {
+
+       if (zend_parse_parameters(2 TSRMLS_CC, "rZ", &arg1, &arg2) == FAILURE) {
                RETURN_FALSE;
        }
        
-       php_stream_from_zval(stream, arg1);
+       php_stream_from_zval(stream, &arg1);
 
        if (Z_TYPE_PP(arg2) != IS_STRING && Z_TYPE_PP(arg2) != IS_UNICODE) {
                convert_to_text_ex(arg2);
@@ -1406,7 +1403,7 @@ PHP_FUNCTION(fprintf)
 PHP_FUNCTION(vfprintf)
 {
        php_stream *stream;
-       zval **arg1, **arg2;
+       zval *arg1, **arg2;
        zstr result;
        int len, ret;
        
@@ -1414,11 +1411,11 @@ PHP_FUNCTION(vfprintf)
                WRONG_PARAM_COUNT;
        }
        
-       if (zend_get_parameters_ex(2, &arg1, &arg2)==FAILURE) {
+       if (zend_parse_parameters(2 TSRMLS_CC, "rZ", &arg1, &arg2) == FAILURE) {
                RETURN_FALSE;
        }
        
-       php_stream_from_zval(stream, arg1);
+       php_stream_from_zval(stream, &arg1);
 
        if (Z_TYPE_PP(arg2) != IS_STRING && Z_TYPE_PP(arg2) != IS_UNICODE) {
                convert_to_text_ex(arg2);
index c6858eea56b01a47419a751b5d02eb5571e11d2b..d2e6143ce1cb202f9889d9e5d27a7be04ce5db38 100755 (executable)
@@ -227,7 +227,7 @@ printf("%d", $tempstring);
 --EXPECTF--
 *** Output for zero argument ***
 
-Warning: Wrong parameter count for printf() in %s on line %d
+Warning: printf() expects at least %d parameter, %d given in %s on line %d
 
 *** Output for insufficient number of arguments ***
 
index 1200ab27a689b8d95c6c53e7b103a6c21960c092..f7f9e37e7704f617e8cbfe3dd49245527d509060 100644 (file)
@@ -39,7 +39,7 @@ echo "Done";
 
 -- Testing sprintf() function with Zero arguments --
 
-Warning: Wrong parameter count for sprintf() in %s on line %d
+Warning: sprintf() expects at least %d parameter, %d given in %s on line %d
 bool(false)
 
 -- Testing sprintf() function with less than expected no. of arguments --
index 384d9cd7406b743eaa0aee6e39b0bf8ef61df008..57be8f7e3c368d35f7021687fd2edc608b6eec38 100644 (file)
@@ -36,7 +36,7 @@ unlink( $file );
 --EXPECTF--
 -- Testing vfprintf() function with other strangeties  --
 
-Warning: vfprintf(): supplied argument is not a valid stream resource in %s on line %d
+Warning: vfprintf() expects parameter 1 to be resource, Unicode string given in %s on line %d
 bool(false)
 
 Warning: vfprintf(): Zero is not a valid argument number in %s on line %d
index 0ece4a420f0a44cc419c045e99b823005f82e35b..8d581474b402cd1f9ef6eb6e784bca89d5f946e9 100644 (file)
@@ -31,7 +31,7 @@ echo "Done";
 
 -- Testing vsprintf() function with Zero arguments --
 
-Warning: Wrong parameter count for vsprintf() in %s on line %d
+Warning: vsprintf() expects at least %d parameter, %d given in %s on line %d
 bool(false)
 
 -- Testing vsprintf() function with less than expected no. of arguments --