From 4886cc8258783047ab035ea35ec5b08997948567 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 1 Jul 2013 19:40:12 +0100 Subject: [PATCH 1/3] Don't use G_VALUE_INIT since it was introduced in glib 2.30, and our minimum requirement is glib 2.28. This was giving a compilation error in FreeBSD 9.1, since it uses glib 2.28. --- src/fe-gtk/banlist.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fe-gtk/banlist.c b/src/fe-gtk/banlist.c index 897e61d6..d80d9333 100644 --- a/src/fe-gtk/banlist.c +++ b/src/fe-gtk/banlist.c @@ -323,10 +323,14 @@ banlist_copyentry (GtkWidget *menuitem, GtkTreeView *view) GtkTreeModel *model; GtkTreeSelection *sel; GtkTreeIter iter; - GValue mask = G_VALUE_INIT; - GValue from = G_VALUE_INIT; - GValue date = G_VALUE_INIT; + GValue mask; + GValue from; + GValue date; char *str; + + memset (&mask, 0, sizeof (mask)); + memset (&from, 0, sizeof (from)); + memset (&date, 0, sizeof (date)); /* get selection (which should have been set on click) * and temporarily switch to single mode to get selected iter */ From 9a789bc9e79ffa29e1f333ebc0242cff013b815b Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 2 Jul 2013 01:41:34 +0100 Subject: [PATCH 2/3] Now handle_message_tag_time() doesn't use "timezone" since it is not defined in *BSD. --- src/common/proto-irc.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 7742c064..b19d9afa 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1326,6 +1326,26 @@ process_named_servermsg (session *sess, char *buf, char *rawname, char *word_eol rawname, NULL, 0, tags_data->timestamp); } +/* Returns the timezone offset. This should be the same as the variable + * "timezone" in time.h, but *BSD doesn't have it. + */ +static int +get_timezone(void) +{ + struct tm tm_utc, tm_local; + time_t t, time_utc, time_local; + + time (&t); + + gmtime_r (&t, &tm_utc); + localtime_r (&t, &tm_local); + + time_utc = mktime (&tm_utc); + time_local = mktime (&tm_local); + + return time_utc - time_local; +} + /* Handle time-server tags. * * Sets tags_data->timestamp to the correct time (in unix time). @@ -1370,7 +1390,7 @@ handle_message_tag_time (const char *time, message_tags_data *tags_data) } /* get rid of the local time (mktime() receives a local calendar time) */ - tags_data->timestamp -= timezone; + tags_data->timestamp -= get_timezone(); } else { From 4b40597c76063e0d97c6e0b6295c72caf3dc2d07 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 2 Jul 2013 02:22:41 +0100 Subject: [PATCH 3/3] Fixed get_timezone() to work on windows. --- src/common/proto-irc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index b19d9afa..29102afc 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1337,8 +1337,16 @@ get_timezone(void) time (&t); + /* gmtime() and localtime() are thread-safe on windows. + * on other systems we should use {gmtime,localtime}_r(). + */ +#if WIN32 + tm_utc = *gmtime (&t); + tm_local = *localtime (&t); +#else gmtime_r (&t, &tm_utc); localtime_r (&t, &tm_local); +#endif time_utc = mktime (&tm_utc); time_local = mktime (&tm_local);