Commit Graph
102 Commits
Author SHA1 Message Date
Arina Itkes 7c81b3ab52 Changes in ChangeLog moved to their place
svn path=/trunk/mcs/; revision=90650
2007-12-04 11:01:39 +00:00
Miguel de Icaza 3cfcca3926 2007-11-12 Atsushi Enomoto <[email protected]>
* System.dll.sources : added S.R.InteropSvcs.ComTypes types.

svn path=/trunk/mcs/; revision=89684
2007-11-15 16:50:05 +00:00
Raja R Harinath 01dbfb50d5 Fix 324390
In System/System.Text.RegularExpressions:
	* BaseMachine.cs (LTRReplace): Don't use non-advancement of 'ptr'
	to deduce absence of matches -- a match can have length 0.
	(RTLReplace): Likewise.

In System/Test/System.Text.RegularExpressions:
	* RegexReplace.cs (tests): New test from #324390.

svn path=/trunk/mcs/; revision=89176
2007-11-08 03:31:44 +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
Gert Driesen 083af1ff31 * GroupTest.cs: Improved test for null argument check.
* MatchTest.cs: Improved tests for null argument checks. Added and
fixed replacement tests.
* RegexMatchTest.cs: Marked tests that do not pass on MS as NotDotNet.
Fixed expected result for trial 5.
* RegexResultTests.cs: Fixed Assert.
* Match.cs: Do not throw NotSupportedException on zero-length 
replacement argument.

svn path=/trunk/mcs/; revision=88685
2007-11-01 21:17:50 +00:00
Arina Itkes 9d7c2d7c36 - Change Log updated for revisions 88065, 88356 and 88375
- Original Copyright is set on extracted by refactoring class BaseMachine.

svn path=/trunk/mcs/; revision=88390
2007-10-29 15:46:34 +00:00
Juraj Skripsky e1559f84d7 2007-10-24 Juraj Skripsky <[email protected]>
* Regex.cs: Store and re-use IMachine, no need to re-instantiate
	it every time we're matching.


svn path=/trunk/mcs/; revision=88076
2007-10-24 15:33:49 +00:00
Gert Driesen bf1bbd952a * RegexTest.cs: Removed. Test was already moved to the appropriate
location.

svn path=/trunk/mcs/; revision=87867
2007-10-21 13:29:41 +00:00
Juraj Skripsky 5e5f78f18c 2007-06-21 Juraj Skripsky <[email protected]>
* quicksearch.ch: Optimization. Add byte array as skip table for
   chars <= 255, falling back to the hashtable for chars > 255 and
   skip distances > 255.


svn path=/trunk/mcs/; revision=80478
2007-06-21 14:31:00 +00:00
Raja R Harinath 05c754d952 In System.Text.RegularExpressions:
Fix #80554
	* parser.cs (ResolveReferences): Don't throw an expression if a
	capture assertion reference cannot be resolved.
	(ParseGroupingConstruct): Provide fallback expression to a capture
	assertion.
	* syntax.cs (CaptureAssertion): If the bareword doesn't refer to
	the name of a capture group, fallback to treating it as a literal
	expression.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (bug80554_trials): New tests based on #80554.

svn path=/trunk/mcs/; revision=75885
2007-04-18 14:52:01 +00:00
Raja R Harinath b27e2a88ae * interpreter.cs (Eval) <OpCode.Reference>: Distribute for loop inside if.
for () if (a) s1; else s2; => if (a) for () s1; else for () s2;

svn path=/trunk/mcs/; revision=75393
2007-04-04 14:46:59 +00:00
Raja R Harinath 1b0f319466 * Regex.cs (~Regex): Don't define in NET_2_0 profile.
svn path=/trunk/mcs/; revision=75338
2007-04-03 11:43:49 +00:00
Raja R Harinath 24bba3fcc8 In System.Text.RegularExpressions:
Fix #79472
	* parser.cs (Parser.GetMapping): Use the actual group numbers to
	build the mapping.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (GroupNumbers): New test based on #79472.

svn path=/trunk/mcs/; revision=70374
2007-01-02 17:52:33 +00:00
Andrew Skiba 692e5cf88b revert unnecessary TARGET_JVM
svn path=/trunk/mcs/; revision=66184
2006-10-03 12:50:13 +00:00
Andrew Skiba 7f0db39bd5 TARGET_JVM
svn path=/trunk/mcs/; revision=66033
2006-09-28 13:45:23 +00:00
Gert Driesen d4accb58b4 * CaptureCollection.cs: Removed virtual keyword to fix API mismatches.
* MatchCollection.cs: Removed virtual keyword to fix API mismatches.
* GroupCollection.cs: Removed virtual keyword to fix API mismatches.

