[Mono-list] string-icall.c patch for Trim()

Nick Drochak ndrochak@gol.com
Mon, 22 Apr 2002 17:07:44 +0900


This is a multi-part message in MIME format.

------=_NextPart_000_0017_01C1EA20.38724330
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

There's an off-by-one error in Trim().  Here's a patch and a test case for
it.

Perhaps Patrick or Lupus could commit to cvs.

Thanks,
Nick D.

------=_NextPart_000_0017_01C1EA20.38724330
Content-Type: text/plain;
	name="simpTest.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="simpTest.cs"

using System;=0A=
=0A=
namespace NS {=0A=
	class C {=0A=
		public static int Main() {=0A=
			string s =3D "True ";=0A=
			if (s.Trim() =3D=3D "True")=0A=
				return 0;=0A=
=0A=
			return 1;=0A=
		}=0A=
	}=0A=
}
------=_NextPart_000_0017_01C1EA20.38724330
Content-Type: application/octet-stream;
	name="string-icalls.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="string-icalls.diff"

Index: string-icalls.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mono/mono/metadata/string-icalls.c,v=0A=
retrieving revision 1.4=0A=
diff -u -r1.4 string-icalls.c=0A=
--- string-icalls.c	20 Apr 2002 13:49:34 -0000	1.4=0A=
+++ string-icalls.c	22 Apr 2002 04:12:24 -0000=0A=
@@ -322,7 +322,7 @@=0A=
 	}=0A=
 =0A=
 	if (0 =3D=3D typ || 2 =3D=3D typ) {=0A=
-		for (i =3D srclen - lenfirst; i !=3D 0; i--) {=0A=
+		for (i =3D srclen - lenfirst - 1; i !=3D 0; i--) {=0A=
 			if (mono_string_isinarray(chars, arrlen, src[i]))=0A=
 				lenlast++;=0A=
 			else =0A=

------=_NextPart_000_0017_01C1EA20.38724330--