diff options
author | Derick Rethans <derick@php.net> | 2010-03-07 13:08:47 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2010-03-07 13:08:47 +0000 |
commit | baff5e6866a3503555c76f2439746fa918333eea (patch) | |
tree | 274f07844ef9677cf986d06b46f970693f77fcd2 | |
parent | 862f25123ee3b5cbbdb537720c2ab30d96a7c668 (diff) | |
download | php-git-baff5e6866a3503555c76f2439746fa918333eea.tar.gz |
- Fixed bug #50392 (date_create_from_format enforces 6 digits for 'u' format
character).
-rw-r--r-- | ext/date/lib/parse_date.c | 201 | ||||
-rw-r--r-- | ext/date/lib/parse_date.re | 5 | ||||
-rw-r--r-- | ext/date/tests/bug50392.phpt | 84 |
3 files changed, 137 insertions, 153 deletions
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index b85a428e87..3f04e40e0d 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Sat Mar 6 15:46:13 2010 */ +/* Generated by re2c 0.13.5 on Sun Mar 7 13:05:24 2010 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -24,6 +24,7 @@ #include <stdio.h> #include <ctype.h> +#include <math.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> @@ -840,11 +841,11 @@ static int scan(Scanner *s) std: s->tok = cursor; s->len = 0; -#line 966 "ext/date/lib/parse_date.re" +#line 967 "ext/date/lib/parse_date.re" -#line 848 "ext/date/lib/parse_date.c" +#line 849 "ext/date/lib/parse_date.c" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -964,7 +965,7 @@ std: } yy2: YYDEBUG(2, *YYCURSOR); -#line 1051 "ext/date/lib/parse_date.re" +#line 1052 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("firstdayof | lastdayof"); TIMELIB_INIT; @@ -980,7 +981,7 @@ yy2: TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 984 "ext/date/lib/parse_date.c" +#line 985 "ext/date/lib/parse_date.c" yy3: YYDEBUG(3, *YYCURSOR); ++YYCURSOR; @@ -1003,7 +1004,7 @@ yy3: } yy4: YYDEBUG(4, *YYCURSOR); -#line 1633 "ext/date/lib/parse_date.re" +#line 1634 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); @@ -1016,7 +1017,7 @@ yy4: TIMELIB_DEINIT; return TIMELIB_TIMEZONE; } -#line 1020 "ext/date/lib/parse_date.c" +#line 1021 "ext/date/lib/parse_date.c" yy5: YYDEBUG(5, *YYCURSOR); yych = *++YYCURSOR; @@ -1327,12 +1328,12 @@ yy12: if (yych <= '9') goto yy1385; yy13: YYDEBUG(13, *YYCURSOR); -#line 1728 "ext/date/lib/parse_date.re" +#line 1729 "ext/date/lib/parse_date.re" { add_error(s, "Unexpected character"); goto std; } -#line 1336 "ext/date/lib/parse_date.c" +#line 1337 "ext/date/lib/parse_date.c" yy14: YYDEBUG(14, *YYCURSOR); yych = *++YYCURSOR; @@ -2389,11 +2390,11 @@ yy49: if (yych <= '9') goto yy55; yy50: YYDEBUG(50, *YYCURSOR); -#line 1717 "ext/date/lib/parse_date.re" +#line 1718 "ext/date/lib/parse_date.re" { goto std; } -#line 2397 "ext/date/lib/parse_date.c" +#line 2398 "ext/date/lib/parse_date.c" yy51: YYDEBUG(51, *YYCURSOR); yych = *++YYCURSOR; @@ -2402,12 +2403,12 @@ yy52: YYDEBUG(52, *YYCURSOR); ++YYCURSOR; YYDEBUG(53, *YYCURSOR); -#line 1722 "ext/date/lib/parse_date.re" +#line 1723 "ext/date/lib/parse_date.re" { s->pos = cursor; s->line++; goto std; } -#line 2411 "ext/date/lib/parse_date.c" +#line 2412 "ext/date/lib/parse_date.c" yy54: YYDEBUG(54, *YYCURSOR); yych = *++YYCURSOR; @@ -2794,7 +2795,7 @@ yy72: if (yych == 's') goto yy74; yy73: YYDEBUG(73, *YYCURSOR); -#line 1701 "ext/date/lib/parse_date.re" +#line 1702 "ext/date/lib/parse_date.re" { timelib_ull i; DEBUG_OUTPUT("relative"); @@ -2809,7 +2810,7 @@ yy73: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2813 "ext/date/lib/parse_date.c" +#line 2814 "ext/date/lib/parse_date.c" yy74: YYDEBUG(74, *YYCURSOR); yych = *++YYCURSOR; @@ -3562,7 +3563,7 @@ yy167: } yy168: YYDEBUG(168, *YYCURSOR); -#line 1564 "ext/date/lib/parse_date.re" +#line 1565 "ext/date/lib/parse_date.re" { const timelib_relunit* relunit; DEBUG_OUTPUT("daytext"); @@ -3579,7 +3580,7 @@ yy168: TIMELIB_DEINIT; return TIMELIB_WEEKDAY; } -#line 3583 "ext/date/lib/parse_date.c" +#line 3584 "ext/date/lib/parse_date.c" yy169: YYDEBUG(169, *YYCURSOR); yych = *++YYCURSOR; @@ -4056,7 +4057,7 @@ yy194: } yy195: YYDEBUG(195, *YYCURSOR); -#line 1623 "ext/date/lib/parse_date.re" +#line 1624 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("monthtext"); TIMELIB_INIT; @@ -4065,7 +4066,7 @@ yy195: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 4069 "ext/date/lib/parse_date.c" +#line 4070 "ext/date/lib/parse_date.c" yy196: YYDEBUG(196, *YYCURSOR); ++YYCURSOR; @@ -4116,7 +4117,7 @@ yy199: } yy200: YYDEBUG(200, *YYCURSOR); -#line 1373 "ext/date/lib/parse_date.re" +#line 1374 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datetextual | datenoyear"); TIMELIB_INIT; @@ -4128,7 +4129,7 @@ yy200: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 4132 "ext/date/lib/parse_date.c" +#line 4133 "ext/date/lib/parse_date.c" yy201: YYDEBUG(201, *YYCURSOR); yyaccept = 6; @@ -4397,7 +4398,7 @@ yy223: } yy224: YYDEBUG(224, *YYCURSOR); -#line 1671 "ext/date/lib/parse_date.re" +#line 1672 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz"); @@ -4426,7 +4427,7 @@ yy224: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 4430 "ext/date/lib/parse_date.c" +#line 4431 "ext/date/lib/parse_date.c" yy225: YYDEBUG(225, *YYCURSOR); yyaccept = 7; @@ -5103,7 +5104,7 @@ yy280: YYDEBUG(280, *YYCURSOR); ++YYCURSOR; YYDEBUG(281, *YYCURSOR); -#line 1647 "ext/date/lib/parse_date.re" +#line 1648 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12"); TIMELIB_INIT; @@ -5126,7 +5127,7 @@ yy280: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 5130 "ext/date/lib/parse_date.c" +#line 5131 "ext/date/lib/parse_date.c" yy282: YYDEBUG(282, *YYCURSOR); yych = *++YYCURSOR; @@ -5299,7 +5300,7 @@ yy296: ++YYCURSOR; yy297: YYDEBUG(297, *YYCURSOR); -#line 1347 "ext/date/lib/parse_date.re" +#line 1348 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenoday"); TIMELIB_INIT; @@ -5311,7 +5312,7 @@ yy297: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 5315 "ext/date/lib/parse_date.c" +#line 5316 "ext/date/lib/parse_date.c" yy298: YYDEBUG(298, *YYCURSOR); yych = *++YYCURSOR; @@ -6521,7 +6522,7 @@ yy364: if (yych <= '9') goto yy367; yy366: YYDEBUG(366, *YYCURSOR); -#line 1487 "ext/date/lib/parse_date.re" +#line 1488 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pgtextshort"); TIMELIB_INIT; @@ -6533,7 +6534,7 @@ yy366: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 6537 "ext/date/lib/parse_date.c" +#line 6538 "ext/date/lib/parse_date.c" yy367: YYDEBUG(367, *YYCURSOR); yych = *++YYCURSOR; @@ -7117,7 +7118,7 @@ yy392: } yy393: YYDEBUG(393, *YYCURSOR); -#line 1543 "ext/date/lib/parse_date.re" +#line 1544 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("ago"); TIMELIB_INIT; @@ -7137,7 +7138,7 @@ yy393: TIMELIB_DEINIT; return TIMELIB_AGO; } -#line 7141 "ext/date/lib/parse_date.c" +#line 7142 "ext/date/lib/parse_date.c" yy394: YYDEBUG(394, *YYCURSOR); yyaccept = 5; @@ -8822,7 +8823,7 @@ yy454: ++YYCURSOR; yy455: YYDEBUG(455, *YYCURSOR); -#line 1257 "ext/date/lib/parse_date.re" +#line 1258 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash"); TIMELIB_INIT; @@ -8833,7 +8834,7 @@ yy455: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 8837 "ext/date/lib/parse_date.c" +#line 8838 "ext/date/lib/parse_date.c" yy456: YYDEBUG(456, *YYCURSOR); yyaccept = 0; @@ -9393,7 +9394,7 @@ yy475: } yy476: YYDEBUG(476, *YYCURSOR); -#line 1386 "ext/date/lib/parse_date.re" +#line 1387 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenoyearrev"); TIMELIB_INIT; @@ -9404,7 +9405,7 @@ yy476: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 9408 "ext/date/lib/parse_date.c" +#line 9409 "ext/date/lib/parse_date.c" yy477: YYDEBUG(477, *YYCURSOR); yyaccept = 10; @@ -9545,7 +9546,7 @@ yy488: YYDEBUG(488, *YYCURSOR); ++YYCURSOR; YYDEBUG(489, *YYCURSOR); -#line 1113 "ext/date/lib/parse_date.re" +#line 1114 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12"); TIMELIB_INIT; @@ -9561,7 +9562,7 @@ yy488: TIMELIB_DEINIT; return TIMELIB_TIME12; } -#line 9565 "ext/date/lib/parse_date.c" +#line 9566 "ext/date/lib/parse_date.c" yy490: YYDEBUG(490, *YYCURSOR); yyaccept = 11; @@ -9574,7 +9575,7 @@ yy490: } yy491: YYDEBUG(491, *YYCURSOR); -#line 1150 "ext/date/lib/parse_date.re" +#line 1151 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long"); @@ -9599,7 +9600,7 @@ yy491: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 9603 "ext/date/lib/parse_date.c" +#line 9604 "ext/date/lib/parse_date.c" yy492: YYDEBUG(492, *YYCURSOR); yyaccept = 11; @@ -9909,7 +9910,7 @@ yy523: YYDEBUG(523, *YYCURSOR); ++YYCURSOR; YYDEBUG(524, *YYCURSOR); -#line 1130 "ext/date/lib/parse_date.re" +#line 1131 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("mssqltime"); TIMELIB_INIT; @@ -9928,7 +9929,7 @@ yy523: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 9932 "ext/date/lib/parse_date.c" +#line 9933 "ext/date/lib/parse_date.c" yy525: YYDEBUG(525, *YYCURSOR); yyaccept = 11; @@ -10034,7 +10035,7 @@ yy534: if (yych <= '9') goto yy541; yy535: YYDEBUG(535, *YYCURSOR); -#line 1308 "ext/date/lib/parse_date.re" +#line 1309 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datefull"); TIMELIB_INIT; @@ -10047,7 +10048,7 @@ yy535: TIMELIB_DEINIT; return TIMELIB_DATE_FULL; } -#line 10051 "ext/date/lib/parse_date.c" +#line 10052 "ext/date/lib/parse_date.c" yy536: YYDEBUG(536, *YYCURSOR); yych = *++YYCURSOR; @@ -10784,7 +10785,7 @@ yy605: YYDEBUG(606, *YYCURSOR); ++YYCURSOR; YYDEBUG(607, *YYCURSOR); -#line 1322 "ext/date/lib/parse_date.re" +#line 1323 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pointed date YYYY"); TIMELIB_INIT; @@ -10795,7 +10796,7 @@ yy605: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 10799 "ext/date/lib/parse_date.c" +#line 10800 "ext/date/lib/parse_date.c" yy608: YYDEBUG(608, *YYCURSOR); yyaccept = 11; @@ -10831,7 +10832,7 @@ yy611: if (yych <= '9') goto yy605; yy612: YYDEBUG(612, *YYCURSOR); -#line 1334 "ext/date/lib/parse_date.re" +#line 1335 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pointed date YY"); TIMELIB_INIT; @@ -10843,7 +10844,7 @@ yy612: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 10847 "ext/date/lib/parse_date.c" +#line 10848 "ext/date/lib/parse_date.c" yy613: YYDEBUG(613, *YYCURSOR); yyaccept = 11; @@ -11484,7 +11485,7 @@ yy656: } yy657: YYDEBUG(657, *YYCURSOR); -#line 1295 "ext/date/lib/parse_date.re" +#line 1296 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("gnudateshort"); TIMELIB_INIT; @@ -11496,7 +11497,7 @@ yy657: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 11500 "ext/date/lib/parse_date.c" +#line 11501 "ext/date/lib/parse_date.c" yy658: YYDEBUG(658, *YYCURSOR); yyaccept = 13; @@ -11602,7 +11603,7 @@ yy666: } yy667: YYDEBUG(667, *YYCURSOR); -#line 1242 "ext/date/lib/parse_date.re" +#line 1243 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("americanshort | american"); TIMELIB_INIT; @@ -11616,7 +11617,7 @@ yy667: TIMELIB_DEINIT; return TIMELIB_AMERICAN; } -#line 11620 "ext/date/lib/parse_date.c" +#line 11621 "ext/date/lib/parse_date.c" yy668: YYDEBUG(668, *YYCURSOR); yyaccept = 14; @@ -11849,7 +11850,7 @@ yy700: if (yych <= ':') goto yy704; yy701: YYDEBUG(701, *YYCURSOR); -#line 1513 "ext/date/lib/parse_date.re" +#line 1514 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("clf"); @@ -11869,7 +11870,7 @@ yy701: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 11873 "ext/date/lib/parse_date.c" +#line 11874 "ext/date/lib/parse_date.c" yy702: YYDEBUG(702, *YYCURSOR); yych = *++YYCURSOR; @@ -12421,7 +12422,7 @@ yy763: } yy764: YYDEBUG(764, *YYCURSOR); -#line 1269 "ext/date/lib/parse_date.re" +#line 1270 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("iso8601date2"); TIMELIB_INIT; @@ -12433,7 +12434,7 @@ yy764: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 12437 "ext/date/lib/parse_date.c" +#line 12438 "ext/date/lib/parse_date.c" yy765: YYDEBUG(765, *YYCURSOR); yych = *++YYCURSOR; @@ -12472,7 +12473,7 @@ yy771: YYDEBUG(771, *YYCURSOR); ++YYCURSOR; YYDEBUG(772, *YYCURSOR); -#line 1500 "ext/date/lib/parse_date.re" +#line 1501 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pgtextreverse"); TIMELIB_INIT; @@ -12484,7 +12485,7 @@ yy771: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 12488 "ext/date/lib/parse_date.c" +#line 12489 "ext/date/lib/parse_date.c" yy773: YYDEBUG(773, *YYCURSOR); yych = *++YYCURSOR; @@ -12622,7 +12623,7 @@ yy783: } yy784: YYDEBUG(784, *YYCURSOR); -#line 1534 "ext/date/lib/parse_date.re" +#line 1535 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("year4"); TIMELIB_INIT; @@ -12630,7 +12631,7 @@ yy784: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 12634 "ext/date/lib/parse_date.c" +#line 12635 "ext/date/lib/parse_date.c" yy785: YYDEBUG(785, *YYCURSOR); yych = *++YYCURSOR; @@ -12781,7 +12782,7 @@ yy793: } yy794: YYDEBUG(794, *YYCURSOR); -#line 1360 "ext/date/lib/parse_date.re" +#line 1361 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenodayrev"); TIMELIB_INIT; @@ -12793,7 +12794,7 @@ yy794: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 12797 "ext/date/lib/parse_date.c" +#line 12798 "ext/date/lib/parse_date.c" yy795: YYDEBUG(795, *YYCURSOR); yych = *++YYCURSOR; @@ -13008,7 +13009,7 @@ yy814: if (yych <= '7') goto yy817; yy815: YYDEBUG(815, *YYCURSOR); -#line 1468 "ext/date/lib/parse_date.re" +#line 1469 "ext/date/lib/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweek"); @@ -13026,7 +13027,7 @@ yy815: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 13030 "ext/date/lib/parse_date.c" +#line 13031 "ext/date/lib/parse_date.c" yy816: YYDEBUG(816, *YYCURSOR); yych = *++YYCURSOR; @@ -13036,7 +13037,7 @@ yy817: YYDEBUG(817, *YYCURSOR); ++YYCURSOR; YYDEBUG(818, *YYCURSOR); -#line 1449 "ext/date/lib/parse_date.re" +#line 1450 "ext/date/lib/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweekday"); @@ -13054,7 +13055,7 @@ yy817: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 13058 "ext/date/lib/parse_date.c" +#line 13059 "ext/date/lib/parse_date.c" yy819: YYDEBUG(819, *YYCURSOR); yych = *++YYCURSOR; @@ -13118,7 +13119,7 @@ yy821: } yy822: YYDEBUG(822, *YYCURSOR); -#line 1436 "ext/date/lib/parse_date.re" +#line 1437 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pgydotd"); TIMELIB_INIT; @@ -13130,7 +13131,7 @@ yy822: TIMELIB_DEINIT; return TIMELIB_PG_YEARDAY; } -#line 13134 "ext/date/lib/parse_date.c" +#line 13135 "ext/date/lib/parse_date.c" yy823: YYDEBUG(823, *YYCURSOR); yych = *++YYCURSOR; @@ -13233,7 +13234,7 @@ yy842: ++YYCURSOR; yy843: YYDEBUG(843, *YYCURSOR); -#line 1410 "ext/date/lib/parse_date.re" +#line 1411 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif"); @@ -13258,7 +13259,7 @@ yy843: TIMELIB_DEINIT; return TIMELIB_XMLRPC_SOAP; } -#line 13262 "ext/date/lib/parse_date.c" +#line 13263 "ext/date/lib/parse_date.c" yy844: YYDEBUG(844, *YYCURSOR); yych = *++YYCURSOR; @@ -13520,7 +13521,7 @@ yy848: } yy849: YYDEBUG(849, *YYCURSOR); -#line 1398 "ext/date/lib/parse_date.re" +#line 1399 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenocolon"); TIMELIB_INIT; @@ -13531,7 +13532,7 @@ yy849: TIMELIB_DEINIT; return TIMELIB_DATE_NOCOLON; } -#line 13535 "ext/date/lib/parse_date.c" +#line 13536 "ext/date/lib/parse_date.c" yy850: YYDEBUG(850, *YYCURSOR); yych = *++YYCURSOR; @@ -14451,7 +14452,7 @@ yy973: if (yych <= '9') goto yy996; yy974: YYDEBUG(974, *YYCURSOR); -#line 1282 "ext/date/lib/parse_date.re" +#line 1283 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("gnudateshorter"); TIMELIB_INIT; @@ -14463,7 +14464,7 @@ yy974: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 14467 "ext/date/lib/parse_date.c" +#line 14468 "ext/date/lib/parse_date.c" yy975: YYDEBUG(975, *YYCURSOR); yyaccept = 22; @@ -15472,7 +15473,7 @@ yy1066: } yy1068: YYDEBUG(1068, *YYCURSOR); -#line 1176 "ext/date/lib/parse_date.re" +#line 1177 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("gnunocolon"); TIMELIB_INIT; @@ -15494,7 +15495,7 @@ yy1068: TIMELIB_DEINIT; return TIMELIB_GNU_NOCOLON; } -#line 15498 "ext/date/lib/parse_date.c" +#line 15499 "ext/date/lib/parse_date.c" yy1069: YYDEBUG(1069, *YYCURSOR); yych = *++YYCURSOR; @@ -15586,7 +15587,7 @@ yy1075: } yy1076: YYDEBUG(1076, *YYCURSOR); -#line 1222 "ext/date/lib/parse_date.re" +#line 1223 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("iso8601nocolon"); @@ -15605,7 +15606,7 @@ yy1076: TIMELIB_DEINIT; return TIMELIB_ISO_NOCOLON; } -#line 15609 "ext/date/lib/parse_date.c" +#line 15610 "ext/date/lib/parse_date.c" yy1077: YYDEBUG(1077, *YYCURSOR); yyaccept = 25; @@ -16503,7 +16504,7 @@ yy1117: } yy1118: YYDEBUG(1118, *YYCURSOR); -#line 1606 "ext/date/lib/parse_date.re" +#line 1607 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16519,7 +16520,7 @@ yy1118: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16523 "ext/date/lib/parse_date.c" +#line 16524 "ext/date/lib/parse_date.c" yy1119: YYDEBUG(1119, *YYCURSOR); ++YYCURSOR; @@ -16570,7 +16571,7 @@ yy1126: YYDEBUG(1126, *YYCURSOR); ++YYCURSOR; YYDEBUG(1127, *YYCURSOR); -#line 1091 "ext/date/lib/parse_date.re" +#line 1092 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16591,7 +16592,7 @@ yy1126: TIMELIB_DEINIT; return TIMELIB_WEEK_DAY_OF_MONTH; } -#line 16595 "ext/date/lib/parse_date.c" +#line 16596 "ext/date/lib/parse_date.c" yy1128: YYDEBUG(1128, *YYCURSOR); yyaccept = 26; @@ -16699,7 +16700,7 @@ yy1141: } yy1142: YYDEBUG(1142, *YYCURSOR); -#line 1582 "ext/date/lib/parse_date.re" +#line 1583 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16722,7 +16723,7 @@ yy1142: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16726 "ext/date/lib/parse_date.c" +#line 16727 "ext/date/lib/parse_date.c" yy1143: YYDEBUG(1143, *YYCURSOR); yych = *++YYCURSOR; @@ -19208,7 +19209,7 @@ yy1294: goto yy1298; yy1295: YYDEBUG(1295, *YYCURSOR); -#line 1068 "ext/date/lib/parse_date.re" +#line 1069 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("backof | frontof"); TIMELIB_INIT; @@ -19230,7 +19231,7 @@ yy1295: TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 19234 "ext/date/lib/parse_date.c" +#line 19235 "ext/date/lib/parse_date.c" yy1296: YYDEBUG(1296, *YYCURSOR); yyaccept = 28; @@ -20796,7 +20797,7 @@ yy1385: if (yych <= '9') goto yy1385; yy1387: YYDEBUG(1387, *YYCURSOR); -#line 1026 "ext/date/lib/parse_date.re" +#line 1027 "ext/date/lib/parse_date.re" { timelib_ull i; @@ -20820,7 +20821,7 @@ yy1387: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 20824 "ext/date/lib/parse_date.c" +#line 20825 "ext/date/lib/parse_date.c" yy1388: YYDEBUG(1388, *YYCURSOR); yych = *++YYCURSOR; @@ -21256,7 +21257,7 @@ yy1416: ++YYCURSOR; yy1417: YYDEBUG(1417, *YYCURSOR); -#line 1014 "ext/date/lib/parse_date.re" +#line 1015 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("tomorrow"); TIMELIB_INIT; @@ -21267,7 +21268,7 @@ yy1417: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21271 "ext/date/lib/parse_date.c" +#line 21272 "ext/date/lib/parse_date.c" yy1418: YYDEBUG(1418, *YYCURSOR); yych = *++YYCURSOR; @@ -21302,7 +21303,7 @@ yy1419: } yy1420: YYDEBUG(1420, *YYCURSOR); -#line 1004 "ext/date/lib/parse_date.re" +#line 1005 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("midnight | today"); TIMELIB_INIT; @@ -21311,7 +21312,7 @@ yy1420: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21315 "ext/date/lib/parse_date.c" +#line 21316 "ext/date/lib/parse_date.c" yy1421: YYDEBUG(1421, *YYCURSOR); yych = *++YYCURSOR; @@ -23135,7 +23136,7 @@ yy1499: } yy1500: YYDEBUG(1500, *YYCURSOR); -#line 983 "ext/date/lib/parse_date.re" +#line 984 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("now"); TIMELIB_INIT; @@ -23143,7 +23144,7 @@ yy1500: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23147 "ext/date/lib/parse_date.c" +#line 23148 "ext/date/lib/parse_date.c" yy1501: YYDEBUG(1501, *YYCURSOR); yych = *++YYCURSOR; @@ -23282,7 +23283,7 @@ yy1507: } yy1508: YYDEBUG(1508, *YYCURSOR); -#line 992 "ext/date/lib/parse_date.re" +#line 993 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("noon"); TIMELIB_INIT; @@ -23293,7 +23294,7 @@ yy1508: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23297 "ext/date/lib/parse_date.c" +#line 23298 "ext/date/lib/parse_date.c" yy1509: YYDEBUG(1509, *YYCURSOR); yyaccept = 0; @@ -23773,7 +23774,7 @@ yy1530: ++YYCURSOR; yy1531: YYDEBUG(1531, *YYCURSOR); -#line 971 "ext/date/lib/parse_date.re" +#line 972 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("yesterday"); TIMELIB_INIT; @@ -23784,7 +23785,7 @@ yy1531: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23788 "ext/date/lib/parse_date.c" +#line 23789 "ext/date/lib/parse_date.c" yy1532: YYDEBUG(1532, *YYCURSOR); yyaccept = 0; @@ -23930,7 +23931,7 @@ yy1537: goto yy1531; } } -#line 1732 "ext/date/lib/parse_date.re" +#line 1733 "ext/date/lib/parse_date.re" } @@ -24153,10 +24154,10 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim TIMELIB_CHECK_NUMBER; tptr = ptr; - if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) { + if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr < 1)) { add_pbf_error(s, "A six digit millisecond could not be found", string, begin); } else { - s->time->f = (f / 1000000); + s->time->f = (f / pow(10, (ptr - tptr))); } } break; diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 94f9dafc46..29cc832738 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -22,6 +22,7 @@ #include <stdio.h> #include <ctype.h> +#include <math.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> @@ -1951,10 +1952,10 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim TIMELIB_CHECK_NUMBER; tptr = ptr; - if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) { + if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr < 1)) { add_pbf_error(s, "A six digit millisecond could not be found", string, begin); } else { - s->time->f = (f / 1000000); + s->time->f = (f / pow(10, (ptr - tptr))); } } break; diff --git a/ext/date/tests/bug50392.phpt b/ext/date/tests/bug50392.phpt index 8d10923e03..4fa506ef55 100644 --- a/ext/date/tests/bug50392.phpt +++ b/ext/date/tests/bug50392.phpt @@ -7,57 +7,39 @@ 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))); + $string = $base . '.' . str_repeat($i, $i); + echo $string, "\n- "; + $result = date_parse_from_format('Y-m-d H:i:s.u', $string); + echo $result['fraction'] ? $result['fraction'] : 'X', "\n"; + foreach( $result['errors'] as $error ) { + echo "- ", $error, "\n"; + } + echo "\n"; } ?> --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) +2009-03-01 18:00:00. +- X +- Data missing + +2009-03-01 18:00:00.1 +- 0.1 + +2009-03-01 18:00:00.22 +- 0.22 + +2009-03-01 18:00:00.333 +- 0.333 + +2009-03-01 18:00:00.4444 +- 0.4444 + +2009-03-01 18:00:00.55555 +- 0.55555 + +2009-03-01 18:00:00.666666 +- 0.666666 + +2009-03-01 18:00:00.7777777 +- 0.777777 +- Trailing data |