svn path=/trunk/mcs/; revision=61254
2006-05-30 10:01:00 +00:00
Raja R Harinath 083ccb79d8 In System.Text.RegularExpressions:
Fix #78278
	Remove 65535-limit on number of repetitions matched by a pattern.
	We still have a 65535 limit on the length of a pattern and the
	number of groups in a pattern.
	* compiler.cs (PatternCompiler.EmitCount): New.  Emits an int as
	two ushorts into the program stream.
	(EmitInfo, EmitRepeat, EmitFastRepeat): Use it to emit integers
	rather than shorts.
	* interpreter.cs (Intepreter.ReadProgramCount): Read an int
	emitted into the program stream.
	(Interpreter): Use it.  Update counts.
	(Interpreter.Eval) [OpCode.Repeat, OpCode.FastRepeat]: Likewise.
	* parser.cs (ParseGroup): Pass 0x7ffffff as the max value for '*'
	and '+' repetition patterns.
	* arch.cs (Info, Repeat, FastRepeat): Update description.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (Kill65535_1, Kill65535_2, No65535Limit): New tests
	based on #78278.

svn path=/trunk/mcs/; revision=60401
2006-05-08 13:44:23 +00:00
Raja R Harinath c6ea88f745 Treat fixed repetitions of simple regexes as simple too.
* syntax.cs (Expression.IsComplex): Make abstract.
(Group.IsComplex, Alternation.IsComplex): Move ...
(CompositeExpression.IsComplex): ... here.
(Group.GetAnchorInfo): Reduce allocations.  Avoid creating another
ArrayList, and use a StringBuilder to build up the string.
(Repetition.GetAnchorInfo): Use a StringBuilder to build up the string.
(ExpressionAssertion.IsComplex): Override.

svn path=/trunk/mcs/; revision=59583
2006-04-18 09:59:13 +00:00
Raja R Harinath a0072aeec0 In System.Text.RegularExpressions:
2006-04-17  Florian Gross  <[email protected]>
	    Raja R Harinath  <[email protected]>

	* syntax.cs (CharacterClass.Compile): Emit categories after the
	character intervals so that the evaluator can pick up the
	'IgnoreCase' flag.

In Test/System.Text.RegularExpressions:
2006-04-17  Florian Gross  <[email protected]>

	* RegexBugs.cs (CharClassWithIgnoreCase): Ensure that character
	classes don't interfere with RegexOptions.IgnoreCase.

Started looking at some of Florian's patches, which I realized now that
he hadn't applied.

svn path=/trunk/mcs/; revision=59538
2006-04-17 14:05:46 +00:00
Raja R Harinath d96a4c42b2 In System.Text.RegularExpressions:
Fix #78007
	* interpreter.cs (Interpreter.Eval) [Anchor, Position.StartOfString]:
	Don't reset 'ptr' to 0 during forward scan.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (Bug78007): New test from #78007.

svn path=/trunk/mcs/; revision=59177
2006-04-07 13:44:55 +00:00
Raja R Harinath 4d94dda2bf In System.Text.RegularExpressions:
Fix #76345
	* interpreter.cs (Interpreter.FastEval) [FastRepeat]: If the first
	tail operation has a 'negate' flag, avoid the "match next char"
	optimization.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (Bug76345): New test from #76345.

svn path=/trunk/mcs/; revision=59174
2006-04-07 12:01:44 +00:00
Raja R Harinath aeacac9505 In System.Text.RegularExpressions:
Fix #69269
	* arch.cs (OpCode.NotCategory): New.  Stands for matching a
	character _not_ from the given category.
	* debug.cs (DisassembleBlock): Handle it.
	* compiler.cs (ICompiler.EmitNotCategory): New.
	(Compiler.EmitNotCategory): New.  Emit OpCode.NotCategory.
	* syntax.cs (CharacterClass.Compile): Don't conflate negation of
	the character class and negation of the category.  Use
	EmitNotCategory.
	* interpreter.cs (Interpreter.Eval): Pass OpCode.NotCategory to
	EvalChar.
	(Interpreter.EvalChar): Handle it.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (Bug69269): New test from #69269.

