From 2b9af967fbf12d9eb5fd74a7d6d31431307b0870 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 18 Aug 2014 18:22:14 +0100 Subject: [PATCH] Fixed bug #66985: Some timezones are no longer valid in PHP 5.5.10. --- ext/date/lib/parse_date.c | 244 ++++++++++++++++------------------- ext/date/lib/parse_date.re | 48 ++----- ext/date/tests/bug66985.phpt | 175 +++++++++++++++++++++++++ 3 files changed, 295 insertions(+), 172 deletions(-) create mode 100644 ext/date/tests/bug66985.phpt diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 015da88914..ecfdbefff3 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 Thu Jul 31 14:33:37 2014 */ +/* Generated by re2c 0.13.5 on Sun Aug 17 11:08:33 2014 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -670,7 +670,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S } } -const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst) +const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffset, int isdst) { int first_found = 0; const timelib_tz_lookup_table *tp, *first_found_elem = NULL; @@ -698,25 +698,6 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs return first_found_elem; } - for (tp = timelib_timezone_lookup; tp->name; tp++) { - if (tp->full_tz_name && strcasecmp(word, tp->full_tz_name) == 0) { - if (!first_found) { - first_found = 1; - first_found_elem = tp; - if (gmtoffset == -1) { - return tp; - } - } - if (tp->gmtoffset == gmtoffset) { - return tp; - } - } - } - if (first_found) { - return first_found_elem; - } - - /* Still didn't find anything, let's find the zone solely based on * offset/isdst then */ for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) { @@ -727,7 +708,7 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs return NULL; } -static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found) +static long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, int *found) { char *word; char *begin = *ptr, *end; @@ -741,7 +722,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found word = calloc(1, end - begin + 1); memcpy(word, begin, end - begin); - if ((tp = zone_search(word, -1, 0))) { + if ((tp = abbr_search(word, -1, 0))) { value = -tp->gmtoffset / 60; *dst = tp->type; value += tp->type * 60; @@ -785,33 +766,26 @@ long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found retval = timelib_parse_tz_cor(ptr); } else { int found = 0; - long offset; + long offset = 0; char *tz_abbr; t->is_localtime = 1; - offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found); + /* First, we lookup by abbreviation only */ + offset = timelib_lookup_abbr(ptr, dst, &tz_abbr, &found); if (found) { t->zone_type = TIMELIB_ZONETYPE_ABBR; + timelib_time_tz_abbr_update(t, tz_abbr); } -#if 0 - /* If we found a TimeZone identifier, use it */ - if (tz_name) { - t->tz_info = timelib_parse_tzfile(tz_name); - t->zone_type = TIMELIB_ZONETYPE_ID; - } -#endif - /* If we have a TimeZone identifier to start with, use it */ - if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) { + + /* Otherwise, we look if we have a TimeZone identifier */ + if (!found || strcmp("UTC", tz_abbr) == 0) { if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) { t->tz_info = res; t->zone_type = TIMELIB_ZONETYPE_ID; found++; } } - if (found && t->zone_type != TIMELIB_ZONETYPE_ID) { - timelib_time_tz_abbr_update(t, tz_abbr); - } free(tz_abbr); *tz_not_found = (found == 0); retval = offset; @@ -840,11 +814,11 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper) std: s->tok = cursor; s->len = 0; -#line 966 "ext/date/lib/parse_date.re" +#line 940 "ext/date/lib/parse_date.re" -#line 848 "ext/date/lib/parse_date.c" +#line 822 "ext/date/lib/parse_date.c" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -984,7 +958,7 @@ yy2: } yy3: YYDEBUG(3, *YYCURSOR); -#line 1646 "ext/date/lib/parse_date.re" +#line 1620 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); @@ -997,7 +971,7 @@ yy3: TIMELIB_DEINIT; return TIMELIB_TIMEZONE; } -#line 1001 "ext/date/lib/parse_date.c" +#line 975 "ext/date/lib/parse_date.c" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -1308,12 +1282,12 @@ yy11: if (yych <= '9') goto yy1385; yy12: YYDEBUG(12, *YYCURSOR); -#line 1741 "ext/date/lib/parse_date.re" +#line 1715 "ext/date/lib/parse_date.re" { add_error(s, "Unexpected character"); goto std; } -#line 1317 "ext/date/lib/parse_date.c" +#line 1291 "ext/date/lib/parse_date.c" yy13: YYDEBUG(13, *YYCURSOR); yych = *++YYCURSOR; @@ -2370,11 +2344,11 @@ yy48: if (yych <= '9') goto yy54; yy49: YYDEBUG(49, *YYCURSOR); -#line 1730 "ext/date/lib/parse_date.re" +#line 1704 "ext/date/lib/parse_date.re" { goto std; } -#line 2378 "ext/date/lib/parse_date.c" +#line 2352 "ext/date/lib/parse_date.c" yy50: YYDEBUG(50, *YYCURSOR); yych = *++YYCURSOR; @@ -2383,12 +2357,12 @@ yy51: YYDEBUG(51, *YYCURSOR); ++YYCURSOR; YYDEBUG(52, *YYCURSOR); -#line 1735 "ext/date/lib/parse_date.re" +#line 1709 "ext/date/lib/parse_date.re" { s->pos = cursor; s->line++; goto std; } -#line 2392 "ext/date/lib/parse_date.c" +#line 2366 "ext/date/lib/parse_date.c" yy53: YYDEBUG(53, *YYCURSOR); yych = *++YYCURSOR; @@ -2775,7 +2749,7 @@ yy71: if (yych == 's') goto yy73; yy72: YYDEBUG(72, *YYCURSOR); -#line 1714 "ext/date/lib/parse_date.re" +#line 1688 "ext/date/lib/parse_date.re" { timelib_ull i; DEBUG_OUTPUT("relative"); @@ -2790,7 +2764,7 @@ yy72: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2794 "ext/date/lib/parse_date.c" +#line 2768 "ext/date/lib/parse_date.c" yy73: YYDEBUG(73, *YYCURSOR); yych = *++YYCURSOR; @@ -3552,7 +3526,7 @@ yy165: } yy166: YYDEBUG(166, *YYCURSOR); -#line 1577 "ext/date/lib/parse_date.re" +#line 1551 "ext/date/lib/parse_date.re" { const timelib_relunit* relunit; DEBUG_OUTPUT("daytext"); @@ -3569,7 +3543,7 @@ yy166: TIMELIB_DEINIT; return TIMELIB_WEEKDAY; } -#line 3573 "ext/date/lib/parse_date.c" +#line 3547 "ext/date/lib/parse_date.c" yy167: YYDEBUG(167, *YYCURSOR); yych = *++YYCURSOR; @@ -4089,7 +4063,7 @@ yy192: } yy193: YYDEBUG(193, *YYCURSOR); -#line 1636 "ext/date/lib/parse_date.re" +#line 1610 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("monthtext"); TIMELIB_INIT; @@ -4098,7 +4072,7 @@ yy193: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 4102 "ext/date/lib/parse_date.c" +#line 4076 "ext/date/lib/parse_date.c" yy194: YYDEBUG(194, *YYCURSOR); ++YYCURSOR; @@ -4149,7 +4123,7 @@ yy197: } yy198: YYDEBUG(198, *YYCURSOR); -#line 1382 "ext/date/lib/parse_date.re" +#line 1356 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("datetextual | datenoyear"); @@ -4162,7 +4136,7 @@ yy198: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 4166 "ext/date/lib/parse_date.c" +#line 4140 "ext/date/lib/parse_date.c" yy199: YYDEBUG(199, *YYCURSOR); yyaccept = 6; @@ -4431,7 +4405,7 @@ yy221: } yy222: YYDEBUG(222, *YYCURSOR); -#line 1684 "ext/date/lib/parse_date.re" +#line 1658 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz"); @@ -4460,7 +4434,7 @@ yy222: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 4464 "ext/date/lib/parse_date.c" +#line 4438 "ext/date/lib/parse_date.c" yy223: YYDEBUG(223, *YYCURSOR); yyaccept = 7; @@ -5158,7 +5132,7 @@ yy277: YYDEBUG(277, *YYCURSOR); ++YYCURSOR; YYDEBUG(278, *YYCURSOR); -#line 1660 "ext/date/lib/parse_date.re" +#line 1634 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12"); TIMELIB_INIT; @@ -5181,7 +5155,7 @@ yy277: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 5185 "ext/date/lib/parse_date.c" +#line 5159 "ext/date/lib/parse_date.c" yy279: YYDEBUG(279, *YYCURSOR); yych = *++YYCURSOR; @@ -5359,7 +5333,7 @@ yy293: ++YYCURSOR; yy294: YYDEBUG(294, *YYCURSOR); -#line 1354 "ext/date/lib/parse_date.re" +#line 1328 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("datenoday"); @@ -5372,7 +5346,7 @@ yy294: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 5376 "ext/date/lib/parse_date.c" +#line 5350 "ext/date/lib/parse_date.c" yy295: YYDEBUG(295, *YYCURSOR); yych = *++YYCURSOR; @@ -6592,7 +6566,7 @@ yy361: if (yych <= '9') goto yy364; yy363: YYDEBUG(363, *YYCURSOR); -#line 1498 "ext/date/lib/parse_date.re" +#line 1472 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("pgtextshort"); @@ -6605,7 +6579,7 @@ yy363: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 6609 "ext/date/lib/parse_date.c" +#line 6583 "ext/date/lib/parse_date.c" yy364: YYDEBUG(364, *YYCURSOR); yych = *++YYCURSOR; @@ -7243,7 +7217,7 @@ yy391: } yy392: YYDEBUG(392, *YYCURSOR); -#line 1556 "ext/date/lib/parse_date.re" +#line 1530 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("ago"); TIMELIB_INIT; @@ -7263,7 +7237,7 @@ yy392: TIMELIB_DEINIT; return TIMELIB_AGO; } -#line 7267 "ext/date/lib/parse_date.c" +#line 7241 "ext/date/lib/parse_date.c" yy393: YYDEBUG(393, *YYCURSOR); yyaccept = 5; @@ -9013,7 +8987,7 @@ yy453: ++YYCURSOR; yy454: YYDEBUG(454, *YYCURSOR); -#line 1259 "ext/date/lib/parse_date.re" +#line 1233 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash"); TIMELIB_INIT; @@ -9024,7 +8998,7 @@ yy454: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 9028 "ext/date/lib/parse_date.c" +#line 9002 "ext/date/lib/parse_date.c" yy455: YYDEBUG(455, *YYCURSOR); yyaccept = 0; @@ -9584,7 +9558,7 @@ yy474: } yy475: YYDEBUG(475, *YYCURSOR); -#line 1396 "ext/date/lib/parse_date.re" +#line 1370 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenoyearrev"); TIMELIB_INIT; @@ -9595,7 +9569,7 @@ yy475: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 9599 "ext/date/lib/parse_date.c" +#line 9573 "ext/date/lib/parse_date.c" yy476: YYDEBUG(476, *YYCURSOR); yyaccept = 10; @@ -9736,7 +9710,7 @@ yy487: YYDEBUG(487, *YYCURSOR); ++YYCURSOR; YYDEBUG(488, *YYCURSOR); -#line 1114 "ext/date/lib/parse_date.re" +#line 1088 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12"); TIMELIB_INIT; @@ -9752,7 +9726,7 @@ yy487: TIMELIB_DEINIT; return TIMELIB_TIME12; } -#line 9756 "ext/date/lib/parse_date.c" +#line 9730 "ext/date/lib/parse_date.c" yy489: YYDEBUG(489, *YYCURSOR); yyaccept = 11; @@ -9765,7 +9739,7 @@ yy489: } yy490: YYDEBUG(490, *YYCURSOR); -#line 1151 "ext/date/lib/parse_date.re" +#line 1125 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long"); @@ -9790,7 +9764,7 @@ yy490: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 9794 "ext/date/lib/parse_date.c" +#line 9768 "ext/date/lib/parse_date.c" yy491: YYDEBUG(491, *YYCURSOR); yyaccept = 11; @@ -10100,7 +10074,7 @@ yy522: YYDEBUG(522, *YYCURSOR); ++YYCURSOR; YYDEBUG(523, *YYCURSOR); -#line 1131 "ext/date/lib/parse_date.re" +#line 1105 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("mssqltime"); TIMELIB_INIT; @@ -10119,7 +10093,7 @@ yy522: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 10123 "ext/date/lib/parse_date.c" +#line 10097 "ext/date/lib/parse_date.c" yy524: YYDEBUG(524, *YYCURSOR); yyaccept = 11; @@ -10225,7 +10199,7 @@ yy533: if (yych <= '9') goto yy540; yy534: YYDEBUG(534, *YYCURSOR); -#line 1313 "ext/date/lib/parse_date.re" +#line 1287 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("datefull"); @@ -10239,7 +10213,7 @@ yy534: TIMELIB_DEINIT; return TIMELIB_DATE_FULL; } -#line 10243 "ext/date/lib/parse_date.c" +#line 10217 "ext/date/lib/parse_date.c" yy535: YYDEBUG(535, *YYCURSOR); yych = *++YYCURSOR; @@ -10976,7 +10950,7 @@ yy604: YYDEBUG(605, *YYCURSOR); ++YYCURSOR; YYDEBUG(606, *YYCURSOR); -#line 1328 "ext/date/lib/parse_date.re" +#line 1302 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("pointed date YYYY"); TIMELIB_INIT; @@ -10987,7 +10961,7 @@ yy604: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 10991 "ext/date/lib/parse_date.c" +#line 10965 "ext/date/lib/parse_date.c" yy607: YYDEBUG(607, *YYCURSOR); yyaccept = 11; @@ -11023,7 +10997,7 @@ yy610: if (yych <= '9') goto yy604; yy611: YYDEBUG(611, *YYCURSOR); -#line 1340 "ext/date/lib/parse_date.re" +#line 1314 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("pointed date YY"); @@ -11036,7 +11010,7 @@ yy611: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 11040 "ext/date/lib/parse_date.c" +#line 11014 "ext/date/lib/parse_date.c" yy612: YYDEBUG(612, *YYCURSOR); yyaccept = 11; @@ -11677,7 +11651,7 @@ yy655: } yy656: YYDEBUG(656, *YYCURSOR); -#line 1299 "ext/date/lib/parse_date.re" +#line 1273 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("gnudateshort"); @@ -11690,7 +11664,7 @@ yy656: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 11694 "ext/date/lib/parse_date.c" +#line 11668 "ext/date/lib/parse_date.c" yy657: YYDEBUG(657, *YYCURSOR); yyaccept = 13; @@ -11796,7 +11770,7 @@ yy665: } yy666: YYDEBUG(666, *YYCURSOR); -#line 1243 "ext/date/lib/parse_date.re" +#line 1217 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("americanshort | american"); @@ -11811,7 +11785,7 @@ yy666: TIMELIB_DEINIT; return TIMELIB_AMERICAN; } -#line 11815 "ext/date/lib/parse_date.c" +#line 11789 "ext/date/lib/parse_date.c" yy667: YYDEBUG(667, *YYCURSOR); yyaccept = 14; @@ -12044,7 +12018,7 @@ yy699: if (yych <= ':') goto yy703; yy700: YYDEBUG(700, *YYCURSOR); -#line 1526 "ext/date/lib/parse_date.re" +#line 1500 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("clf"); @@ -12064,7 +12038,7 @@ yy700: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 12068 "ext/date/lib/parse_date.c" +#line 12042 "ext/date/lib/parse_date.c" yy701: YYDEBUG(701, *YYCURSOR); yych = *++YYCURSOR; @@ -12616,7 +12590,7 @@ yy762: } yy763: YYDEBUG(763, *YYCURSOR); -#line 1271 "ext/date/lib/parse_date.re" +#line 1245 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("iso8601date2"); @@ -12629,7 +12603,7 @@ yy763: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 12633 "ext/date/lib/parse_date.c" +#line 12607 "ext/date/lib/parse_date.c" yy764: YYDEBUG(764, *YYCURSOR); yych = *++YYCURSOR; @@ -12668,7 +12642,7 @@ yy770: YYDEBUG(770, *YYCURSOR); ++YYCURSOR; YYDEBUG(771, *YYCURSOR); -#line 1512 "ext/date/lib/parse_date.re" +#line 1486 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("pgtextreverse"); @@ -12681,7 +12655,7 @@ yy770: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 12685 "ext/date/lib/parse_date.c" +#line 12659 "ext/date/lib/parse_date.c" yy772: YYDEBUG(772, *YYCURSOR); yych = *++YYCURSOR; @@ -12819,7 +12793,7 @@ yy782: } yy783: YYDEBUG(783, *YYCURSOR); -#line 1547 "ext/date/lib/parse_date.re" +#line 1521 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("year4"); TIMELIB_INIT; @@ -12827,7 +12801,7 @@ yy783: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 12831 "ext/date/lib/parse_date.c" +#line 12805 "ext/date/lib/parse_date.c" yy784: YYDEBUG(784, *YYCURSOR); yych = *++YYCURSOR; @@ -12978,7 +12952,7 @@ yy792: } yy793: YYDEBUG(793, *YYCURSOR); -#line 1368 "ext/date/lib/parse_date.re" +#line 1342 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("datenodayrev"); @@ -12991,7 +12965,7 @@ yy793: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 12995 "ext/date/lib/parse_date.c" +#line 12969 "ext/date/lib/parse_date.c" yy794: YYDEBUG(794, *YYCURSOR); yych = *++YYCURSOR; @@ -13206,7 +13180,7 @@ yy813: if (yych <= '7') goto yy816; yy814: YYDEBUG(814, *YYCURSOR); -#line 1479 "ext/date/lib/parse_date.re" +#line 1453 "ext/date/lib/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweek"); @@ -13224,7 +13198,7 @@ yy814: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 13228 "ext/date/lib/parse_date.c" +#line 13202 "ext/date/lib/parse_date.c" yy815: YYDEBUG(815, *YYCURSOR); yych = *++YYCURSOR; @@ -13234,7 +13208,7 @@ yy816: YYDEBUG(816, *YYCURSOR); ++YYCURSOR; YYDEBUG(817, *YYCURSOR); -#line 1460 "ext/date/lib/parse_date.re" +#line 1434 "ext/date/lib/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweekday"); @@ -13252,7 +13226,7 @@ yy816: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 13256 "ext/date/lib/parse_date.c" +#line 13230 "ext/date/lib/parse_date.c" yy818: YYDEBUG(818, *YYCURSOR); yych = *++YYCURSOR; @@ -13316,7 +13290,7 @@ yy820: } yy821: YYDEBUG(821, *YYCURSOR); -#line 1446 "ext/date/lib/parse_date.re" +#line 1420 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("pgydotd"); @@ -13329,7 +13303,7 @@ yy821: TIMELIB_DEINIT; return TIMELIB_PG_YEARDAY; } -#line 13333 "ext/date/lib/parse_date.c" +#line 13307 "ext/date/lib/parse_date.c" yy822: YYDEBUG(822, *YYCURSOR); yych = *++YYCURSOR; @@ -13432,7 +13406,7 @@ yy841: ++YYCURSOR; yy842: YYDEBUG(842, *YYCURSOR); -#line 1420 "ext/date/lib/parse_date.re" +#line 1394 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif"); @@ -13457,7 +13431,7 @@ yy842: TIMELIB_DEINIT; return TIMELIB_XMLRPC_SOAP; } -#line 13461 "ext/date/lib/parse_date.c" +#line 13435 "ext/date/lib/parse_date.c" yy843: YYDEBUG(843, *YYCURSOR); yych = *++YYCURSOR; @@ -13719,7 +13693,7 @@ yy847: } yy848: YYDEBUG(848, *YYCURSOR); -#line 1408 "ext/date/lib/parse_date.re" +#line 1382 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("datenocolon"); TIMELIB_INIT; @@ -13730,7 +13704,7 @@ yy848: TIMELIB_DEINIT; return TIMELIB_DATE_NOCOLON; } -#line 13734 "ext/date/lib/parse_date.c" +#line 13708 "ext/date/lib/parse_date.c" yy849: YYDEBUG(849, *YYCURSOR); yych = *++YYCURSOR; @@ -14650,7 +14624,7 @@ yy972: if (yych <= '9') goto yy995; yy973: YYDEBUG(973, *YYCURSOR); -#line 1285 "ext/date/lib/parse_date.re" +#line 1259 "ext/date/lib/parse_date.re" { int length = 0; DEBUG_OUTPUT("gnudateshorter"); @@ -14663,7 +14637,7 @@ yy973: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 14667 "ext/date/lib/parse_date.c" +#line 14641 "ext/date/lib/parse_date.c" yy974: YYDEBUG(974, *YYCURSOR); yyaccept = 22; @@ -15672,7 +15646,7 @@ yy1065: } yy1067: YYDEBUG(1067, *YYCURSOR); -#line 1177 "ext/date/lib/parse_date.re" +#line 1151 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("gnunocolon"); TIMELIB_INIT; @@ -15694,7 +15668,7 @@ yy1067: TIMELIB_DEINIT; return TIMELIB_GNU_NOCOLON; } -#line 15698 "ext/date/lib/parse_date.c" +#line 15672 "ext/date/lib/parse_date.c" yy1068: YYDEBUG(1068, *YYCURSOR); yych = *++YYCURSOR; @@ -15786,7 +15760,7 @@ yy1074: } yy1075: YYDEBUG(1075, *YYCURSOR); -#line 1223 "ext/date/lib/parse_date.re" +#line 1197 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("iso8601nocolon"); @@ -15805,7 +15779,7 @@ yy1075: TIMELIB_DEINIT; return TIMELIB_ISO_NOCOLON; } -#line 15809 "ext/date/lib/parse_date.c" +#line 15783 "ext/date/lib/parse_date.c" yy1076: YYDEBUG(1076, *YYCURSOR); yyaccept = 25; @@ -16703,7 +16677,7 @@ yy1116: } yy1117: YYDEBUG(1117, *YYCURSOR); -#line 1619 "ext/date/lib/parse_date.re" +#line 1593 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16719,7 +16693,7 @@ yy1117: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16723 "ext/date/lib/parse_date.c" +#line 16697 "ext/date/lib/parse_date.c" yy1118: YYDEBUG(1118, *YYCURSOR); ++YYCURSOR; @@ -16770,7 +16744,7 @@ yy1125: YYDEBUG(1125, *YYCURSOR); ++YYCURSOR; YYDEBUG(1126, *YYCURSOR); -#line 1092 "ext/date/lib/parse_date.re" +#line 1066 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16791,7 +16765,7 @@ yy1125: TIMELIB_DEINIT; return TIMELIB_WEEK_DAY_OF_MONTH; } -#line 16795 "ext/date/lib/parse_date.c" +#line 16769 "ext/date/lib/parse_date.c" yy1127: YYDEBUG(1127, *YYCURSOR); yyaccept = 26; @@ -16899,7 +16873,7 @@ yy1140: } yy1141: YYDEBUG(1141, *YYCURSOR); -#line 1595 "ext/date/lib/parse_date.re" +#line 1569 "ext/date/lib/parse_date.re" { timelib_sll i; int behavior = 0; @@ -16922,7 +16896,7 @@ yy1141: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16926 "ext/date/lib/parse_date.c" +#line 16900 "ext/date/lib/parse_date.c" yy1142: YYDEBUG(1142, *YYCURSOR); yych = *++YYCURSOR; @@ -19599,7 +19573,7 @@ yy1293: goto yy1297; yy1294: YYDEBUG(1294, *YYCURSOR); -#line 1069 "ext/date/lib/parse_date.re" +#line 1043 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("backof | frontof"); TIMELIB_INIT; @@ -19621,7 +19595,7 @@ yy1294: TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 19625 "ext/date/lib/parse_date.c" +#line 19599 "ext/date/lib/parse_date.c" yy1295: YYDEBUG(1295, *YYCURSOR); yyaccept = 28; @@ -19882,7 +19856,7 @@ yy1315: YYDEBUG(1315, *YYCURSOR); ++YYCURSOR; YYDEBUG(1316, *YYCURSOR); -#line 1052 "ext/date/lib/parse_date.re" +#line 1026 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("firstdayof | lastdayof"); TIMELIB_INIT; @@ -19898,7 +19872,7 @@ yy1315: TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 19902 "ext/date/lib/parse_date.c" +#line 19876 "ext/date/lib/parse_date.c" yy1317: YYDEBUG(1317, *YYCURSOR); yyaccept = 0; @@ -21329,7 +21303,7 @@ yy1385: if (yych <= '9') goto yy1385; yy1387: YYDEBUG(1387, *YYCURSOR); -#line 1026 "ext/date/lib/parse_date.re" +#line 1000 "ext/date/lib/parse_date.re" { timelib_ull i; @@ -21354,7 +21328,7 @@ yy1387: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21358 "ext/date/lib/parse_date.c" +#line 21332 "ext/date/lib/parse_date.c" yy1388: YYDEBUG(1388, *YYCURSOR); yych = *++YYCURSOR; @@ -21790,7 +21764,7 @@ yy1416: ++YYCURSOR; yy1417: YYDEBUG(1417, *YYCURSOR); -#line 1014 "ext/date/lib/parse_date.re" +#line 988 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("tomorrow"); TIMELIB_INIT; @@ -21801,7 +21775,7 @@ yy1417: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21805 "ext/date/lib/parse_date.c" +#line 21779 "ext/date/lib/parse_date.c" yy1418: YYDEBUG(1418, *YYCURSOR); yych = *++YYCURSOR; @@ -21836,7 +21810,7 @@ yy1419: } yy1420: YYDEBUG(1420, *YYCURSOR); -#line 1004 "ext/date/lib/parse_date.re" +#line 978 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("midnight | today"); TIMELIB_INIT; @@ -21845,7 +21819,7 @@ yy1420: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21849 "ext/date/lib/parse_date.c" +#line 21823 "ext/date/lib/parse_date.c" yy1421: YYDEBUG(1421, *YYCURSOR); yych = *++YYCURSOR; @@ -23857,7 +23831,7 @@ yy1499: } yy1500: YYDEBUG(1500, *YYCURSOR); -#line 983 "ext/date/lib/parse_date.re" +#line 957 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("now"); TIMELIB_INIT; @@ -23865,7 +23839,7 @@ yy1500: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23869 "ext/date/lib/parse_date.c" +#line 23843 "ext/date/lib/parse_date.c" yy1501: YYDEBUG(1501, *YYCURSOR); yych = *++YYCURSOR; @@ -24004,7 +23978,7 @@ yy1507: } yy1508: YYDEBUG(1508, *YYCURSOR); -#line 992 "ext/date/lib/parse_date.re" +#line 966 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("noon"); TIMELIB_INIT; @@ -24015,7 +23989,7 @@ yy1508: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 24019 "ext/date/lib/parse_date.c" +#line 23993 "ext/date/lib/parse_date.c" yy1509: YYDEBUG(1509, *YYCURSOR); yyaccept = 0; @@ -24548,7 +24522,7 @@ yy1530: ++YYCURSOR; yy1531: YYDEBUG(1531, *YYCURSOR); -#line 971 "ext/date/lib/parse_date.re" +#line 945 "ext/date/lib/parse_date.re" { DEBUG_OUTPUT("yesterday"); TIMELIB_INIT; @@ -24559,7 +24533,7 @@ yy1531: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 24563 "ext/date/lib/parse_date.c" +#line 24537 "ext/date/lib/parse_date.c" yy1532: YYDEBUG(1532, *YYCURSOR); yyaccept = 0; @@ -24732,7 +24706,7 @@ yy1537: goto yy1531; } } -#line 1745 "ext/date/lib/parse_date.re" +#line 1719 "ext/date/lib/parse_date.re" } @@ -25223,7 +25197,7 @@ char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst) { const timelib_tz_lookup_table *tp; - tp = zone_search(abbr, gmtoffset, isdst); + tp = abbr_search(abbr, gmtoffset, isdst); if (tp) { return (tp->full_tz_name); } else { diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 760caea330..4cbbb554bf 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -668,7 +668,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S } } -const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst) +const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffset, int isdst) { int first_found = 0; const timelib_tz_lookup_table *tp, *first_found_elem = NULL; @@ -696,25 +696,6 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs return first_found_elem; } - for (tp = timelib_timezone_lookup; tp->name; tp++) { - if (tp->full_tz_name && strcasecmp(word, tp->full_tz_name) == 0) { - if (!first_found) { - first_found = 1; - first_found_elem = tp; - if (gmtoffset == -1) { - return tp; - } - } - if (tp->gmtoffset == gmtoffset) { - return tp; - } - } - } - if (first_found) { - return first_found_elem; - } - - /* Still didn't find anything, let's find the zone solely based on * offset/isdst then */ for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) { @@ -725,7 +706,7 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs return NULL; } -static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found) +static long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, int *found) { char *word; char *begin = *ptr, *end; @@ -739,7 +720,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found word = calloc(1, end - begin + 1); memcpy(word, begin, end - begin); - if ((tp = zone_search(word, -1, 0))) { + if ((tp = abbr_search(word, -1, 0))) { value = -tp->gmtoffset / 60; *dst = tp->type; value += tp->type * 60; @@ -783,33 +764,26 @@ long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found retval = timelib_parse_tz_cor(ptr); } else { int found = 0; - long offset; + long offset = 0; char *tz_abbr; t->is_localtime = 1; - offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found); + /* First, we lookup by abbreviation only */ + offset = timelib_lookup_abbr(ptr, dst, &tz_abbr, &found); if (found) { t->zone_type = TIMELIB_ZONETYPE_ABBR; + timelib_time_tz_abbr_update(t, tz_abbr); } -#if 0 - /* If we found a TimeZone identifier, use it */ - if (tz_name) { - t->tz_info = timelib_parse_tzfile(tz_name); - t->zone_type = TIMELIB_ZONETYPE_ID; - } -#endif - /* If we have a TimeZone identifier to start with, use it */ - if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) { + + /* Otherwise, we look if we have a TimeZone identifier */ + if (!found || strcmp("UTC", tz_abbr) == 0) { if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) { t->tz_info = res; t->zone_type = TIMELIB_ZONETYPE_ID; found++; } } - if (found && t->zone_type != TIMELIB_ZONETYPE_ID) { - timelib_time_tz_abbr_update(t, tz_abbr); - } free(tz_abbr); *tz_not_found = (found == 0); retval = offset; @@ -2232,7 +2206,7 @@ char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst) { const timelib_tz_lookup_table *tp; - tp = zone_search(abbr, gmtoffset, isdst); + tp = abbr_search(abbr, gmtoffset, isdst); if (tp) { return (tp->full_tz_name); } else { diff --git a/ext/date/tests/bug66985.phpt b/ext/date/tests/bug66985.phpt new file mode 100644 index 0000000000..0045ca29d6 --- /dev/null +++ b/ext/date/tests/bug66985.phpt @@ -0,0 +1,175 @@ +--TEST-- +Bug #66986 (Some timezones are no longer valid in PHP 5.5.10) +--FILE-- + +--EXPECT-- +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => CST6CDT +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Cuba +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Egypt +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Eire +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => EST5EDT +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Factory +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => GB-Eire +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => GMT0 +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Greenwich +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Hongkong +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Iceland +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Iran +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Israel +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Jamaica +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Japan +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Kwajalein +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Libya +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => MST7MDT +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Navajo +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => NZ-CHAT +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Poland +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Portugal +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => PST8PDT +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Singapore +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Turkey +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => Universal +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => W-SU +) +DateTimeZone Object +( + [timezone_type] => 3 + [timezone] => UTC +) +DateTimeZone Object +( + [timezone_type] => 2 + [timezone] => GMT +) +DateTimeZone Object +( + [timezone_type] => 1 + [timezone] => +01:00 +) +DateTimeZone Object +( + [timezone_type] => 1 + [timezone] => -02:30 +) -- 2.40.0