[Xfce4-commits] <xfce4-weather-plugin:master> Remove code dependency on glib-2.30.
Harald Judt
noreply at xfce.org
Mon Jul 23 21:48:01 CEST 2012
Updating branch refs/heads/master
to 8e6afef9a67f08ee247e0a15b65ded2231f08661 (commit)
from dc8454e9891448c878ccb9bdd7df841fbc672047 (commit)
commit 8e6afef9a67f08ee247e0a15b65ded2231f08661
Author: Harald Judt <h.judt at gmx.at>
Date: Mon Jul 23 21:44:39 2012 +0200
Remove code dependency on glib-2.30.
The plugin should compile with older versions of glib than 2.30,
so replace g_utf8_substring with something equivalent but less
modern.
panel-plugin/weather-config.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index e196ebf..c572d96 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -209,19 +209,29 @@ make_label (void)
gchar *
sanitize_location_name(const gchar *location_name)
{
- gchar *pos;
- long len;
+ gchar *pos, sane[LOC_NAME_MAX_LEN * 4];
+ glong len, offset;
pos = g_utf8_strchr (location_name, -1, ',');
if (pos != NULL)
- return g_utf8_substring (location_name, 0,
- g_utf8_pointer_to_offset (location_name, pos));
+ {
+ offset = g_utf8_pointer_to_offset (location_name, pos);
+ if (offset > LOC_NAME_MAX_LEN)
+ offset = LOC_NAME_MAX_LEN;
+ pos = g_utf8_strncpy (sane, location_name, offset);
+ sane[LOC_NAME_MAX_LEN * 4 - 1] = '\0';
+ return g_strdup (sane);
+ }
else
{
len = g_utf8_strlen(location_name, LOC_NAME_MAX_LEN);
if (len >= LOC_NAME_MAX_LEN)
- return g_utf8_substring (location_name, 0, len);
+ {
+ pos = g_utf8_strncpy (sane, location_name, len);
+ sane[LOC_NAME_MAX_LEN * 4 - 1] = '\0';
+ return g_strdup (sane);
+ }
if (len > 0)
return g_strdup(location_name);
More information about the Xfce4-commits
mailing list