[Mono-list] String.Trim patch

Jeffrey Stedfast fejj@ximian.com
04 Jan 2002 12:59:08 -0500


--=-LOLHGE/l5lkgQr8V1koo
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Bob,

I wasn't able to apply your patch after several minutes of futzing
around with it (apparently enough changed between 1.25 and 1.27 to make
applying the patch a nightmare ;-)

Anyways, I looked over the main differences that your code changed and
think that the following patch fixes the same things that you were
aiming to fix with your patch but also fixes the last of the brokenness
that you were talking about that still existed after your patch had been
applied (I hope?).

I'm about to apply this to CVS because it certainly does fix some logic
mistakes that I had made (shame on me!). Could you let me know if it
also fixes the problems you were trying to fix?

Thanks,

Jeff

Index: String.cs
===================================================================
RCS file: /cvs/public/mcs/class/corlib/System/String.cs,v
diff -u -r1.27 String.cs
--- String.cs	2002/01/04 09:47:24	1.27
+++ String.cs	2002/01/04 13:37:41
@@ -1576,7 +1576,7 @@
 			}
 
 			matches = true;
-			for (end = this.length-1; end > begin; end--) {
+			for (end = this.length - 1; matches && end > begin; end--) {
 				if (trimChars != null) {
 					matches = false;
 					foreach (char c in trimChars) {
@@ -1589,7 +1589,7 @@
 				}
 			}
 
-			if (begin == end)
+			if (begin >= end)
 				return String.Empty;
 
 			return Substring (begin, end - begin);


On Fri, 2002-01-04 at 04:00, Bob Smith wrote:
> The Trim method contained bugs that prevent mcs from working from mint (it
> still doesnt work with the patch, but it is closer to working) so I have
> reworked the method so that it should work better. Could you have a look
> at it and see if its commit worthy?
> 
> http://www.thestuff.net/temp/String.diff
> 
> Thanks,
> Bob
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj@ximian.com  - www.ximian.com

--=-LOLHGE/l5lkgQr8V1koo
Content-Disposition: attachment; filename=String.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1

Index: String.cs
=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
RCS file: /cvs/public/mcs/class/corlib/System/String.cs,v
retrieving revision 1.27
diff -u -r1.27 String.cs
--- String.cs	2002/01/04 09:47:24	1.27
+++ String.cs	2002/01/04 13:56:49
@@ -1576,7 +1576,7 @@
 			}
=20
 			matches =3D true;
-			for (end =3D this.length-1; end > begin; end--) {
+			for (end =3D this.length - 1; matches && end > begin; end--) {
 				if (trimChars !=3D null) {
 					matches =3D false;
 					foreach (char c in trimChars) {
@@ -1589,7 +1589,7 @@
 				}
 			}
=20
-			if (begin =3D=3D end)
+			if (begin >=3D end)
 				return String.Empty;
=20
 			return Substring (begin, end - begin);

--=-LOLHGE/l5lkgQr8V1koo--