mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 14:16:07 +08:00
Thank you, cmickeyb, for a patch to ass two string functions
to OSSL. Fixes Mantis #3173
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user