]> git.pld-linux.org Git - packages/php.git/blame - php-systzdata.patch
- updated to 8.1.0
[packages/php.git] / php-systzdata.patch
CommitLineData
cacce04b
ER
1# License: MIT
2# http://opensource.org/licenses/MIT
3
c0240cb1 4Add support for use of the system timezone database, rather
5than embedding a copy. Discussed upstream but was not desired.
6
7History:
072a47ef 8r20: adapt for timelib 2020.03 (in 8.0.10RC1)
060f741a 9r19: adapt for timelib 2020.02 (in 8.0.0beta2)
5cd8d883 10r18: adapt for autotool change in 7.3.3RC1
539ed3cb
AG
11r17: adapt for timelib 2018.01 (in 7.3.2RC1)
12r16: adapt for timelib 2017.06 (in 7.2.3RC1)
cacce04b
ER
13r15: adapt for timelib 2017.05beta7 (in 7.2.0RC1)
14r14: improve check for valid tz file
909e9211 15r13: adapt for upstream changes to use PHP allocator
a659fa18
ER
16r12: adapt for upstream changes for new zic
17r11: use canonical names to avoid more case sensitivity issues
18 round lat/long from zone.tab towards zero per builtin db
19r10: make timezone case insensitive
361fb152
ER
20r9: fix another compile error without --with-system-tzdata configured (Michael Heimpold)
21r8: fix compile error without --with-system-tzdata configured
c0240cb1 22r7: improve check for valid timezone id to exclude directories
a659fa18 23r6: fix fd leak in r5, fix country code/BC flag use in
c0240cb1 24 timezone_identifiers_list() using system db,
25 fix use of PECL timezonedb to override system db,
26r5: reverts addition of "System/Localtime" fake tzname.
27 updated for 5.3.0, parses zone.tab to pick up mapping between
28 timezone name, country code and long/lat coords
29r4: added "System/Localtime" tzname which uses /etc/localtime
30r3: fix a crash if /usr/share/zoneinfo doesn't exist (Raphael Geissert)
31r2: add filesystem trawl to set up name alias index
32r1: initial revision
33
072a47ef
ER
34diff -up ./ext/date/config0.m4.systzdata ./ext/date/config0.m4
35--- ./ext/date/config0.m4.systzdata 2021-08-10 11:35:28.000000000 +0200
36+++ ./ext/date/config0.m4 2021-08-10 12:09:41.067003517 +0200
060f741a 37@@ -4,6 +4,19 @@ AC_CHECK_HEADERS([io.h])
5cd8d883
AG
38 dnl Check for strtoll, atoll
39 AC_CHECK_FUNCS(strtoll atoll)
40
41+PHP_ARG_WITH(system-tzdata, for use of system timezone data,
42+[ --with-system-tzdata[=DIR] to specify use of system timezone data],
43+no, no)
44+
45+if test "$PHP_SYSTEM_TZDATA" != "no"; then
46+ AC_DEFINE(HAVE_SYSTEM_TZDATA, 1, [Define if system timezone data is used])
47+
48+ if test "$PHP_SYSTEM_TZDATA" != "yes"; then
49+ AC_DEFINE_UNQUOTED(HAVE_SYSTEM_TZDATA_PREFIX, "$PHP_SYSTEM_TZDATA",
50+ [Define for location of system timezone data])
51+ fi
52+fi
53+
da3ee842
AG
54 PHP_DATE_CFLAGS="-Wno-implicit-fallthrough -I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1"
55 timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/parse_posix.c
5cd8d883 56 lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c"
072a47ef
ER
57diff -up ./ext/date/lib/parse_tz.c.systzdata ./ext/date/lib/parse_tz.c
58--- ./ext/date/lib/parse_tz.c.systzdata 2021-08-10 11:35:28.000000000 +0200
59+++ ./ext/date/lib/parse_tz.c 2021-08-10 12:12:13.191605207 +0200
da3ee842 60@@ -26,9 +26,22 @@
c0240cb1 61 #include "timelib.h"
cacce04b 62 #include "timelib_private.h"
c0240cb1 63
64+#ifdef HAVE_SYSTEM_TZDATA
65+#include <sys/mman.h>
66+#include <sys/stat.h>
67+#include <limits.h>
68+#include <fcntl.h>
69+#include <unistd.h>
70+
71+#include "php_scandir.h"
c0240cb1 72+
cacce04b 73+#else
909e9211 74 #define TIMELIB_SUPPORTS_V2DATA
da3ee842 75 #define TIMELIB_SUPPORT_SLIM_FILE
c0240cb1 76 #include "timezonedb.h"
77+#endif
78+
79+#include <ctype.h>
80
81 #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
82 # if defined(__LITTLE_ENDIAN__)
060f741a 83@@ -94,6 +107,11 @@ static int read_php_preamble(const unsig
c0240cb1 84 {
a659fa18
ER
85 uint32_t version;
86
87+ if (memcmp(*tzf, "TZif", 4) == 0) {
88+ *tzf += 20;
89+ return 0;
90+ }
909e9211 91+
a659fa18
ER
92 /* read ID */
93 version = (*tzf)[3] - '0';
94 *tzf += 4;
072a47ef 95@@ -435,7 +453,429 @@ void timelib_dump_tzinfo(timelib_tzinfo
c0240cb1 96 }
97 }
98
060f741a 99-static int seek_to_tz_position(const unsigned char **tzf, const char *timezone, const timelib_tzdb *tzdb)
c0240cb1 100+#ifdef HAVE_SYSTEM_TZDATA
101+
102+#ifdef HAVE_SYSTEM_TZDATA_PREFIX
103+#define ZONEINFO_PREFIX HAVE_SYSTEM_TZDATA_PREFIX
104+#else
105+#define ZONEINFO_PREFIX "/usr/share/zoneinfo"
106+#endif
107+
108+/* System timezone database pointer. */
7588b36c 109+static const timelib_tzdb *timezonedb_system;
c0240cb1 110+
111+/* Hash table entry for the cache of the zone.tab mapping table. */
112+struct location_info {
113+ char code[2];
114+ double latitude, longitude;
115+ char name[64];
116+ char *comment;
117+ struct location_info *next;
118+};
119+
120+/* Cache of zone.tab. */
121+static struct location_info **system_location_table;
122+
123+/* Size of the zone.tab hash table; a random-ish prime big enough to
124+ * prevent too many collisions. */
125+#define LOCINFO_HASH_SIZE (1021)
126+
7588b36c 127+/* Compute a case insensitive hash of str */
c0240cb1 128+static uint32_t tz_hash(const char *str)
129+{
130+ const unsigned char *p = (const unsigned char *)str;
131+ uint32_t hash = 5381;
132+ int c;
909e9211 133+
7588b36c 134+ while ((c = tolower(*p++)) != '\0') {
c0240cb1 135+ hash = (hash << 5) ^ hash ^ c;
136+ }
909e9211 137+
c0240cb1 138+ return hash % LOCINFO_HASH_SIZE;
139+}
140+
141+/* Parse an ISO-6709 date as used in zone.tab. Returns end of the
142+ * parsed string on success, or NULL on parse error. On success,
143+ * writes the parsed number to *result. */
144+static char *parse_iso6709(char *p, double *result)
145+{
146+ double v, sign;
147+ char *pend;
148+ size_t len;
149+
150+ if (*p == '+')
151+ sign = 1.0;
152+ else if (*p == '-')
153+ sign = -1.0;
154+ else
155+ return NULL;
156+
157+ p++;
158+ for (pend = p; *pend >= '0' && *pend <= '9'; pend++)
159+ ;;
160+
161+ /* Annoying encoding used by zone.tab has no decimal point, so use
162+ * the length to determine the format:
163+ *
164+ * 4 = DDMM
165+ * 5 = DDDMM
166+ * 6 = DDMMSS
167+ * 7 = DDDMMSS
168+ */
169+ len = pend - p;
170+ if (len < 4 || len > 7) {
171+ return NULL;
172+ }
173+
174+ /* p => [D]DD */
175+ v = (p[0] - '0') * 10.0 + (p[1] - '0');
176+ p += 2;
177+ if (len == 5 || len == 7)
178+ v = v * 10.0 + (*p++ - '0');
179+ /* p => MM[SS] */
180+ v += (10.0 * (p[0] - '0')
181+ + p[1] - '0') / 60.0;
182+ p += 2;
183+ /* p => [SS] */
184+ if (len > 5) {
185+ v += (10.0 * (p[0] - '0')
186+ + p[1] - '0') / 3600.0;
187+ p += 2;
188+ }
189+
190+ /* Round to five decimal place, not because it's a good idea,
191+ * but, because the builtin data uses rounded data, so, match
192+ * that. */
a659fa18 193+ *result = trunc(v * sign * 100000.0) / 100000.0;
c0240cb1 194+
195+ return p;
196+}
197+
198+/* This function parses the zone.tab file to build up the mapping of
199+ * timezone to country code and geographic location, and returns a
200+ * hash table. The hash table is indexed by the function:
201+ *
202+ * tz_hash(timezone-name)
203+ */
204+static struct location_info **create_location_table(void)
205+{
206+ struct location_info **li, *i;
207+ char zone_tab[PATH_MAX];
208+ char line[512];
209+ FILE *fp;
210+
211+ strncpy(zone_tab, ZONEINFO_PREFIX "/zone.tab", sizeof zone_tab);
212+
213+ fp = fopen(zone_tab, "r");
214+ if (!fp) {
215+ return NULL;
216+ }
217+
218+ li = calloc(LOCINFO_HASH_SIZE, sizeof *li);
219+
220+ while (fgets(line, sizeof line, fp)) {
221+ char *p = line, *code, *name, *comment;
222+ uint32_t hash;
223+ double latitude, longitude;
224+
225+ while (isspace(*p))
226+ p++;
227+
228+ if (*p == '#' || *p == '\0' || *p == '\n')
229+ continue;
230+
231+ if (!isalpha(p[0]) || !isalpha(p[1]) || p[2] != '\t')
232+ continue;
233+
234+ /* code => AA */
235+ code = p;
236+ p[2] = 0;
237+ p += 3;
238+
239+ /* coords => [+-][D]DDMM[SS][+-][D]DDMM[SS] */
240+ p = parse_iso6709(p, &latitude);
241+ if (!p) {
242+ continue;
243+ }
244+ p = parse_iso6709(p, &longitude);
245+ if (!p) {
246+ continue;
247+ }
248+
249+ if (!p || *p != '\t') {
250+ continue;
251+ }
252+
253+ /* name = string */
254+ name = ++p;
255+ while (*p != '\t' && *p && *p != '\n')
256+ p++;
257+
258+ *p++ = '\0';
259+
260+ /* comment = string */
261+ comment = p;
262+ while (*p != '\t' && *p && *p != '\n')
263+ p++;
264+
265+ if (*p == '\n' || *p == '\t')
266+ *p = '\0';
267+
268+ hash = tz_hash(name);
269+ i = malloc(sizeof *i);
270+ memcpy(i->code, code, 2);
271+ strncpy(i->name, name, sizeof i->name);
272+ i->comment = strdup(comment);
273+ i->longitude = longitude;
274+ i->latitude = latitude;
275+ i->next = li[hash];
276+ li[hash] = i;
277+ /* printf("%s [%u, %f, %f]\n", name, hash, latitude, longitude); */
278+ }
279+
280+ fclose(fp);
281+
282+ return li;
283+}
284+
285+/* Return location info from hash table, using given timezone name.
286+ * Returns NULL if the name could not be found. */
287+const struct location_info *find_zone_info(struct location_info **li,
288+ const char *name)
289+{
290+ uint32_t hash = tz_hash(name);
291+ const struct location_info *l;
292+
293+ if (!li) {
294+ return NULL;
295+ }
296+
297+ for (l = li[hash]; l; l = l->next) {
539ed3cb 298+ if (timelib_strcasecmp(l->name, name) == 0)
c0240cb1 299+ return l;
300+ }
301+
302+ return NULL;
303+}
304+
305+/* Filter out some non-tzdata files and the posix/right databases, if
306+ * present. */
307+static int index_filter(const struct dirent *ent)
308+{
309+ return strcmp(ent->d_name, ".") != 0
310+ && strcmp(ent->d_name, "..") != 0
311+ && strcmp(ent->d_name, "posix") != 0
312+ && strcmp(ent->d_name, "posixrules") != 0
313+ && strcmp(ent->d_name, "right") != 0
cacce04b 314+ && strstr(ent->d_name, ".list") == NULL
c0240cb1 315+ && strstr(ent->d_name, ".tab") == NULL;
316+}
317+
318+static int sysdbcmp(const void *first, const void *second)
319+{
320+ const timelib_tzdb_index_entry *alpha = first, *beta = second;
321+
539ed3cb 322+ return timelib_strcasecmp(alpha->id, beta->id);
c0240cb1 323+}
324+
325+
326+/* Create the zone identifier index by trawling the filesystem. */
327+static void create_zone_index(timelib_tzdb *db)
328+{
329+ size_t dirstack_size, dirstack_top;
330+ size_t index_size, index_next;
331+ timelib_tzdb_index_entry *db_index;
332+ char **dirstack;
333+
334+ /* LIFO stack to hold directory entries to scan; each slot is a
335+ * directory name relative to the zoneinfo prefix. */
336+ dirstack_size = 32;
337+ dirstack = malloc(dirstack_size * sizeof *dirstack);
338+ dirstack_top = 1;
339+ dirstack[0] = strdup("");
340+
341+ /* Index array. */
342+ index_size = 64;
343+ db_index = malloc(index_size * sizeof *db_index);
344+ index_next = 0;
345+
346+ do {
347+ struct dirent **ents;
348+ char name[PATH_MAX], *top;
349+ int count;
350+
351+ /* Pop the top stack entry, and iterate through its contents. */
352+ top = dirstack[--dirstack_top];
353+ snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s", top);
354+
355+ count = php_scandir(name, &ents, index_filter, php_alphasort);
356+
357+ while (count > 0) {
358+ struct stat st;
359+ const char *leaf = ents[count - 1]->d_name;
360+
361+ snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s/%s",
362+ top, leaf);
363+
364+ if (strlen(name) && stat(name, &st) == 0) {
365+ /* Name, relative to the zoneinfo prefix. */
366+ const char *root = top;
367+
368+ if (root[0] == '/') root++;
369+
370+ snprintf(name, sizeof name, "%s%s%s", root,
371+ *root ? "/": "", leaf);
372+
373+ if (S_ISDIR(st.st_mode)) {
374+ if (dirstack_top == dirstack_size) {
375+ dirstack_size *= 2;
376+ dirstack = realloc(dirstack,
377+ dirstack_size * sizeof *dirstack);
378+ }
379+ dirstack[dirstack_top++] = strdup(name);
380+ }
381+ else {
382+ if (index_next == index_size) {
383+ index_size *= 2;
384+ db_index = realloc(db_index,
385+ index_size * sizeof *db_index);
386+ }
387+
388+ db_index[index_next++].id = strdup(name);
389+ }
390+ }
391+
392+ free(ents[--count]);
393+ }
394+
395+ if (count != -1) free(ents);
396+ free(top);
397+ } while (dirstack_top);
398+
399+ qsort(db_index, index_next, sizeof *db_index, sysdbcmp);
400+
401+ db->index = db_index;
402+ db->index_size = index_next;
403+
404+ free(dirstack);
405+}
406+
407+#define FAKE_HEADER "1234\0??\1??"
408+#define FAKE_UTC_POS (7 - 4)
409+
410+/* Create a fake data segment for database 'sysdb'. */
411+static void fake_data_segment(timelib_tzdb *sysdb,
412+ struct location_info **info)
413+{
414+ size_t n;
415+ char *data, *p;
416+
417+ data = malloc(3 * sysdb->index_size + 7);
418+
419+ p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1);
420+
421+ for (n = 0; n < sysdb->index_size; n++) {
422+ const struct location_info *li;
423+ timelib_tzdb_index_entry *ent;
424+
425+ ent = (timelib_tzdb_index_entry *)&sysdb->index[n];
426+
427+ /* Lookup the timezone name in the hash table. */
428+ if (strcmp(ent->id, "UTC") == 0) {
429+ ent->pos = FAKE_UTC_POS;
430+ continue;
431+ }
432+
433+ li = find_zone_info(info, ent->id);
434+ if (li) {
435+ /* If found, append the BC byte and the
436+ * country code; set the position for this
437+ * section of timezone data. */
438+ ent->pos = (p - data) - 4;
439+ *p++ = '\1';
440+ *p++ = li->code[0];
441+ *p++ = li->code[1];
442+ }
443+ else {
444+ /* If not found, the timezone data can
445+ * point at the header. */
446+ ent->pos = 0;
447+ }
448+ }
449+
450+ sysdb->data = (unsigned char *)data;
451+}
452+
453+/* Returns true if the passed-in stat structure describes a
454+ * probably-valid timezone file. */
cacce04b 455+static int is_valid_tzfile(const struct stat *st, int fd)
c0240cb1 456+{
cacce04b
ER
457+ if (fd) {
458+ char buf[20];
459+ if (read(fd, buf, 20)!=20) {
460+ return 0;
461+ }
462+ lseek(fd, SEEK_SET, 0);
463+ if (memcmp(buf, "TZif", 4)) {
464+ return 0;
465+ }
466+ }
c0240cb1 467+ return S_ISREG(st->st_mode) && st->st_size > 20;
468+}
469+
a659fa18
ER
470+/* To allow timezone names to be used case-insensitively, find the
471+ * canonical name for this timezone, if possible. */
472+static const char *canonical_tzname(const char *timezone)
473+{
474+ if (timezonedb_system) {
475+ timelib_tzdb_index_entry *ent, lookup;
909e9211 476+
a659fa18 477+ lookup.id = (char *)timezone;
909e9211 478+
a659fa18
ER
479+ ent = bsearch(&lookup, timezonedb_system->index,
480+ timezonedb_system->index_size, sizeof lookup,
481+ sysdbcmp);
482+ if (ent) {
483+ return ent->id;
484+ }
485+ }
486+
487+ return timezone;
488+}
489+
c0240cb1 490+/* Return the mmap()ed tzfile if found, else NULL. On success, the
491+ * length of the mapped data is placed in *length. */
492+static char *map_tzfile(const char *timezone, size_t *length)
493+{
494+ char fname[PATH_MAX];
495+ struct stat st;
496+ char *p;
497+ int fd;
498+
499+ if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
500+ return NULL;
501+ }
502+
a659fa18 503+ snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone));
cacce04b 504+
c0240cb1 505+ fd = open(fname, O_RDONLY);
506+ if (fd == -1) {
507+ return NULL;
cacce04b 508+ } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st, fd)) {
c0240cb1 509+ close(fd);
510+ return NULL;
511+ }
512+
513+ *length = st.st_size;
514+ p = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
515+ close(fd);
516+
517+ return p != MAP_FAILED ? p : NULL;
518+}
519+
520+#endif
521+
060f741a 522+static int inmem_seek_to_tz_position(const unsigned char **tzf, const char *timezone, const timelib_tzdb *tzdb)
c0240cb1 523 {
524 int left = 0, right = tzdb->index_size - 1;
539ed3cb 525
072a47ef 526@@ -461,9 +901,48 @@ static int seek_to_tz_position(const uns
c0240cb1 527 return 0;
528 }
529
060f741a 530+static int seek_to_tz_position(const unsigned char **tzf, const char *timezone,
c0240cb1 531+ char **map, size_t *maplen,
532+ const timelib_tzdb *tzdb)
533+{
361fb152 534+#ifdef HAVE_SYSTEM_TZDATA
c0240cb1 535+ if (tzdb == timezonedb_system) {
536+ char *orig;
537+
538+ orig = map_tzfile(timezone, maplen);
539+ if (orig == NULL) {
540+ return 0;
541+ }
a659fa18 542+
909e9211 543+ (*tzf) = (unsigned char *)orig;
c0240cb1 544+ *map = orig;
909e9211 545+ return 1;
c0240cb1 546+ }
a659fa18 547+ else
361fb152 548+#endif
a659fa18 549+ {
c0240cb1 550+ return inmem_seek_to_tz_position(tzf, timezone, tzdb);
551+ }
552+}
553+
554 const timelib_tzdb *timelib_builtin_db(void)
555 {
556+#ifdef HAVE_SYSTEM_TZDATA
557+ if (timezonedb_system == NULL) {
558+ timelib_tzdb *tmp = malloc(sizeof *tmp);
559+
560+ tmp->version = "0.system";
561+ tmp->data = NULL;
562+ create_zone_index(tmp);
563+ system_location_table = create_location_table();
a659fa18 564+ fake_data_segment(tmp, system_location_table);
c0240cb1 565+ timezonedb_system = tmp;
566+ }
567+
c0240cb1 568+ return timezonedb_system;
569+#else
570 return &timezonedb_builtin;
571+#endif
572 }
573
539ed3cb 574 const timelib_tzdb_index_entry *timelib_timezone_identifiers_list(const timelib_tzdb *tzdb, int *count)
072a47ef 575@@ -475,7 +954,30 @@ const timelib_tzdb_index_entry *timelib_
060f741a 576 int timelib_timezone_id_is_valid(const char *timezone, const timelib_tzdb *tzdb)
c0240cb1 577 {
578 const unsigned char *tzf;
579- return (seek_to_tz_position(&tzf, timezone, tzdb));
580+
581+#ifdef HAVE_SYSTEM_TZDATA
a659fa18
ER
582+ if (tzdb == timezonedb_system) {
583+ char fname[PATH_MAX];
584+ struct stat st;
585+
586+ if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
587+ return 0;
588+ }
c0240cb1 589+
a659fa18
ER
590+ if (system_location_table) {
591+ if (find_zone_info(system_location_table, timezone) != NULL) {
592+ /* found in cache */
593+ return 1;
594+ }
595+ }
596+
597+ snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone));
598+
cacce04b 599+ return stat(fname, &st) == 0 && is_valid_tzfile(&st, 0);
a659fa18
ER
600+ }
601+#endif
909e9211 602+
c0240cb1 603+ return (inmem_seek_to_tz_position(&tzf, timezone, tzdb));
604 }
605
cacce04b 606 static int skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
072a47ef 607@@ -517,6 +1019,8 @@ static timelib_tzinfo* timelib_tzinfo_ct
060f741a 608 timelib_tzinfo *timelib_parse_tzfile(const char *timezone, const timelib_tzdb *tzdb, int *error_code)
c0240cb1 609 {
610 const unsigned char *tzf;
611+ char *memmap = NULL;
612+ size_t maplen;
613 timelib_tzinfo *tmp;
a659fa18 614 int version;
cacce04b 615 int transitions_result, types_result;
072a47ef
ER
616@@ -524,7 +1028,7 @@ timelib_tzinfo *timelib_parse_tzfile(con
617
618 *error_code = TIMELIB_ERROR_NO_ERROR;
c0240cb1 619
620- if (seek_to_tz_position(&tzf, timezone, tzdb)) {
621+ if (seek_to_tz_position(&tzf, timezone, &memmap, &maplen, tzdb)) {
622 tmp = timelib_tzinfo_ctor(timezone);
623
cacce04b 624 version = read_preamble(&tzf, tmp, &type);
072a47ef 625@@ -563,11 +1067,36 @@ timelib_tzinfo *timelib_parse_tzfile(con
da3ee842 626 return NULL;
cacce04b 627 }
539ed3cb 628
c0240cb1 629+#ifdef HAVE_SYSTEM_TZDATA
630+ if (memmap) {
631+ const struct location_info *li;
632+
633+ /* TZif-style - grok the location info from the system database,
634+ * if possible. */
635+
636+ if ((li = find_zone_info(system_location_table, timezone)) != NULL) {
909e9211
ER
637+ tmp->location.comments = timelib_strdup(li->comment);
638+ strncpy(tmp->location.country_code, li->code, 2);
c0240cb1 639+ tmp->location.longitude = li->longitude;
640+ tmp->location.latitude = li->latitude;
641+ tmp->bc = 1;
642+ }
643+ else {
cacce04b 644+ set_default_location_and_comments(&tzf, tmp);
c0240cb1 645+ }
646+
647+ /* Now done with the mmap segment - discard it. */
648+ munmap(memmap, maplen);
cacce04b
ER
649+ } else {
650+#endif
539ed3cb
AG
651 if (type == TIMELIB_TZINFO_PHP) {
652 read_location(&tzf, tmp);
cacce04b
ER
653 } else {
654 set_default_location_and_comments(&tzf, tmp);
655 }
656+#ifdef HAVE_SYSTEM_TZDATA
657+ }
c0240cb1 658+#endif
c0240cb1 659 } else {
cacce04b 660 *error_code = TIMELIB_ERROR_NO_SUCH_TIMEZONE;
c0240cb1 661 tmp = NULL;
This page took 0.108881 seconds and 4 git commands to generate.