From 57ce3afba7d553ff9ac3e33db25267948b365f1d Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Mon, 26 Jul 2010 21:33:01 +0300 Subject: [PATCH] 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. --- src/rygel/rygel-media-object.vala | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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); + } + } } -- 2.7.4