The list sort functions compared things backwards. Fixed.
The list iterator macros now check for NULL args -Yosh
This commit is contained in:
parent
4fb20bdbcc
commit
89a5c21c07
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jan 28 23:53:27 PST 1998 Manish Singh <yosh@gimp.org>
|
||||||
|
|
||||||
|
* glist.c
|
||||||
|
* gslist.c
|
||||||
|
* testglib.c: the sort functions compared backwards. Fixed
|
||||||
|
* glib.h: list iterator macros now check for NULL pointers
|
||||||
|
|
||||||
Tue Jan 27 09:46:57 PST 1998 Manish Singh <yosh@gimp.org>
|
Tue Jan 27 09:46:57 PST 1998 Manish Singh <yosh@gimp.org>
|
||||||
|
|
||||||
* gstring.c: g_string_prepend and g_string_prepend_c had
|
* gstring.c: g_string_prepend and g_string_prepend_c had
|
||||||
|
@ -419,8 +419,8 @@ void g_list_foreach (GList *list,
|
|||||||
GFunc func,
|
GFunc func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
#define g_list_previous(list) (((GList *)list)->prev)
|
#define g_list_previous(list) ((list) ? (((GList *)list)->prev) : NULL)
|
||||||
#define g_list_next(list) (((GList *)list)->next)
|
#define g_list_next(list) ((list) ? (((GList *)list)->next) : NULL)
|
||||||
|
|
||||||
/* Singly linked lists
|
/* Singly linked lists
|
||||||
*/
|
*/
|
||||||
@ -455,7 +455,7 @@ void g_slist_foreach (GSList *list,
|
|||||||
GFunc func,
|
GFunc func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
#define g_slist_next(list) (((GSList *)list)->next)
|
#define g_slist_next(list) ((list) ? (((GSList *)list)->next) : NULL)
|
||||||
|
|
||||||
/* List Allocators
|
/* List Allocators
|
||||||
*/
|
*/
|
||||||
|
@ -381,12 +381,12 @@ g_list_insert_sorted (GList *list,
|
|||||||
return new_list;
|
return new_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp = (*func) (tmp_list->data, data);
|
cmp = (*func) (data, tmp_list->data);
|
||||||
|
|
||||||
while ((tmp_list->next) && (cmp > 0))
|
while ((tmp_list->next) && (cmp > 0))
|
||||||
{
|
{
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
cmp = (*func) (tmp_list->data, data);
|
cmp = (*func) (data, tmp_list->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
|
@ -358,13 +358,13 @@ g_slist_insert_sorted (GSList *list,
|
|||||||
return new_list;
|
return new_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp = (*func) (tmp_list->data, data);
|
cmp = (*func) (data, tmp_list->data);
|
||||||
|
|
||||||
while ((tmp_list->next) && (cmp > 0))
|
while ((tmp_list->next) && (cmp > 0))
|
||||||
{
|
{
|
||||||
prev_list = tmp_list;
|
prev_list = tmp_list;
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
cmp = (*func) (tmp_list->data, data);
|
cmp = (*func) (data, tmp_list->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
|
@ -138,7 +138,7 @@ main (int argc,
|
|||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
t = g_list_nth (list, i);
|
t = g_list_nth (list, i);
|
||||||
if (*((gint*) t->data) != (9 - i))
|
if (*((gint*) t->data) != i)
|
||||||
g_error ("Sorted insert failed");
|
g_error ("Sorted insert failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ main (int argc,
|
|||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
t = g_list_nth (list, i);
|
t = g_list_nth (list, i);
|
||||||
if (*((gint*) t->data) != i)
|
if (*((gint*) t->data) != (9 - i))
|
||||||
g_error ("Sorted insert failed");
|
g_error ("Sorted insert failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ main (int argc,
|
|||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
st = g_slist_nth (slist, i);
|
st = g_slist_nth (slist, i);
|
||||||
if (*((gint*) st->data) != (9 - i))
|
if (*((gint*) st->data) != i)
|
||||||
g_error ("Sorted insert failed");
|
g_error ("Sorted insert failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ main (int argc,
|
|||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
st = g_slist_nth (slist, i);
|
st = g_slist_nth (slist, i);
|
||||||
if (*((gint*) st->data) != i)
|
if (*((gint*) st->data) != (9 - i))
|
||||||
g_error("Sorted insert failed");
|
g_error("Sorted insert failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user