svn path=/trunk/mcs/; revision=59173
2006-04-07 10:00:23 +00:00
Raja R Harinath 91300ea498 Fix #77487
* System.Text.RegularExpressions/interpreter.cs (Eval) [Until, FastUntil]:
Set 'deep' to null when evaluating the tail.  Ensure that backtracks don't
confuse the recursion vs. iteration detector.
* Test/System.Text.RegularExpressions/RegexBugs.cs (Bug77487):
New test based on #77487.

svn path=/trunk/mcs/; revision=59114
2006-04-06 14:29:06 +00:00
Raja R Harinath 5c74d8a989 * interpreter.cs (Eval) [Until, lazy]: Avoid extra evaluation on a
degenerate match.

svn path=/trunk/mcs/; revision=58954
2006-04-03 14:04:53 +00:00
Raja R Harinath 5718114083 In System.Text.RegularExpressions:
* parser.cs (Parser.ParseCharacterClass): Handle some more errors.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (HangingHyphens1): New testcase for exceptions in character ranges.

svn path=/trunk/mcs/; revision=58806
2006-03-30 16:37:29 +00:00
Raja R Harinath 0117c762c6 In System.Text.RegularExpressions:
* parser.cs (Parser.ParseCharacterClass): Don't automatically
	assume there's a range when we see '-'.  Ensure that we have seen
	at least one other character, and that we aren't already parsing a
	range.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (HangingHyphens): New tests from #77626, and
	related bugs found by inspection.

svn path=/trunk/mcs/; revision=58776
2006-03-30 12:29:51 +00:00
Raja R Harinath 41c152eba7 In System.Text.RegularExpressions:
Fix #77626
	* parser.cs (Parser.ParseCharacterClass): Set 'last' when we find
	that a '-' doesn't signify a range.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (HangingHyphens): New test from #77626.

svn path=/trunk/mcs/; revision=58774
2006-03-30 10:18:44 +00:00
Kornél Pál d993e00c33 * Regex.cs: Added support for regular expressions compiled to assemblies by compiling the pattern. This solution ignores existing CIL code but provides full support for regular expression classes compiled by MS.NET.
svn path=/trunk/mcs/; revision=54917
2005-12-29 19:34:27 +00:00
Sebastien Pouliot 1a7ff3d408 2005-11-21 Sebastien Pouliot <[email protected]>
* CaptureCollection.cs: Fixed length check.
	* Group.cs: Added missing validation for Synchronized method.
	* Match.cs: Added missing validation for Synchronized and Result 
	methods.
	* MatchEvaluator.cs: Added [Serializable] for 2.0 profile.
	* RegexCompilationInfo.cs: Added missing property validation.
	* Regex.cs: Implemented UseOptionC and UseOptionR protected methods
	(now documented). Fixed API for 2.0 profile.
	* RegexRunner.cs: Stubbed CharInClass for 2.0 profile.


svn path=/trunk/mcs/; revision=53312
2005-11-21 18:33:35 +00:00
Sebastien Pouliot 43a0fba6b1 2005-11-17 Sebastien Pouliot <[email protected]>
* MatchCollection.cs: Add missing virtual to indexer property.

