[gimp] Some of the stupidity from the previous commit was copied from here
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Some of the stupidity from the previous commit was copied from here
- Date: Tue, 9 Feb 2010 21:41:11 +0000 (UTC)
commit 52eaf96a6c4b7ca36da50df07604535fc282a9a9
Author: Michael Natterer <mitch gimp org>
Date: Mon Feb 8 00:28:47 2010 +0100
Some of the stupidity from the previous commit was copied from here
app/core/gimplist.c | 88 ++++++++++++++++++++++++++++-----------------------
1 files changed, 48 insertions(+), 40 deletions(-)
---
diff --git a/app/core/gimplist.c b/app/core/gimplist.c
index ed48888..df83de5 100644
--- a/app/core/gimplist.c
+++ b/app/core/gimplist.c
@@ -491,8 +491,8 @@ static void
gimp_list_uniquefy_name (GimpList *gimp_list,
GimpObject *object)
{
- GList *list;
- const gchar *name = gimp_object_get_name (object);
+ gchar *name = (gchar *) gimp_object_get_name (object);
+ GList *list;
if (! name)
return;
@@ -505,57 +505,65 @@ gimp_list_uniquefy_name (GimpList *gimp_list,
if (object != object2 &&
name2 &&
! strcmp (name, name2))
- {
- GList *list2;
- gchar *ext = strrchr (name, '#');
- gchar *new_name = NULL;
- gint unique_ext = 0;
+ break;
+ }
- if (ext)
- {
- gchar *ext_str;
+ if (list)
+ {
+ gchar *ext;
+ gchar *new_name = NULL;
+ gint unique_ext = 0;
+
+ name = g_strdup (name);
- unique_ext = atoi (ext + 1);
+ ext = strrchr (name, '#');
- ext_str = g_strdup_printf ("%d", unique_ext);
+ if (ext)
+ {
+ gchar ext_str[8];
- /* check if the extension really is of the form "#<n>" */
- if (! strcmp (ext_str, ext + 1))
- {
- *ext = '\0';
- }
- else
- {
- unique_ext = 0;
- }
+ unique_ext = atoi (ext + 1);
- g_free (ext_str);
- }
+ g_snprintf (ext_str, sizeof (ext_str), "%d", unique_ext);
- do
+ /* check if the extension really is of the form "#<n>" */
+ if (! strcmp (ext_str, ext + 1))
{
- unique_ext++;
+ if (ext > name && *(ext - 1) == ' ')
+ ext--;
- g_free (new_name);
+ *ext = '\0';
+ }
+ else
+ {
+ unique_ext = 0;
+ }
+ }
- new_name = g_strdup_printf ("%s#%d", name, unique_ext);
+ do
+ {
+ unique_ext++;
- for (list2 = gimp_list->list; list2; list2 = g_list_next (list2))
- {
- object2 = list2->data;
- name2 = gimp_object_get_name (object2);
+ g_free (new_name);
- if (object != object2 &&
- name2 &&
- ! strcmp (new_name, name2))
- break;
- }
- }
- while (list2);
+ new_name = g_strdup_printf ("%s #%d", name, unique_ext);
- gimp_object_take_name (object, new_name);
- break;
+ for (list = gimp_list->list; list; list = g_list_next (list))
+ {
+ GimpObject *object2 = list->data;
+ const gchar *name2 = gimp_object_get_name (object2);
+
+ if (object != object2 &&
+ name2 &&
+ ! strcmp (new_name, name2))
+ break;
+ }
}
+ while (list);
+
+ g_free (name);
+
+ gimp_object_take_name (object, new_name);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]