From fc674d5f6186a3b211ed6dba1e3e2e38e89648bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 5 Dec 2013 21:13:41 +0200 Subject: [PATCH] update systzdata patch from debian -- r10: make timezone case insensitive --- php-systzdata.patch | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/php-systzdata.patch b/php-systzdata.patch index f841e9b..053f769 100644 --- a/php-systzdata.patch +++ b/php-systzdata.patch @@ -2,6 +2,7 @@ Add support for use of the system timezone database, rather than embedding a copy. Discussed upstream but was not desired. History: +r10 : make timezone case insensitive r9: fix another compile error without --with-system-tzdata configured (Michael Heimpold) r8: fix compile error without --with-system-tzdata configured r7: improve check for valid timezone id to exclude directories @@ -16,8 +17,8 @@ r3: fix a crash if /usr/share/zoneinfo doesn't exist (Raphael Geissert) r2: add filesystem trawl to set up name alias index r1: initial revision ---- a/ext/date/lib/parse_tz.c -+++ b/ext/date/lib/parse_tz.c +--- php5.orig/ext/date/lib/parse_tz.c ++++ php5/ext/date/lib/parse_tz.c @@ -24,6 +24,16 @@ #include "timelib.h" @@ -66,7 +67,7 @@ r1: initial revision /* read BC flag */ tz->bc = (**tzf == '\1'); *tzf += 1; -@@ -260,7 +280,397 @@ void timelib_dump_tzinfo(timelib_tzinfo +@@ -260,7 +280,405 @@ void timelib_dump_tzinfo(timelib_tzinfo } } @@ -80,7 +81,7 @@ r1: initial revision +#endif + +/* System timezone database pointer. */ -+static const timelib_tzdb *timezonedb_system = NULL; ++static const timelib_tzdb *timezonedb_system; + +/* Hash table entry for the cache of the zone.tab mapping table. */ +struct location_info { @@ -98,13 +99,14 @@ r1: initial revision + * prevent too many collisions. */ +#define LOCINFO_HASH_SIZE (1021) + ++/* Compute a case insensitive hash of str */ +static uint32_t tz_hash(const char *str) +{ + const unsigned char *p = (const unsigned char *)str; + uint32_t hash = 5381; + int c; + -+ while ((c = *p++) != '\0') { ++ while ((c = tolower(*p++)) != '\0') { + hash = (hash << 5) ^ hash ^ c; + } + @@ -442,6 +444,13 @@ r1: initial revision + return NULL; + } + ++ if (system_location_table) { ++ const struct location_info *li; ++ if ((li = find_zone_info(system_location_table, timezone)) != NULL) { ++ /* Use the stored name to avoid case issue */ ++ timezone = li->name; ++ } ++ } + snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", timezone); + + fd = open(fname, O_RDONLY); @@ -465,7 +474,7 @@ r1: initial revision { int left = 0, right = tzdb->index_size - 1; #ifdef HAVE_SETLOCALE -@@ -299,36 +709,128 @@ static int seek_to_tz_position(const uns +@@ -299,36 +717,135 @@ static int seek_to_tz_position(const uns return 0; } @@ -537,7 +546,14 @@ r1: initial revision + struct stat st; + + if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) { -+ return 0; ++ return 0; ++ } ++ ++ if (system_location_table) { ++ if (find_zone_info(system_location_table, timezone) != NULL) { ++ /* found in cache */ ++ return 1; ++ } + } + + snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", timezone); @@ -597,8 +613,8 @@ r1: initial revision } else { tmp = NULL; } ---- a/ext/date/lib/timelib.m4 -+++ b/ext/date/lib/timelib.m4 +--- php5.orig/ext/date/lib/timelib.m4 ++++ php5/ext/date/lib/timelib.m4 @@ -78,3 +78,17 @@ stdlib.h dnl Check for strtoll, atoll -- 2.44.0