Author: alanmc
Date: 2007-03-23 09:52:29 -0500 (Fri, 23 Mar 2007)
New Revision: 74875
Modified:
trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs
Log:
Updated comparisons for bencoded strings. Just to be 100% sure it's comparing
right.
Modified: trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs 2007-03-23
14:50:30 UTC (rev 74874)
+++ trunk/bitsharp/src/MonoTorrent.BEncoding/BEncodedString.cs 2007-03-23
14:52:29 UTC (rev 74875)
@@ -193,13 +193,16 @@
public int CompareTo(BEncodedString other)
{
- return string.CompareOrdinal(this.Text, other.Text);
+ int difference=0;
+ int length = this.textBytes.Length > other.textBytes.Length ?
other.textBytes.Length : this.textBytes.Length;
+
+ for (int i = 0; i < length; i++)
+ if ((difference =
this.textBytes[i].CompareTo(other.textBytes[i])) != 0)
+ return difference;
+
+ return this.textBytes.Length > other.textBytes.Length ? 1 : 0;
}
- public int CompareTo(string other)
- {
- return string.CompareOrdinal(this.Text, other);
- }
#endregion
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches