ScriptEngine/Shared: Fix bug 5473 (v2).

bulletsim
Kim King 2011-05-16 05:57:08 -04:00 committed by Justin Clark-Casey (justincc)
parent bdd7849094
commit a2c19847b4
1 changed files with 4 additions and 2 deletions

View File

@ -1536,6 +1536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
public struct LSLInteger public struct LSLInteger
{ {
public int value; public int value;
private static readonly Regex castRegex = new Regex(@"(^[ ]*0[xX][0-9A-Fa-f][0-9A-Fa-f]*)|(^[ ]*(-?|\+?)[0-9][0-9]*)");
#region Constructors #region Constructors
public LSLInteger(int i) public LSLInteger(int i)
@ -1555,9 +1556,10 @@ namespace OpenSim.Region.ScriptEngine.Shared
public LSLInteger(string s) public LSLInteger(string s)
{ {
Regex r = new Regex("(^[ ]*0[xX][0-9A-Fa-f][0-9A-Fa-f]*)|(^[ ]*-?[0-9][0-9]*)"); Match m = castRegex.Match(s);
Match m = r.Match(s);
string v = m.Groups[0].Value; string v = m.Groups[0].Value;
// Leading plus sign is allowed, but ignored
v = v.Replace("+", "");
if (v == String.Empty) if (v == String.Empty)
{ {