1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
From 03edd1915e60aac86a75d4db05acf554087d17e3 Mon Sep 17 00:00:00 2001
From: Rafael Ostertag <rafisol@opencsw.org>
Date: Thu, 23 Aug 2012 15:33:09 +0200
Subject: [PATCH] Make glib work with zoneinfo version 1
Glib expect zoneinfo version 2, Solaris uses zoneinfo version 1.
See also
* http://cs.ucla.edu/~eggert/tz/tz-link.htm
* tzfile.h in ftp://elsie.nci.nih.gov/pub/tzcode2011i.tar.gz
* /usr/include/tzfile.h
---
glib/gtimezone.c | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index e513f3b..d960959 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -122,7 +122,11 @@ struct _GTimeZone
const struct tzhead *header;
const struct ttinfo *infos;
+#ifndef __sun
const gint64_be *trans;
+#else
+ const gint32_be *trans;
+#endif
const guint8 *indices;
const gchar *abbrs;
gint timecnt;
@@ -272,13 +276,23 @@ parse_constant_offset (const gchar *name,
static GBytes *
zone_for_constant_offset (const gchar *name)
{
+#ifndef __sun
const gchar fake_zoneinfo_headers[] =
"TZif" "2..." "...." "...." "...."
"\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\0"
"TZif" "2..." "...." "...." "...."
"\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\1" "\0\0\0\7";
+#else
+ const gchar fake_zoneinfo_headers[] =
+ "TZif" "\0..." "...." "...." "...."
+ "\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\1" "\0\0\0\7";
+#endif
struct {
+#ifndef __sun
struct tzhead headers[2];
+#else
+ struct tzhead headers[1];
+#endif
struct ttinfo info;
gchar abbr[8];
} *fake;
@@ -378,7 +392,11 @@ g_time_zone_new (const gchar *identifier)
tzdir = getenv ("TZDIR");
if (tzdir == NULL)
+#ifndef __sun
tzdir = "/usr/share/zoneinfo";
+#else
+ tzdir = "/usr/share/lib/zoneinfo";
+#endif
if (*identifier == ':')
identifier ++;
@@ -408,8 +426,15 @@ g_time_zone_new (const gchar *identifier)
gsize size;
const struct tzhead *header = g_bytes_get_data (tz->zoneinfo, &size);
- /* we only bother to support version 2 */
+ /* we only bother to support version 2
+ *
+ * Well, I don't --raos
+ */
+#ifndef __sun
if (size < sizeof (struct tzhead) || memcmp (header, "TZif2", 5))
+#else
+ if (size < sizeof (struct tzhead) || memcmp (header, "TZif\0", 5))
+#endif
{
g_bytes_unref (tz->zoneinfo);
tz->zoneinfo = NULL;
@@ -418,6 +443,7 @@ g_time_zone_new (const gchar *identifier)
{
gint typecnt;
+#ifndef __sun
/* we trust the file completely. */
tz->header = (const struct tzhead *)
(((const gchar *) (header + 1)) +
@@ -427,6 +453,9 @@ g_time_zone_new (const gchar *identifier)
5 * guint32_from_be(header->tzh_timecnt) +
6 * guint32_from_be(header->tzh_typecnt) +
guint32_from_be(header->tzh_charcnt));
+#else
+ tz->header = header;
+#endif
typecnt = guint32_from_be (tz->header->tzh_typecnt);
tz->timecnt = guint32_from_be (tz->header->tzh_timecnt);
@@ -507,7 +536,7 @@ interval_start (GTimeZone *tz,
gint interval)
{
if (interval)
- return gint64_from_be (tz->trans[interval - 1]);
+ return (gint64)gint32_from_be (tz->trans[interval - 1]);
return G_MININT64;
}
@@ -517,7 +546,7 @@ interval_end (GTimeZone *tz,
gint interval)
{
if (interval < tz->timecnt)
- return gint64_from_be (tz->trans[interval]) - 1;
+ return (gint64)gint32_from_be (tz->trans[interval]) - 1;
return G_MAXINT64;
}
--
1.7.11.3
|