Author: alanmc
Date: 2007-03-24 11:22:53 -0500 (Sat, 24 Mar 2007)
New Revision: 74934

Modified:
   trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs
Log:
Bugfixed CompareTo and added safety check for .Equals

Modified: trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs  2007-03-24 
08:41:08 UTC (rev 74933)
+++ trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs  2007-03-24 
16:22:53 UTC (rev 74934)
@@ -200,6 +200,9 @@
                 if ((difference = 
this.textBytes[i].CompareTo(other.textBytes[i])) != 0)
                     return difference;
 
+            if (this.textBytes.Length == other.textBytes.Length)
+                return 0;
+
             return this.textBytes.Length > other.textBytes.Length ? 1 : -1;
         }
 
@@ -211,6 +214,8 @@
         public override bool Equals(object obj)
         {
             BEncodedString other = obj as BEncodedString;
+            if (obj is string)
+                other = new BEncodedString((string)obj);
 
             if (other == null)
                 return false;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to