summaryrefslogtreecommitdiff
path: root/glib/patches/0003-Make-glib-work-with-zoneinfo-version-1.patch
diff options
context:
space:
mode:
Diffstat (limited to 'glib/patches/0003-Make-glib-work-with-zoneinfo-version-1.patch')
-rw-r--r--glib/patches/0003-Make-glib-work-with-zoneinfo-version-1.patch124
1 files changed, 124 insertions, 0 deletions
diff --git a/glib/patches/0003-Make-glib-work-with-zoneinfo-version-1.patch b/glib/patches/0003-Make-glib-work-with-zoneinfo-version-1.patch
new file mode 100644
index 0000000..dfd8180
--- /dev/null
+++ b/glib/patches/0003-Make-glib-work-with-zoneinfo-version-1.patch
@@ -0,0 +1,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
+