Re: Bug#14412: g_list_find_custom inconsistent with GCompareFunc



Hi John,

The bug, you reported is fixed now. You still have to return 0 for two equal
elements, but now it is properly documented and seperated from GEqualFunc as
used by GHashTable.

> > > Description:
> > > The glib API says of g_list_find_custom, "It iterates over the list,
> > > calling the given function which should return 0 when the desired
> > > element is found.
> >
> > That has also bugged me for a while. So I introduced another Function
> > Type:
> > typedef gboolean (*GEqualFunc) (gconstpointer  a, gconstpointer  b);
> >
> > That allows us to differentiate the (so far) two meanings of GCompareFunc
> > at the API level. a GCompareFunc works like strcmp and a GEqualFunc
> > returns TRUE for equal values. I havn't yet updated the Documentation, but
> > I'll do that, when I'm going to commit.
> >
> > If no-one objects, I'll commit the attached patch next week. Note, that
> > this won't break any code, as gint and gboolean are the same.
> 
> please go ahead and on the way check other usages of *compare* as well.
> basically, "compare" should return results, and be only used in contexts,
> where something like this is desired:
> /* helper macro to avoid signed overflow for value comparisions */
> #define G_BSEARCH_ARRAY_CMP(v1,v2) ((v1) < (v2) ? -1 : (v1) > (v2) ? 1 : 0)

Yes, it's done. A quick grep through gtk+ revealed some other locations of
false GCompareFunc and false 'compare' though. You might want to check (I'm
not going to touch gtk+, unless 'ordered' to do so.... ;-)
 
> [META: when will the bugtracker deal with multiple To: adresses?]

[META-TOO: hihi, I also always fail that hurdle at first try.]

Bye,
Sebastian
-- 
Sebastian Wilhelmi                   |            här ovanför alla molnen
mailto:wilhelmi ira uka de           |     är himmlen så förunderligt blå
http://goethe.ira.uka.de/~wilhelmi   |




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]