summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2010-02-06 20:15:48 -0500
committerJason Woodward2010-02-06 20:15:48 -0500
commitabd4335495a65d097426fdd92503c07dc1e366a3 (patch)
tree378c2fce4dec64f5b37a1281d7bfb8cbc265e1db
parentb1865781123c5f4bdbc2aeb1b33fbf4819f0e8b4 (diff)
downloadgslapt-abd4335495a65d097426fdd92503c07dc1e366a3.tar.gz
additional error checking and handling for series support
-rw-r--r--src/callbacks.c3
-rw-r--r--src/series.c18
-rw-r--r--src/series.h1
3 files changed, 17 insertions, 5 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index e58141a..6a01f59 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -601,6 +601,8 @@ void build_package_treeviewlist (GtkWidget *treeview)
}
series = gslapt_series_map_lookup(gslapt_series_map, location);
+ if (series == NULL)
+ series = g_strdup(location);
gtk_list_store_append(GTK_LIST_STORE(base_model), &iter);
gtk_list_store_set(GTK_LIST_STORE(base_model), &iter,
@@ -622,6 +624,7 @@ void build_package_treeviewlist (GtkWidget *treeview)
gdk_pixbuf_unref(status_icon);
g_free(status);
g_free(short_desc);
+ g_free(series);
}
for (i = 0; i < installed->pkg_count; ++i) {
diff --git a/src/series.c b/src/series.c
index 665989c..a6e7235 100644
--- a/src/series.c
+++ b/src/series.c
@@ -67,16 +67,24 @@ GSLAPT_SERIES_MAP_FILL_END:
char *gslapt_series_map_lookup(GHashTable *map, const char *key)
{
char *value = NULL, *converted = NULL;
- void *v = g_hash_table_lookup (map, key);
+ void *v;
+
+ if (key == NULL)
+ return NULL;
+
+ v = g_hash_table_lookup (map, key);
if (v != NULL) {
value = (char *)v;
} else {
- value = g_path_get_basename(key);
+ if (strcmp(key,"") != 0)
+ value = g_path_get_basename(key);
}
- converted = g_convert(value, strlen(value), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
- if (converted != NULL)
- value = converted;
+ if (value != NULL) {
+ converted = g_convert(value, strlen(value), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ if (converted != NULL)
+ value = converted;
+ }
return value;
}
diff --git a/src/series.h b/src/series.h
index 7a48124..ca48c0a 100644
--- a/src/series.h
+++ b/src/series.h
@@ -2,6 +2,7 @@
#define GSLAPT_SERIES_HEADER
#include <stdlib.h>
+#include <string.h>
#include <stdio.h>
#include <glib.h>
#include "config.h"