svn path=/trunk/mcs/; revision=53208
2005-11-17 20:24:47 +00:00
Sebastien Pouliot 048be78654 2005-11-17 Sebastien Pouliot <[email protected]>
* Match.cs: Removed the ": base ()" on the private ctor as it is
	unrequired and cause an extra public ctor to added (bug #76736).


svn path=/trunk/mcs/; revision=53207
2005-11-17 20:20:13 +00:00
Raja R Harinath 955798252a * interpreter.cs (Interpreter.Eval) [OpCode.Until]: Invert the
sense of a test to reflect the code re-organization.

svn path=/trunk/mcs/; revision=50566
2005-09-23 09:34:08 +00:00
Raja R Harinath f0af80be04 update with more info.
svn path=/trunk/mcs/; revision=50496
2005-09-22 15:21:44 +00:00
Raja R Harinath 26594d40db Fix #72152, #72989.
* interpreter.cs (Interpreter.Eval) [OpCode.Until]: Avoid some
cases of recursion when dealing with eager quantifiers too.

svn path=/trunk/mcs/; revision=50491
2005-09-22 15:06:55 +00:00
Raja R Harinath 1a3f0b79ee * interpreter.cs (Interpreter.Eval) [OpCode.Until]: Avoid some
cases of recursion when dealing with the minimum count and lazy
quantifiers.

svn path=/trunk/mcs/; revision=50369
2005-09-21 12:24:12 +00:00
Raja R Harinath 38bf36b081 In .:
* System.dll.sources: Update.

In System.Text.RegularExpressions:
	* regex.cs: Remove.  Split into ...
	* MatchEvaluator.cs, Regex.cs, RegexCompilationInfo.cs,	
	RegexOptions.cs: ... these.  Now every publicly exposed type in
	this namespace has its own file.

svn path=/trunk/mcs/; revision=48728
2005-08-23 14:15:25 +00:00
Florian Gross f7b97fed97 Fix for ECMAScript \d
svn path=/trunk/mcs/; revision=47536
2005-07-21 21:57:15 +00:00
Raja R Harinath 8ada155a61 Make even more lazier.
* MatchCollection.cs (TryToGet): Don't generate match i+1 when
we're looking for match i.  Change post-conditions.
(FullList): New helper property.  Ensures the list is fully populated.
(Count, CopyTo): Use it.
(Enumerator.Current): Update to new post-conditions of TryToGet.
(Enumerator.MoveNext): Likewise.  Don't modify index if we're
beyond the end.

svn path=/trunk/mcs/; revision=47264
2005-07-13 12:34:50 +00:00
Raja R Harinath 9106f292c5 In System.Text.RegularExpressions:
* MatchCollection.cs: Convert to incremental mode.
	* regex.cs (Regex.Matches): Update.  Pass responsibility of
	generating all matches to MatchCollection.

In Test/System.Text.RegularExpressions:
	* RegexTest.cs (Matches1, Matches2, ..., Matches10): Combine into ...
	(Matches): ... this.  Convert to use a data-driven approach.  Use ...
	(trials): ... this.  New variable that lists the regexp, input
	text and expected results.
	(runTrial): New.  Run a suite of MatchCollection tests on each trial.
	Tests both incremental and non-incremental modes.

svn path=/trunk/mcs/; revision=47079
2005-07-08 09:49:44 +00:00
Raja R Harinath a001119e72 * parser.cs (Parser.ConsumeWhitespace): Add bounds check.
svn path=/trunk/mcs/; revision=45960
2005-06-14 12:20:57 +00:00
Raja R Harinath 4e8fc6ec9a In System.Text.RegularExpressions:
Fix #74753.
	* Match.cs (Match) [zero-argument variant]: Make private.
	* GroupCollection (Item) [string variant]: Don't look for the
	group number in an empty match.

In Test/System.Text.RegularExpressions:
	* RegexBugs.cs (NameLookupInEmptyMatch): New test from #74753.

svn path=/trunk/mcs/; revision=45958
2005-06-14 11:44:35 +00:00
Raja R Harinath bcc7b46795 * interpreter.cs (Interpreter.GenerateMatch): Avoid allocating two
intermediate arrays to build the final result.
(Interpreter.GetGroupInfo, Interpreter.PopulateGroup): New helper
functions.
* CaptureCollection.cs (list): Change from ArrayList to list.
(SetValue): New internal helper, used by Interpreter.PopulateGroup.
(Enumerator): Remove helper class.
(IEnumerator.GetEnumerator): Just use list.GetEnumerator.
* GroupCollection.cs: Likewise.
* Group.cs (Group): Move responsibility of populating 'Captures'
to Interpreter.PopulateGroup.
* Match.cs (Match): Move responsibility of populating 'Groups' to
Interpreter.GenerateMatch.

This reduced the time for 100000 iterations of the 'regex'[1] benchmark
from 63s to 53s.

svn path=/trunk/mcs/; revision=45757
2005-06-10 13:54:07 +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
Ben Maurer dbdfe8157a 2005-05-20 Ben Maurer <[email protected]>
* regex.cs: Some memory allocation optimizations.


svn path=/trunk/mcs/; revision=44829
2005-05-20 16:23:11 +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 4698fd7099 * compiler.cs (InterpreterFactory.GroupCount): Fix. The 0'th
index corresponds to Opcode.Info.

svn path=/trunk/mcs/; revision=44812
2005-05-20 12:05:57 +00:00
Raja R Harinath 9819d57368 More low-hanging fruit.
* parser.cs (Parser.Unescape): If the string doesn't contain any
'\' character, don't allocate a new string.

svn path=/trunk/mcs/; revision=44800
2005-05-20 08:50:48 +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