Commit Graph
12 Commits
Author SHA1 Message Date
Zoltan Varga f1e948d1b0 2008-02-10 Zoltan Varga <[email protected]>
* replace.cs (NeedsGroupsOrCaptures): New property. Determines whenever the
	replacement process needs access to the groups or captures properties of the
	Match object.

	* Group.cs: Add an internal ctor which avoids allocations.

	* Match.cs: Ditto.

	* BaseMachine.cs interpreter.cs: Add an optimization to avoid fully creating
	Match objects during Replace () if the replacement string is simple.

svn path=/trunk/mcs/; revision=95394
2008-02-10 18:08:27 +00:00
Raja R Harinath b35097bc0b Support RegexOptions.RightToLeft in Replace().
In b/class/System/System.Text.RegularExpressions:
	* BaseMachine.cs (Replace): Use either LTRReplace or RTLReplace
	based on regex.
	(LTRReplace): Make internal and rename the MatchAppendEvaluator
	version of Replace to this.
	(RTLReplace): New.
	* Regex.cs (Replace): Use LTRReplace and RTLReplace from BaseMachine.
	* replace.cs (ReplacementEvaluator.Evaluate): Optimize simple case.
	Based on patch by Stephane Delcroix.

In b/class/System/Test/System.Text.RegularExpressions:
	* MatchTest.cs (Match_Backref): New.
	* RegexReplace.cs (direction, testcase.direction): New.
	(testcase..ctor): Allow specifying the direction of the replace.
	(ReplaceTests): Test replace in both directions.
	(EvaluatorTests): New test based on #321036.

svn path=/trunk/mcs/; revision=89034
2007-11-06 22:03:35 +00:00
Raja R Harinath baf4cdef81 In System.Text.RegularExpressions:
* replace.cs (Compile): Don't unescape string.

In Test/System.Text.RegularExpressions:
	* RegexReplace.cs (tests): New test from #317092.
	(ReplaceTests): Don't catch an AssertException.

svn path=/trunk/mcs/; revision=89021
2007-11-06 19:28:12 +00:00
Raja R Harinath f77874d49a * replace.cs (ReplacementEvaluator.Compile): Rewrite to avoid
creating several intermediate strings.  Simplify internal
intermediate representation.
(ReplacementEvaluator.EvaluateAppend): New.  Version of Evaluate
that builds the result directly on a passed-in StringBuilder.
(ReplacementEvaluator.Evaluate): Just a wrapper around
EvaluateAppend.
* regex.cs (MatchAppendEvaluator): New internal delegate.
(Regex.Replace): Use MatchAppendEvaluator.
(Regex.Adapter): New class used to adapt a MatchEvaluator to a
MatchAppendEvaluator.

Rationale: We avoid allocating a lot of memory in the
	   Replace (..., string, ...) case.  We penalize the
	   Replace (..., MatchEvaluator, ...) version slightly,
	   but that is already a slow case.

svn path=/trunk/mcs/; revision=44994
2005-05-25 12:27:07 +00:00
Raja R Harinath afc63db0fa In Test/System.Text.RegularExpressions:
* RegexReplace.cs: Add testcase for $+.

In System.Text.RegularExpressions:
	* replace.cs (ReplacementEvaluator.CompileTerm): Fix group
	returned by $+.

svn path=/trunk/mcs/; revision=44925
2005-05-24 10:28:19 +00:00
Raja R Harinath 2b8fc93056 In .:
* System_test.dll.sources: Add
	System.Text.RegularExpressions/RegexReplace.cs.

In System.Text.RegularExpressions:
	Fix #74735.
	* replace.cs (ReplacementEvaluator.Compile): Allow CompileTerm to
	fail and yet have advanced the pointer.  Append the scanned-over
	portion to the "literal" being built.
	(ReplacementEvaluator.CompileTerm): Don't throw any exceptions.
	If a term cannot be recognized, just return null.

In Test/System.Text.RegularExpressions:
	* RegexReplace.cs: New file.  Most of the tests were inspired by
	#74735.

svn path=/trunk/mcs/; revision=44813
2005-05-20 12:44:24 +00:00
Raja R Harinath b8335e58b1 Some low-hanging fruit.
* replace.cs (ReplacementEvalutator.Term.AppendResult): Renamed
from GetResult.  Modified to append to a passed-in StringBuilder
rather than return a string.
(ReplacementEvaluator.Evaluate): Update.

svn path=/trunk/mcs/; revision=44795
2005-05-20 06:39:12 +00:00
Raja R Harinath 0db5645ea7 In System.Text.RegularExpressions:
* Capture.cs, Group.cs, Match.cs: New files split out of ...
	* match.cs: ... this.  Remove.

In .:
	* System.dll.sources: Update to reflect split-up of
	System.Text.RegularExpressions/match.cs.

svn path=/trunk/mcs/; revision=44793
2005-05-20 05:44:45 +00:00
Ben Maurer e2a91c4d71 2004-11-08 Ben Maurer <[email protected]>
* replace.cs, parser.cs: Use stringbuilder for allocation sanity.

svn path=/trunk/mcs/; revision=35869
2004-11-09 01:27:09 +00:00
Duncan Mak 24f5ef2c44 Add MIT license to System.dll
svn path=/trunk/mcs/; revision=30054
2004-06-21 18:02:11 +00:00
Miguel de Icaza 392a1522ce Patch from Dan Lewisi
Carlos' bug seems to stem from my failure to interpolate
the "$$" substitution pattern properly.

This fixes bug #48666

svn path=/trunk/mcs/; revision=18492
2003-10-01 21:51:20 +00:00
Dan Lewis ad375c8180 Regex classes, initial revision.
svn path=/trunk/mcs/; revision=2205
2002-01-31 08:00:16 +00:00