Code cleanup around glib version check (2.28 minimum).
[claws.git] / src / common / utils.c
index 941f1c7f3a6de087eb695223df4aa60caa2a8851..0a7f4211b81bf3da9fcbe76b6707abcf18a27330 100644 (file)
 
 static gboolean debug_mode = FALSE;
 
-#if !GLIB_CHECK_VERSION(2, 26, 0)
-guchar *g_base64_decode_wa(const gchar *text, gsize *out_len)
-{
-       guchar *ret;
-       gsize input_length;
-       gint state = 0;
-       guint save = 0;
-
-       input_length = strlen(text);
-
-       ret = g_malloc0((input_length / 4) * 3 + 1);
-
-       *out_len = g_base64_decode_step(text, input_length, ret, &state, &save);
-
-       return ret;
-}
-#endif
-
 /* Return true if we are running as root.  This function should beused
    instead of getuid () == 0.  */
 gboolean superuser_p (void)
@@ -134,32 +116,14 @@ GSList *slist_copy_deep(GSList *list, GCopyFunc func)
 #endif
 }
 
-void list_free_strings(GList *list)
+void list_free_strings_full(GList *list)
 {
-       list = g_list_first(list);
-
-       while (list != NULL) {
-               g_free(list->data);
-               list = list->next;
-       }
-}
-
-void slist_free_strings(GSList *list)
-{
-       while (list != NULL) {
-               g_free(list->data);
-               list = list->next;
-       }
+       g_list_free_full(list, (GDestroyNotify)g_free);
 }
 
 void slist_free_strings_full(GSList *list)
 {
-#if GLIB_CHECK_VERSION(2,28,0)
        g_slist_free_full(list, (GDestroyNotify)g_free);
-#else
-       g_slist_foreach(list, (GFunc)g_free, NULL);
-       g_slist_free(list);
-#endif
 }
 
 static void hash_free_strings_func(gpointer key, gpointer value, gpointer data)
@@ -3558,10 +3522,14 @@ static void _get_rfc822_date(gchar *buf, gint len, gboolean hidetz)
        gchar buf2[RFC822_DATE_BUFFSIZE];
 
        t = time(NULL);
-       lt = localtime_r(&t, &buf1);
+       if (hidetz)
+               lt = gmtime_r(&t, &buf1);
+       else
+               lt = localtime_r(&t, &buf1);
 
-       sscanf(asctime_r(lt, buf2), "%3s %3s %d %d:%d:%d %d\n",
-              day, mon, &dd, &hh, &mm, &ss, &yyyy);
+       if (sscanf(asctime_r(lt, buf2), "%3s %3s %d %d:%d:%d %d\n",
+              day, mon, &dd, &hh, &mm, &ss, &yyyy) != 7)
+               g_warning("failed reading date/time");
 
        g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
                   day, dd, mon, yyyy, hh, mm, ss, (hidetz? "-0000": tzoffset(&t)));