Thank you, cmickeyb, for a patch to ass two string functions

to OSSL.
Fixes Mantis #3173
0.6.3-post-fixes
Melanie Thielker 2009-02-16 01:58:26 +00:00
parent 7d77e0e703
commit 37a00427bc
3 changed files with 67 additions and 0 deletions

View File

@ -43,6 +43,7 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using System.Text.RegularExpressions;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
@ -1105,5 +1106,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
loginURI = config.Configs["GridInfo"].GetString("login", loginURI);
return loginURI;
}
public LSL_String osFormatString(string str, LSL_List strings)
{
CheckThreatLevel(ThreatLevel.Low, "osFormatString");
m_host.AddScriptLPS(1);
return String.Format(str, strings.Data);
}
public LSL_List osMatchString(string src, string pattern, int start)
{
CheckThreatLevel(ThreatLevel.High, "osMatchString");
m_host.AddScriptLPS(1);
LSL_List result = new LSL_List();
// Normalize indices (if negative).
// After normlaization they may still be
// negative, but that is now relative to
// the start, rather than the end, of the
// sequence.
if (start < 0)
{
start = src.Length + start;
}
if (start < 0 || start >= src.Length)
{
return result; // empty list
}
// Find matches beginning at start position
Regex matcher = new Regex(pattern);
Match match = matcher.Match(src, start);
if (match.Success)
{
foreach (System.Text.RegularExpressions.Group g in match.Groups)
{
if (g.Success)
{
result.Add(g.Value);
result.Add(g.Index);
}
}
}
return result;
}
}
}

View File

@ -31,6 +31,8 @@ using OpenSim.Region.ScriptEngine.Interfaces;
using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{
@ -104,5 +106,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osGetGridNick();
string osGetGridName();
string osGetGridLoginURI();
LSL_String osFormatString(string str, LSL_List strings);
LSL_List osMatchString(string src, string pattern, int start);
}
}

View File

@ -38,6 +38,8 @@ using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
@ -262,6 +264,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetGridLoginURI();
}
public LSL_String osFormatString(string str, LSL_List strings)
{
return m_OSSL_Functions.osFormatString(str, strings);
}
public LSL_List osMatchString(string src, string pattern, int start)
{
return m_OSSL_Functions.osMatchString(src, pattern, start);
}
public OSSLPrim Prim;
[Serializable]