From: Zeeshan Ali (Khattak) Date: Mon, 26 Jul 2010 18:33:01 +0000 (+0300) Subject: core: Correctly compare strings X-Git-Tag: RYGEL_0_7_3~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57ce3afba7d553ff9ac3e33db25267948b365f1d;p=profile%2Fivi%2Frygel.git core: Correctly compare strings We need to be using string.collatate() rather than GLib.strcmp as the former does a locale-sensitive comparison of UTF-8 strings. --- diff --git a/src/rygel/rygel-media-object.vala b/src/rygel/rygel-media-object.vala index 1039781..6b3a01e 100644 --- a/src/rygel/rygel-media-object.vala +++ b/src/rygel/rygel-media-object.vala @@ -99,15 +99,27 @@ public abstract class Rygel.MediaObject : GLib.Object { string property) { switch (property) { case "@id": - return strcmp (this.id, media_object.id); + return this.compare_string_props (this.id, media_object.id); case "@parentID": - return strcmp (this.parent, media_object.parent); + return this.compare_string_props (this.parent.id, + media_object.parent.id); case "dc:title": - return strcmp (this.title, media_object.title); + return this.compare_string_props (this.title, media_object.title); case "upnp:class": - return strcmp (this.upnp_class, media_object.upnp_class); + return this.compare_string_props (this.upnp_class, + media_object.upnp_class); default: return 0; } } + + protected int compare_string_props (string prop1, string prop2) { + if (prop1 == null) { + return -1; + } else if (prop2 == null) { + return 1; + } else { + return prop1.collate (prop2); + } + } }