Revision: 18235
http://svn.sourceforge.net/gaim/?rev=18235&view=rev
Author: sadrul
Date: 2007-04-04 13:22:16 -0700 (Wed, 04 Apr 2007)
Log Message:
-----------
"elb: g_build_pathv is Glib 2.8"
Modified Paths:
--------------
trunk/console/libgnt/gntfilesel.c
Modified: trunk/console/libgnt/gntfilesel.c
===================================================================
--- trunk/console/libgnt/gntfilesel.c 2007-04-04 20:08:27 UTC (rev 18234)
+++ trunk/console/libgnt/gntfilesel.c 2007-04-04 20:22:16 UTC (rev 18235)
@@ -37,6 +37,106 @@
}
}
+#if !GLIB_CHECK_VERSION(2,8,0)
+/* ripped from glib/gfileutils.c */
+static gchar *
+g_build_path_va (const gchar *separator,
+ gchar **str_array)
+{
+ GString *result;
+ gint separator_len = strlen (separator);
+ gboolean is_first = TRUE;
+ gboolean have_leading = FALSE;
+ const gchar *single_element = NULL;
+ const gchar *next_element;
+ const gchar *last_trailing = NULL;
+ gint i = 0;
+
+ result = g_string_new (NULL);
+
+ next_element = str_array[i++];
+
+ while (TRUE) {
+ const gchar *element;
+ const gchar *start;
+ const gchar *end;
+
+ if (next_element) {
+ element = next_element;
+ next_element = str_array[i++];
+ } else
+ break;
+
+ /* Ignore empty elements */
+ if (!*element)
+ continue;
+
+ start = element;
+
+ if (separator_len) {
+ while (start &&
+ strncmp (start, separator, separator_len) == 0)
+ start += separator_len;
+ }
+
+ end = start + strlen (start);
+
+ if (separator_len) {
+ while (end >= start + separator_len &&
+ strncmp (end - separator_len, separator, separator_len) == 0)
+ end -= separator_len;
+
+ last_trailing = end;
+ while (last_trailing >= element + separator_len &&
+ strncmp (last_trailing - separator_len, separator, separator_len) == 0)
+ last_trailing -= separator_len;
+
+ if (!have_leading) {
+ /* If the leading and trailing separator strings are in the
+ * same element and overlap, the result is exactly that element
+ */
+ if (last_trailing <= start)
+ single_element = element;
+
+ g_string_append_len (result, element, start - element);
+ have_leading = TRUE;
+ } else
+ single_element = NULL;
+ }
+
+ if (end == start)
+ continue;
+
+ if (!is_first)
+ g_string_append (result, separator);
+
+ g_string_append_len (result, start, end - start);
+ is_first = FALSE;
+ }
+
+ if (single_element) {
+ g_string_free (result, TRUE);
+ return g_strdup (single_element);
+ } else {
+ if (last_trailing)
+ g_string_append (result, last_trailing);
+
+ return g_string_free (result, FALSE);
+ }
+}
+
+static gchar *
+g_build_pathv (const gchar *separator,
+ gchar **args)
+{
+ if (!args)
+ return NULL;
+
+ return g_build_path_va (separator, args);
+}
+
+#endif
+
static char *
process_path(const char *path)
{
@@ -259,6 +359,11 @@
path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", sel->current, str);
str = process_path(path);
g_free(path);
+ path = str;
+
+ if (gnt_file_sel_set_current_location(sel, path))
+ goto success;
+
path = g_path_get_dirname(str);
g_free(str);
@@ -298,8 +403,8 @@
gnt_widget_draw(sel->files);
}
globfree(&gl);
+#endif
success:
-#endif
g_free(path);
return TRUE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|