//
// author: Dan Lewis (dlewis@gmx.co.uk)
// (c) 2002
-
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-
namespace System.Text.RegularExpressions {
[Serializable]
public static Match Empty {
get { return empty; }
}
-
- public static Match Synchronized (Match inner) {
+
+ [MonoTODO ("not thread-safe")]
+ public static Match Synchronized (Match inner)
+ {
+ if (inner == null)
+ throw new ArgumentNullException ("inner");
return inner; // FIXME need to sync on machine access
}
get { return groups; }
}
- public Match NextMatch () {
+ public Match NextMatch ()
+ {
if (this == Empty)
return Empty;
return machine.Scan (regex, Text, scan_ptr, text_length);
}
- public virtual string Result (string replacement) {
+ public virtual string Result (string replacement)
+ {
+ if (replacement == null)
+ throw new ArgumentNullException ("replacement");
+ if (replacement.Length == 0)
+ throw new NotSupportedException ();
+
return ReplacementEvaluator.Evaluate (replacement, this);
}
// internal
- internal Match () : base (null, null) {
+ private Match ()
+ {
this.regex = null;
this.machine = null;
this.text_length = 0;
- this.groups = new GroupCollection ();
- groups.Add (this);
+ this.groups = new GroupCollection (1);
+ groups.SetValue (this, 0);
}
- internal Match (Regex regex, IMachine machine, string text, int text_length, int[][] grps) :
- base (text, grps[0])
+ internal Match (Regex regex, IMachine machine, string text, int text_length, int n_groups,
+ int index, int length, int n_caps) :
+ base (text, index, length, n_caps)
{
this.regex = regex;
this.machine = machine;
this.text_length = text_length;
- this.groups = new GroupCollection ();
- groups.Add (this);
- for (int i = 1; i < grps.Length; ++ i)
- groups.Add (new Group (text, grps[i]));
+ this.groups = new GroupCollection (n_groups);
+ groups.SetValue (this, 0);
}
internal Regex Regex {