Ok, I've just sent some broken temporary patch before - didn't see the
bug, because final version was working correctly all the time :/
Here it is - tripple-checked :)
Index: Kernel/Core/Foundation/ByteString.cs
===================================================================
--- Kernel/Core/Foundation/ByteString.cs (wersja 733)
+++ Kernel/Core/Foundation/ByteString.cs (kopia robocza)
@@ -90,14 +90,14 @@
public static int Compare (byte* a, int aFrom, byte* b, int bFrom, int count)
{
int c = count;
- int aLength = ByteString.Length (a), bLength = ByteString.Length (b);
+ int aLength = ByteString.Length (a + aFrom), bLength = ByteString.Length (b + bFrom);
if (count == 0 && aLength != bLength)
return aLength - bLength;
- else if (count != 0 && (aFrom + count > aLength || bFrom + count > bLength))
+ else if (count != 0 && (count > aLength || count > bLength))
return aLength - bLength;
- if (c == 0)
+ if (c == 0) // aLen == bLen - filtered at first if
c = aLength;
for (int x = 0; x < c; ++x) {
@@ -114,15 +114,14 @@
public static int Compare (byte* a, int aFrom, string b, int bFrom, int count)
{
int c = count;
- int aLength = ByteString.Length (a);
+ int aLength = ByteString.Length (a + aFrom), bLength = b.Length - bFrom;
- if (count == 0 && aLength != b.Length) {
- return aLength - b.Length;
- } else if (count != 0 && (aFrom + count > aLength || bFrom + count > b.Length)) {
- return aLength - b.Length;
- }
+ if (count == 0 && aLength != bLength)
+ return aLength - bLength;
+ else if (count != 0 && (count > aLength || count > bLength))
+ return aLength - bLength;
- if (c == 0)
+ if (c == 0) // aLen == bLen - filtered at first if
c = aLength;
for (int x = 0; x < c; ++x) {
@@ -183,8 +182,11 @@
TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'U[S]' == 'U[S]'");
if (ByteString.Compare (longer, 4, ptr1, 0, 2) != 0)
- TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'The [US]' == 'US'");
+ TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'The [US]' == 'US' (count=2)");
+ if (ByteString.Compare (longer, 4, ptr1, 0, 0) != 0)
+ TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'The [US]' == 'US' (count=0)");
+
//Test constant CString buffer with constant String type
if (ByteString.Compare (ptr1, "SK") == 0)
@@ -194,8 +196,11 @@
TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'US' == const 'US'");
if (ByteString.Compare (longer, 4, "US", 0, 2) != 0)
- TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'The [US]' == const 'US'");
+ TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'The [US]' == const 'US' (count=2)");
+ if (ByteString.Compare (longer, 4, "US", 0, 0) != 0)
+ TextMode.WriteLine ("ByteString.Compare(): test FAIL: 'The [US]' == const 'US' (count=0)");
+
//Test that constant String is working properly
const string str1 = "US";
const string str2 = "SK";
@@ -210,6 +215,9 @@
if ((byte) str1 [1] != (byte) str2 [0])
TextMode.WriteLine ("ByteString : test FAIL: (byte)\"US\"[1]==(byte)\"SK\"[0]");
+
+ if ("\n".Length != 1)
+ TextMode.WriteLine ("ByteString : test FAIL: \"\\n\".Length==1");
}
#endregion
Index: Kernel/Core/Foundation/Convert.cs
===================================================================
--- Kernel/Core/Foundation/Convert.cs (wersja 733)
+++ Kernel/Core/Foundation/Convert.cs (kopia robocza)
@@ -48,6 +48,7 @@
if (!hex && value < 0) {
count++;
+ negative = true;
uvalue = (uint) -value;
}
Index: Kernel/Core/Foundation/CString8.cs
===================================================================
--- Kernel/Core/Foundation/CString8.cs (wersja 733)
+++ Kernel/Core/Foundation/CString8.cs (kopia robocza)
@@ -99,14 +99,14 @@
"CString8.IndexOf(): argument `substr' is null");
Diagnostics.Assert (offset >= 0 && offset < substrLen,
"CString8.IndexOf(): argument `offset' is out of range");
- Diagnostics.Assert (count >= 0 && from + count < Length && from + count < substrLen,
+ Diagnostics.Assert (count >= 0 && from + count < Length,
"CString8.IndexOf(): argument `count' is out of range");
if (count == 0)
count = Length - substrLen - offset;
- for (int x = from; x < from + count; ++x) {
- if (x + substrLen >= Length)
+ for (int x = from; x <= from + count; ++x) {
+ if (x + substrLen > Length)
break;
if (Compare (x, substr, offset, substrLen) == 0) {
@@ -128,7 +128,7 @@
for (int x = 0; x < substr.Length; ++x)
cstr [x] = (byte) substr [x];
-
+
return IndexOf (from, cstr, substr.Length, offset, count);
/*/
@@ -509,13 +509,37 @@
public static void __Test1 ()
{
- CString8* buf = (CString8*) Stubs.CString ("--keymap arg");
+ CString8* buf = (CString8*) Stubs.CString ("--keymap arg\n");
- if (buf->IndexOf ("--keymap") != 0)
- TextMode.WriteLine ("CString8.IndexOf(): test FAIL: result should be 0");
+ if (buf->Compare ("--keymap", 8) != 0)
+ TextMode.WriteLine ("CString8.Compare(): test[1] FAIL: result should be 0");
- if (buf->IndexOf ("arg") != 9)
- TextMode.WriteLine ("CString8.IndexOf(): test FAIL: result should be 9");
+ if (buf->Compare (9, "arg", 0, 3) != 0)
+ TextMode.WriteLine ("CString8.Compare(): test[2a] FAIL: result should be 0");
+
+ if (buf->Compare (9, "arg\n", 0, 0) != 0)
+ TextMode.WriteLine ("CString8.Compare(): test[2b] FAIL: result should be 0");
+
+ if (buf->Compare ((CString8*) Stubs.CString ("--keymap"), 8) != 0)
+ TextMode.WriteLine ("CString8.Compare(): test[1] FAIL: result should be 0");
+
+ if (buf->Compare (9, (CString8*) Stubs.CString ("arg"), 0, 3) != 0)
+ TextMode.WriteLine ("CString8.Compare(): test[2a] FAIL: result should be 0");
+
+ if (buf->Compare (9, (CString8*) Stubs.CString ("arg\n"), 0, 0) != 0)
+ TextMode.WriteLine ("CString8.Compare(): test[2b] FAIL: result should be 0");
+
+ int ind = buf->IndexOf ("--keymap");
+ if (ind != 0)
+ TextMode.WriteLine ("CString8.IndexOf(): test[3] FAIL: result should be 0");
+
+ ind = buf->IndexOf ("arg");
+ if (ind != 9)
+ TextMode.WriteLine ("CString8.IndexOf(): test[4] FAIL: result should be 9");
+
+ ind = buf->IndexOf ("\n");
+ if (ind != 12)
+ TextMode.WriteLine ("CString8.IndexOf(): test[5] FAIL: result should be 12");
}
#endregion
Index: Kernel/Core/Foundation/PString8.cs
===================================================================
--- Kernel/Core/Foundation/PString8.cs (wersja 733)
+++ Kernel/Core/Foundation/PString8.cs (kopia robocza)
@@ -62,7 +62,7 @@
if (len == 0)
len = strLen - offset;
- Diagnostics.Assert (offset + len >= strLen, "PString8.Concat(): offset + len >= strLen");
+ Diagnostics.Assert (offset + len <= strLen, "PString8.Concat(): offset + len <= strLen");
for (int x = offset; x < strLen && (x - offset) < len; ++x)
Concat (str [x]);
Index: Kernel/Core/CommandLine.cs
===================================================================
--- Kernel/Core/CommandLine.cs (wersja 733)
+++ Kernel/Core/CommandLine.cs (kopia robocza)
@@ -119,8 +119,8 @@
return -1;
while (argumentIndex < commandLine->Length) {
- if (commandLine->GetChar (argumentIndex) != ' ')
- return argumentIndex;
+ if (commandLine->GetChar (argumentIndex) == ' ')
+ return argumentIndex+1;
++argumentIndex;
}
@@ -132,7 +132,7 @@
{
int x = argumentIndex;
- Diagnostics.Assert (argumentIndex < 0 || argumentIndex >= commandLine->Length,
+ Diagnostics.Assert (argumentIndex >= 0 && argumentIndex < commandLine->Length,
"CommandLine.GetArgumentLength(): argument `argumentIndex' is out of range");
while (x < commandLine->Length && commandLine->GetChar (x) != ' ')
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SharpOS-Developers mailing list
SharpOS-Developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sharpos-developers