felipe Mon, 02 Nov 2009 17:37:32 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=290150
Log: - Fixed bug #49244 (Floating point NaN cause garbage characters). (patch by Sjoerd) Bug: http://bugs.php.net/49244 (Assigned) [PATCH] Floating point NaN cause garbage characters Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/standard/formatted_print.c A php/php-src/branches/PHP_5_2/ext/standard/tests/bug49244.phpt U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/standard/formatted_print.c A php/php-src/branches/PHP_5_3/ext/standard/tests/bug49244.phpt U php/php-src/trunk/ext/standard/formatted_print.c A php/php-src/trunk/ext/standard/tests/bug49244.phpt Modified: php/php-src/branches/PHP_5_2/NEWS =================================================================== --- php/php-src/branches/PHP_5_2/NEWS 2009-11-02 16:12:40 UTC (rev 290149) +++ php/php-src/branches/PHP_5_2/NEWS 2009-11-02 17:37:32 UTC (rev 290150) @@ -57,6 +57,7 @@ - Fixed bug #49528 (UTF-16 strings prefixed by BOMs wrongly converted). (Moriyoshi) - Fixed bug #49332 (Build error with Snow Leopard). (Scott) +- Fixed bug #49244 (Floating point NaN cause garbage characters). (Sjoerd) - Fixed bug #48805 (IPv6 socket transport is not working). (Ilia) - Fixed bug #48764 (PDO_pgsql::query() always uses implicit prepared statements if v3 proto available). (Matteo, Mark Kirkwood) Modified: php/php-src/branches/PHP_5_2/ext/standard/formatted_print.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/standard/formatted_print.c 2009-11-02 16:12:40 UTC (rev 290149) +++ php/php-src/branches/PHP_5_2/ext/standard/formatted_print.c 2009-11-02 17:37:32 UTC (rev 290150) @@ -232,14 +232,14 @@ if (zend_isnan(number)) { is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); return; } if (zend_isinf(number)) { is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); return; } Added: php/php-src/branches/PHP_5_2/ext/standard/tests/bug49244.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/standard/tests/bug49244.phpt (rev 0) +++ php/php-src/branches/PHP_5_2/ext/standard/tests/bug49244.phpt 2009-11-02 17:37:32 UTC (rev 290150) @@ -0,0 +1,32 @@ +--TEST-- +Bug #49244 (Floating point NaN cause garbage characters) +--FILE-- +<?php + +for ($i = 0; $i < 10; $i++) { + printf("{%f} %1\$f\n", pow(-1.0, 0.3)); + printf(b"{%f} %1\$f\n", pow(-1.0, 0.3)); +} + +?> +--EXPECT-- +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN Property changes on: php/php-src/branches/PHP_5_2/ext/standard/tests/bug49244.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2009-11-02 16:12:40 UTC (rev 290149) +++ php/php-src/branches/PHP_5_3/NEWS 2009-11-02 17:37:32 UTC (rev 290150) @@ -32,6 +32,7 @@ - Fixed bug #49800 (SimpleXML allow (un)serialize() calls without warning). (Ilia, wmeler at wp-sa dot pl) - Fixed bug #49647 (DOMUserData does not exist). (Rob) +- Fixed bug #49244 (Floating point NaN cause garbage characters). (Sjoerd) - Fixed bug #49224 (Compile error due to old DNS functions on AIX systems). (Scott) Modified: php/php-src/branches/PHP_5_3/ext/standard/formatted_print.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/formatted_print.c 2009-11-02 16:12:40 UTC (rev 290149) +++ php/php-src/branches/PHP_5_3/ext/standard/formatted_print.c 2009-11-02 17:37:32 UTC (rev 290150) @@ -232,14 +232,14 @@ if (zend_isnan(number)) { is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); return; } if (zend_isinf(number)) { is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); return; } Added: php/php-src/branches/PHP_5_3/ext/standard/tests/bug49244.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/bug49244.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/bug49244.phpt 2009-11-02 17:37:32 UTC (rev 290150) @@ -0,0 +1,32 @@ +--TEST-- +Bug #49244 (Floating point NaN cause garbage characters) +--FILE-- +<?php + +for ($i = 0; $i < 10; $i++) { + printf("{%f} %1\$f\n", pow(-1.0, 0.3)); + printf(b"{%f} %1\$f\n", pow(-1.0, 0.3)); +} + +?> +--EXPECT-- +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN Property changes on: php/php-src/branches/PHP_5_3/ext/standard/tests/bug49244.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: php/php-src/trunk/ext/standard/formatted_print.c =================================================================== --- php/php-src/trunk/ext/standard/formatted_print.c 2009-11-02 16:12:40 UTC (rev 290149) +++ php/php-src/trunk/ext/standard/formatted_print.c 2009-11-02 17:37:32 UTC (rev 290150) @@ -365,14 +365,14 @@ if (zend_isnan(number)) { is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); return; } if (zend_isinf(number)) { is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); return; } @@ -455,7 +455,7 @@ UChar *nan = USTR_MAKE("NaN"); is_negative = (number<0); php_u_sprintf_appendstring(buffer, pos, size, nan, 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); efree(nan); return; } @@ -464,7 +464,7 @@ UChar *inf = USTR_MAKE("INF"); is_negative = (number<0); php_u_sprintf_appendstring(buffer, pos, size, inf, 3, 0, padding, - alignment, precision, is_negative, 0, always_sign); + alignment, 3, is_negative, 0, always_sign); efree(inf); return; } Added: php/php-src/trunk/ext/standard/tests/bug49244.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/bug49244.phpt (rev 0) +++ php/php-src/trunk/ext/standard/tests/bug49244.phpt 2009-11-02 17:37:32 UTC (rev 290150) @@ -0,0 +1,32 @@ +--TEST-- +Bug #49244 (Floating point NaN cause garbage characters) +--FILE-- +<?php + +for ($i = 0; $i < 10; $i++) { + printf("{%f} %1\$f\n", pow(-1.0, 0.3)); + printf(b"{%f} %1\$f\n", pow(-1.0, 0.3)); +} + +?> +--EXPECT-- +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN +{NaN} NaN Property changes on: php/php-src/trunk/ext/standard/tests/bug49244.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php