From 6a331399399dc9b91d75fbe6b065e31a2db49fe0 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Sat, 14 Aug 2021 22:43:50 +0200 Subject: [PATCH] compat for glib 2.55 --- src/core/misc.c | 20 ++++++++++++++++---- src/core/misc.h | 7 +++++++ src/fe-text/textbuffer-formats.c | 16 +--------------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/core/misc.c b/src/core/misc.c index c66bbd6d..f0bbf4e0 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -95,7 +95,6 @@ int i_input_add_poll(int fd, int priority, int condition, GInputFunction functio #pragma GCC diagnostic ignored "-Wdeprecated-declarations" int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) { -#pragma GCC diagnostic pop if (tv1->tv_sec < tv2->tv_sec) return -1; if (tv1->tv_sec > tv2->tv_sec) @@ -105,11 +104,8 @@ int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) tv1->tv_usec > tv2->tv_usec ? 1 : 0; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) { -#pragma GCC diagnostic pop long secs, usecs; secs = tv1->tv_sec - tv2->tv_sec; @@ -122,6 +118,22 @@ long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) return usecs; } +#pragma GCC diagnostic pop + +#if GLIB_CHECK_VERSION(2, 56, 0) +/* nothing */ +#else +/* compatibility code for old GLib */ +GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz) +{ + GTimeVal time; + if (g_time_val_from_iso8601(iso_date, &time)) { + return g_date_time_new_from_timeval_utc(&time); + } else { + return NULL; + } +} +#endif int find_substr(const char *list, const char *item) { diff --git a/src/core/misc.h b/src/core/misc.h index 76f5644b..622470f7 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -19,6 +19,13 @@ int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) G_GNUC_DEPRECATED; long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) G_GNUC_DEPRECATED; #pragma GCC diagnostic pop +#if GLIB_CHECK_VERSION(2, 56, 0) +/* nothing */ +#else +/* compatibility code for old GLib */ +GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz); +#endif + GSList *i_slist_find_string(GSList *list, const char *key); GSList *i_slist_find_icase_string(GSList *list, const char *key); GList *i_list_find_string(GList *list, const char *key); diff --git a/src/fe-text/textbuffer-formats.c b/src/fe-text/textbuffer-formats.c index 5b15313f..20abc0df 100644 --- a/src/fe-text/textbuffer-formats.c +++ b/src/fe-text/textbuffer-formats.c @@ -1,6 +1,7 @@ #include "module.h" #include #include +#include #include #include #include @@ -18,21 +19,6 @@ gboolean scrollback_format; gboolean show_server_time; int signal_gui_render_line_text; -#if GLIB_CHECK_VERSION(2, 56, 0) -/* nothing */ -#else -/* compatibility code for old GLib */ -static GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz) -{ - GTimeVal time; - if (g_time_val_from_iso8601(iso_date, &time)) { - return g_date_time_new_from_timeval_utc(&time); - } else { - return NULL; - } -} -#endif - static void collector_free(GSList **collector) { while (*collector) {