]> granicus.if.org Git - php/commitdiff
- Fixed bug #48802 (printf() returns incorrect outputted length)
authorJani Taskinen <jani@php.net>
Thu, 23 Jul 2009 14:54:04 +0000 (14:54 +0000)
committerJani Taskinen <jani@php.net>
Thu, 23 Jul 2009 14:54:04 +0000 (14:54 +0000)
NEWS
ext/standard/formatted_print.c
sapi/cli/php_cli.c

diff --git a/NEWS b/NEWS
index fa5989167217c852c9b57fa0291e38c341fdf239..af3b0cfc9b8811be8c75c06d265074314900b51e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PHP                                                                        NEWS
   option is an array). (David Zülke)
 - Fixed bug #48913 (Too long error code strings in pdo_odbc driver).
   (naf at altlinux dot ru, Felipe)
+- Fixed bug #48802 (printf() returns incorrect outputted length). (Jani)
 - Fixed bug #48788 (RecursiveDirectoryIterator doesn't descend into symlinked
   directories). (Ilia)
 - Fixed bug #48763 (ZipArchive produces corrupt archive). (dani dot church at 
index 1da0b37eee752963b7c041dedf658cb0b624d172..8666735e0730ea60359f9acc1adbcaea8a535808 100644 (file)
@@ -700,14 +700,14 @@ PHP_FUNCTION(vsprintf)
 PHP_FUNCTION(user_printf)
 {
        char *result;
-       int len;
+       int len, rlen;
        
        if ((result=php_formatted_print(ht, &len, 0, 0 TSRMLS_CC))==NULL) {
                RETURN_FALSE;
        }
-       PHPWRITE(result, len);
+       rlen = PHPWRITE(result, len);
        efree(result);
-       RETURN_LONG(len);
+       RETURN_LONG(rlen);
 }
 /* }}} */
 
@@ -716,14 +716,14 @@ PHP_FUNCTION(user_printf)
 PHP_FUNCTION(vprintf)
 {
        char *result;
-       int len;
+       int len, rlen;
        
        if ((result=php_formatted_print(ht, &len, 1, 0 TSRMLS_CC))==NULL) {
                RETURN_FALSE;
        }
-       PHPWRITE(result, len);
+       rlen = PHPWRITE(result, len);
        efree(result);
-       RETURN_LONG(len);
+       RETURN_LONG(rlen);
 }
 /* }}} */
 
index 0561416f1275e904a350e5f7ab562126eeafb1fb..1545dabe03060cb205af1b49f1637326cef6a4b8 100644 (file)
@@ -298,7 +298,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{
                remaining -= ret;
        }
 
-       return str_length;
+       return (ptr - str);
 }
 /* }}} */