iliaa Tue, 15 Dec 2009 12:34:12 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=292162
Log: Fixed bu #50392 (date_create_from_format() enforces 6 digits for 'u' format character) Bug: http://bugs.php.net/50392 (Assigned) date_create_from_format enforces 6 digits for 'u' format character Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c U php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re A php/php-src/branches/PHP_5_3/ext/date/tests/bug50392.phpt U php/php-src/trunk/ext/date/lib/parse_date.c U php/php-src/trunk/ext/date/lib/parse_date.re A php/php-src/trunk/ext/date/tests/bug50392.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2009-12-15 12:31:32 UTC (rev 292161) +++ php/php-src/branches/PHP_5_3/NEWS 2009-12-15 12:34:12 UTC (rev 292162) @@ -40,6 +40,8 @@ seg fault). (davbrown4 at yahoo dot com, Felipe) - Fixed bug #50351 (performance regression handling objects, ten times slower in 5.3 than in 5.2). (Dmitry) +- Fixed bug #50392 (date_create_from_format() enforces 6 digits for 'u' + format character). (Ilia) - Fixed bug #50345 (nanosleep not detected properly on some solaris versions). (Jani) - Fixed bug #50340 (php.ini parser does not allow spaces in ini keys). (Jani) Modified: php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c 2009-12-15 12:31:32 UTC (rev 292161) +++ php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c 2009-12-15 12:34:12 UTC (rev 292162) @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Jul 29 16:20:12 2009 */ +/* Generated by re2c 0.13.5 on Mon Dec 14 07:41:45 2009 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -24086,15 +24086,15 @@ add_pbf_error(s, "A two digit second could not be found", string, begin); } break; - case 'u': /* six digit millisecond */ + case 'u': /* up to six digit millisecond */ { double f; char *tptr; TIMELIB_CHECK_NUMBER; tptr = ptr; - if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) { - add_pbf_error(s, "A six digit millisecond could not be found", string, begin); + if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr) < 1) { + add_pbf_error(s, "At least a single digit millisecond could not be found", string, begin); } else { s->time->f = (f / 1000000); } Modified: php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re 2009-12-15 12:31:32 UTC (rev 292161) +++ php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re 2009-12-15 12:34:12 UTC (rev 292162) @@ -1943,15 +1943,15 @@ add_pbf_error(s, "A two digit second could not be found", string, begin); } break; - case 'u': /* six digit millisecond */ + case 'u': /* up to six digit millisecond */ { double f; char *tptr; TIMELIB_CHECK_NUMBER; tptr = ptr; - if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) { - add_pbf_error(s, "A six digit millisecond could not be found", string, begin); + if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr) < 1) { + add_pbf_error(s, "At least a single digit millisecond could not be found", string, begin); } else { s->time->f = (f / 1000000); } Added: php/php-src/branches/PHP_5_3/ext/date/tests/bug50392.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/tests/bug50392.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/date/tests/bug50392.phpt 2009-12-15 12:34:12 UTC (rev 292162) @@ -0,0 +1,63 @@ +--TEST-- +Bug #50392 date_create_from_format enforces 6 digits for 'u' format character +--FILE-- +<?php +date_default_timezone_set('Europe/Bratislava'); + +$base = '2009-03-01 18:00:00'; + +for ($i = 0; $i < 8; $i++) { + var_dump(date_create_from_format('Y-m-d H:i:s.u', $base . '.' . str_repeat('1', $i))); +} +?> +--EXPECT-- +bool(false) +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +bool(false) Modified: php/php-src/trunk/ext/date/lib/parse_date.c =================================================================== --- php/php-src/trunk/ext/date/lib/parse_date.c 2009-12-15 12:31:32 UTC (rev 292161) +++ php/php-src/trunk/ext/date/lib/parse_date.c 2009-12-15 12:34:12 UTC (rev 292162) @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Jul 29 16:40:36 2009 */ +/* Generated by re2c 0.13.5 on Tue Dec 15 07:32:15 2009 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -24086,15 +24086,15 @@ add_pbf_error(s, "A two digit second could not be found", string, begin); } break; - case 'u': /* six digit millisecond */ + case 'u': /* up to six digit millisecond */ { double f; char *tptr; TIMELIB_CHECK_NUMBER; tptr = ptr; - if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) { - add_pbf_error(s, "A six digit millisecond could not be found", string, begin); + if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr) < 1) { + add_pbf_error(s, "At least a single digit millisecond could not be found", string, begin); } else { s->time->f = (f / 1000000); } Modified: php/php-src/trunk/ext/date/lib/parse_date.re =================================================================== --- php/php-src/trunk/ext/date/lib/parse_date.re 2009-12-15 12:31:32 UTC (rev 292161) +++ php/php-src/trunk/ext/date/lib/parse_date.re 2009-12-15 12:34:12 UTC (rev 292162) @@ -1943,15 +1943,15 @@ add_pbf_error(s, "A two digit second could not be found", string, begin); } break; - case 'u': /* six digit millisecond */ + case 'u': /* up to six digit millisecond */ { double f; char *tptr; TIMELIB_CHECK_NUMBER; tptr = ptr; - if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) { - add_pbf_error(s, "A six digit millisecond could not be found", string, begin); + if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr) < 1) { + add_pbf_error(s, "At least a single digit millisecond could not be found", string, begin); } else { s->time->f = (f / 1000000); } Added: php/php-src/trunk/ext/date/tests/bug50392.phpt =================================================================== --- php/php-src/trunk/ext/date/tests/bug50392.phpt (rev 0) +++ php/php-src/trunk/ext/date/tests/bug50392.phpt 2009-12-15 12:34:12 UTC (rev 292162) @@ -0,0 +1,63 @@ +--TEST-- +Bug #50392 date_create_from_format enforces 6 digits for 'u' format character +--FILE-- +<?php +date_default_timezone_set('Europe/Bratislava'); + +$base = '2009-03-01 18:00:00'; + +for ($i = 0; $i < 8; $i++) { + var_dump(date_create_from_format('Y-m-d H:i:s.u', $base . '.' . str_repeat('1', $i))); +} +?> +--EXPECT-- +bool(false) +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +object(DateTime)#2 (3) { + ["date"]=> + string(19) "2009-03-01 18:00:00" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(17) "Europe/Bratislava" +} +bool(false)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php