X-Git-Url: https://git.tld-linux.org/?p=packages%2Fphp.git;a=blobdiff_plain;f=php-systzdata.patch;h=eac3cc3a1e8ec1fd669c8edb2ecb7897029d0f38;hp=212820bf352ea59db232a68ecf44418d435c6015;hb=6d6c41ce055b258526429a4b986f0601d28a7181;hpb=2145ef2126854956fb897978f38cda33bdc6672c diff --git a/php-systzdata.patch b/php-systzdata.patch index 212820b..eac3cc3 100644 --- a/php-systzdata.patch +++ b/php-systzdata.patch @@ -1,11 +1,15 @@ +# License: MIT +# http://opensource.org/licenses/MIT + Add support for use of the system timezone database, rather than embedding a copy. Discussed upstream but was not desired. -(Few) upstream reports: -https://bugs.php.net/bug.php?id=53320 -https://bugs.php.net/bug.php?id=54250 - History: +r18: adapt for autotool change in 7.3.3RC1 +r17: adapt for timelib 2018.01 (in 7.3.2RC1) +r16: adapt for timelib 2017.06 (in 7.2.3RC1) +r15: adapt for timelib 2017.05beta7 (in 7.2.0RC1) +r14: improve check for valid tz file r13: adapt for upstream changes to use PHP allocator r12: adapt for upstream changes for new zic r11: use canonical names to avoid more case sensitivity issues @@ -25,12 +29,35 @@ 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 -diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/lib/parse_tz.c ---- php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata 2015-08-18 23:39:24.000000000 +0200 -+++ php-7.0.0RC1/ext/date/lib/parse_tz.c 2015-08-22 07:54:38.097258458 +0200 -@@ -20,6 +20,16 @@ +diff -up php-7.3.3RC1/ext/date/config0.m4.systzdata php-7.3.3RC1/ext/date/config0.m4 +--- php-7.3.3RC1/ext/date/config0.m4.systzdata 2019-02-19 14:57:51.314601701 +0100 ++++ php-7.3.3RC1/ext/date/config0.m4 2019-02-19 14:58:29.050812587 +0100 +@@ -9,6 +9,19 @@ io.h + dnl Check for strtoll, atoll + AC_CHECK_FUNCS(strtoll atoll) ++PHP_ARG_WITH(system-tzdata, for use of system timezone data, ++[ --with-system-tzdata[=DIR] to specify use of system timezone data], ++no, no) ++ ++if test "$PHP_SYSTEM_TZDATA" != "no"; then ++ AC_DEFINE(HAVE_SYSTEM_TZDATA, 1, [Define if system timezone data is used]) ++ ++ if test "$PHP_SYSTEM_TZDATA" != "yes"; then ++ AC_DEFINE_UNQUOTED(HAVE_SYSTEM_TZDATA_PREFIX, "$PHP_SYSTEM_TZDATA", ++ [Define for location of system timezone data]) ++ fi ++fi ++ + PHP_DATE_CFLAGS="-I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1" + timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c + lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c" +diff -up php-7.3.3RC1/ext/date/lib/parse_tz.c.systzdata php-7.3.3RC1/ext/date/lib/parse_tz.c +--- php-7.3.3RC1/ext/date/lib/parse_tz.c.systzdata 2019-02-19 12:18:27.000000000 +0100 ++++ php-7.3.3RC1/ext/date/lib/parse_tz.c 2019-02-19 14:57:20.397428931 +0100 +@@ -25,8 +25,21 @@ #include "timelib.h" + #include "timelib_private.h" +#ifdef HAVE_SYSTEM_TZDATA +#include @@ -40,16 +67,8 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li +#include + +#include "php_scandir.h" -+#endif + - #include - - #ifdef HAVE_LOCALE_H -@@ -32,8 +42,12 @@ - #include - #endif - -+#ifndef HAVE_SYSTEM_TZDATA ++#else #define TIMELIB_SUPPORTS_V2DATA #include "timezonedb.h" +#endif @@ -58,7 +77,7 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)) # if defined(__LITTLE_ENDIAN__) -@@ -55,6 +69,11 @@ static int read_preamble(const unsigned +@@ -87,6 +100,11 @@ static int read_php_preamble(const unsig { uint32_t version; @@ -70,7 +89,7 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li /* read ID */ version = (*tzf)[3] - '0'; *tzf += 4; -@@ -298,7 +317,418 @@ void timelib_dump_tzinfo(timelib_tzinfo +@@ -411,7 +429,429 @@ void timelib_dump_tzinfo(timelib_tzinfo } } @@ -273,7 +292,7 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li + } + + for (l = li[hash]; l; l = l->next) { -+ if (strcasecmp(l->name, name) == 0) ++ if (timelib_strcasecmp(l->name, name) == 0) + return l; + } + @@ -289,6 +308,7 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li + && strcmp(ent->d_name, "posix") != 0 + && strcmp(ent->d_name, "posixrules") != 0 + && strcmp(ent->d_name, "right") != 0 ++ && strstr(ent->d_name, ".list") == NULL + && strstr(ent->d_name, ".tab") == NULL; +} + @@ -296,7 +316,7 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li +{ + const timelib_tzdb_index_entry *alpha = first, *beta = second; + -+ return strcasecmp(alpha->id, beta->id); ++ return timelib_strcasecmp(alpha->id, beta->id); +} + + @@ -429,8 +449,18 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li + +/* Returns true if the passed-in stat structure describes a + * probably-valid timezone file. */ -+static int is_valid_tzfile(const struct stat *st) ++static int is_valid_tzfile(const struct stat *st, int fd) +{ ++ if (fd) { ++ char buf[20]; ++ if (read(fd, buf, 20)!=20) { ++ return 0; ++ } ++ lseek(fd, SEEK_SET, 0); ++ if (memcmp(buf, "TZif", 4)) { ++ return 0; ++ } ++ } + return S_ISREG(st->st_mode) && st->st_size > 20; +} + @@ -468,11 +498,11 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li + } + + snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone)); -+ ++ + fd = open(fname, O_RDONLY); + if (fd == -1) { + return NULL; -+ } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st)) { ++ } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st, fd)) { + close(fd); + return NULL; + } @@ -489,8 +519,8 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li +static int inmem_seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb) { int left = 0, right = tzdb->index_size - 1; - #ifdef HAVE_SETLOCALE -@@ -337,21 +767,88 @@ static int seek_to_tz_position(const uns + +@@ -437,9 +877,48 @@ static int seek_to_tz_position(const uns return 0; } @@ -538,17 +568,8 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li +#endif } - const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count) - { -+#ifdef HAVE_SYSTEM_TZDATA -+ *count = timezonedb_system->index_size; -+ return timezonedb_system->index; -+#else - *count = sizeof(timezonedb_idx_builtin) / sizeof(*timezonedb_idx_builtin); - return timezonedb_idx_builtin; -+#endif - } - + const timelib_tzdb_index_entry *timelib_timezone_identifiers_list(const timelib_tzdb *tzdb, int *count) +@@ -451,7 +930,30 @@ const timelib_tzdb_index_entry *timelib_ int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb) { const unsigned char *tzf; @@ -572,40 +593,34 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li + + snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone)); + -+ return stat(fname, &st) == 0 && is_valid_tzfile(&st); ++ return stat(fname, &st) == 0 && is_valid_tzfile(&st, 0); + } +#endif + + return (inmem_seek_to_tz_position(&tzf, timezone, tzdb)); } - static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz) -@@ -376,24 +873,54 @@ static void read_64bit_header(const unsi - timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb) + static int skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz) +@@ -493,12 +995,14 @@ static timelib_tzinfo* timelib_tzinfo_ct + timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb, int *error_code) { const unsigned char *tzf; + char *memmap = NULL; + size_t maplen; timelib_tzinfo *tmp; int version; + int transitions_result, types_result; + unsigned int type; /* TIMELIB_TZINFO_PHP or TIMELIB_TZINFO_ZONEINFO */ - if (seek_to_tz_position(&tzf, timezone, tzdb)) { + if (seek_to_tz_position(&tzf, timezone, &memmap, &maplen, tzdb)) { tmp = timelib_tzinfo_ctor(timezone); - version = read_preamble(&tzf, tmp); - read_header(&tzf, tmp); - read_transistions(&tzf, tmp); - read_types(&tzf, tmp); -- if (version == 2) { -- skip_64bit_preamble(&tzf, tmp); -- read_64bit_header(&tzf, tmp); -- skip_64bit_transistions(&tzf, tmp); -- skip_64bit_types(&tzf, tmp); -- skip_posix_string(&tzf, tmp); -- } -- read_location(&tzf, tmp); -+ + version = read_preamble(&tzf, tmp, &type); +@@ -537,11 +1041,36 @@ timelib_tzinfo *timelib_parse_tzfile(cha + } + skip_posix_string(&tzf, tmp); + +#ifdef HAVE_SYSTEM_TZDATA + if (memmap) { + const struct location_info *li; @@ -621,45 +636,21 @@ diff -up php-7.0.0RC1/ext/date/lib/parse_tz.c.systzdata php-7.0.0RC1/ext/date/li + tmp->bc = 1; + } + else { -+ strcpy(tmp->location.country_code, "??"); -+ tmp->bc = 0; -+ tmp->location.comments = timelib_strdup(""); ++ set_default_location_and_comments(&tzf, tmp); + } + + /* Now done with the mmap segment - discard it. */ + munmap(memmap, maplen); -+ } else ++ } else { ++#endif + if (type == TIMELIB_TZINFO_PHP) { + read_location(&tzf, tmp); + } else { + set_default_location_and_comments(&tzf, tmp); + } ++#ifdef HAVE_SYSTEM_TZDATA ++ } +#endif -+ { -+ /* PHP-style - use the embedded info. */ -+ if (version == 2) { -+ skip_64bit_preamble(&tzf, tmp); -+ read_64bit_header(&tzf, tmp); -+ skip_64bit_transistions(&tzf, tmp); -+ skip_64bit_types(&tzf, tmp); -+ skip_posix_string(&tzf, tmp); -+ } -+ read_location(&tzf, tmp); -+ } } else { + *error_code = TIMELIB_ERROR_NO_SUCH_TIMEZONE; tmp = NULL; - } ---- php-7.1.0RC4/ext/date/lib/timelib.m4~ 2016-10-17 14:35:11.000000000 +0300 -+++ php-7.1.0RC4/ext/date/lib/timelib.m4 2016-10-25 14:11:32.224877793 +0300 -@@ -78,3 +78,16 @@ - - dnl Check for strtoll, atoll - AC_CHECK_FUNCS(strtoll atoll strftime gettimeofday) -+ -+PHP_ARG_WITH(system-tzdata, for use of system timezone data, -+[ --with-system-tzdata[=DIR] to specify use of system timezone data], -+no, no) -+ -+if test "$PHP_SYSTEM_TZDATA" != "no"; then -+ AC_DEFINE(HAVE_SYSTEM_TZDATA, 1, [Define if system timezone data is used]) -+ -+ if test "$PHP_SYSTEM_TZDATA" != "yes"; then -+ AC_DEFINE_UNQUOTED(HAVE_SYSTEM_TZDATA_PREFIX, "$PHP_SYSTEM_TZDATA", -+ [Define for location of system timezone data]) -+ fi -+fi