[Goodies-commits] r7545 - in xfce4-weather-plugin/trunk: . panel-plugin

Colin Leroy colin at xfce.org
Sat Jun 13 09:28:24 CEST 2009


Author: colin
Date: 2009-06-13 07:28:23 +0000 (Sat, 13 Jun 2009)
New Revision: 7545

Modified:
   xfce4-weather-plugin/trunk/ChangeLog
   xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c
Log:
2009-06-13	Colin Leroy <colin at colino.net>

	* panel-plugin/weather-translate.c: fix bug #3818, "weekdays in 
	Russian are displayed ugly in forecast tab". First patch fixes a
	too short buffer (by Sergey Otinov), second patch checks whether
	the strftime-formatted buffer is UTF-8 (based on a patch from
	Yves-Alexis Perez).



Modified: xfce4-weather-plugin/trunk/ChangeLog
===================================================================
--- xfce4-weather-plugin/trunk/ChangeLog	2009-06-13 07:04:45 UTC (rev 7544)
+++ xfce4-weather-plugin/trunk/ChangeLog	2009-06-13 07:28:23 UTC (rev 7545)
@@ -1,3 +1,11 @@
+2009-06-13	Colin Leroy <colin at colino.net>
+
+	* panel-plugin/weather-translate.c: fix bug #3818, "weekdays in 
+	Russian are displayed ugly in forecast tab". First patch fixes a
+	too short buffer (by Sergey Otinov), second patch checks whether
+	the strftime-formatted buffer is UTF-8 (based on a patch from
+	Yves-Alexis Perez).
+
 2009-06-12	Colin Leroy <colin at colino.net>
 
 	* panel-plugin/*: Add an about button in the summary window.

Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c	2009-06-13 07:04:45 UTC (rev 7544)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c	2009-06-13 07:28:23 UTC (rev 7545)
@@ -32,7 +32,7 @@
 
 
 #define HDATE_N    (sizeof(gchar) * 100)
-#define DAY_LOC_N  (sizeof(gchar) * 20)
+#define DAY_LOC_N  (sizeof(gchar) * 100)
 #define TIME_LOC_N (sizeof(gchar) * 20)
 
 
@@ -302,8 +302,9 @@
   gchar      *hdate;
   struct tm   time;
   gint        size = 0, i = 0;
- gchar      **lsup_split;
-
+  gchar      **lsup_split;
+  int          len;
+  
   if (lsup == NULL || strlen (lsup) == 0)
     return NULL;
 
@@ -332,8 +333,13 @@
     {
       hdate = g_malloc (HDATE_N);
 
-      strftime (hdate, HDATE_N, _("%x at %X Local Time"), &time);
-
+      len = strftime (hdate, HDATE_N, _("%x at %X Local Time"), &time);
+      hdate[len] = 0;
+      if (!g_utf8_validate(hdate, -1, NULL)) {
+         gchar *utf8 = g_locale_to_utf8(hdate, -1, NULL, NULL, NULL);
+	 g_free(hdate);
+	 hdate = utf8;
+      }
       return hdate;
     }
   else
@@ -350,6 +356,7 @@
   guint        i;
   const gchar *days[] = {"su", "mo", "tu", "we", "th", "fr", "sa", NULL};
   gchar       *day_loc;
+  int          len;
 
   if (day == NULL || strlen (day) < 2)
     return NULL;
@@ -366,7 +373,13 @@
 
       day_loc = g_malloc (DAY_LOC_N);
 
-      strftime (day_loc, DAY_LOC_N, "%A", &time);
+      len = strftime (day_loc, DAY_LOC_N, "%A", &time);
+      day_loc[len] = 0;
+      if (!g_utf8_validate(day_loc, -1, NULL)) {
+         gchar *utf8 = g_locale_to_utf8(day_loc, -1, NULL, NULL, NULL);
+	 g_free(day_loc);
+	 day_loc = utf8;
+      }
 
       return day_loc;
     }
@@ -444,6 +457,7 @@
   gchar     **time_split, *time_loc;
   gint        i = 0, size = 0;
   struct tm   time_tm;
+  int          len;
 
   if (strlen (time) == 0)
     return NULL;
@@ -461,7 +475,13 @@
   _fill_time (&time_tm, time_split[0], time_split[1], time_split[2]);
   g_strfreev (time_split);
 
-  strftime (time_loc, TIME_LOC_N, "%X", &time_tm);
+  len = strftime (time_loc, TIME_LOC_N, "%X", &time_tm);
+  time_loc[len] = 0;
+  if (!g_utf8_validate(time_loc, -1, NULL)) {
+     gchar *utf8 = g_locale_to_utf8(time_loc, -1, NULL, NULL, NULL);
+     g_free(time_loc);
+     time_loc = utf8;
+  }
 
   return time_loc;
 }




More information about the Goodies-commits mailing list