Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

iar_mods
Justin Clark-Casey (justincc) 2012-02-11 00:11:28 +00:00
commit aab30f5e67
1 changed files with 34 additions and 0 deletions

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using log4net;
using OpenSim.Framework;
@ -531,6 +532,11 @@ namespace OpenSim.Framework.Console
public class Parser
{
// If an unquoted portion ends with an element matching this regex
// and the next element contains a space, then we have stripped
// embedded quotes that should not have been stripped
private static Regex optionRegex = new Regex("^--[a-zA-Z0-9-]+=$");
public static string[] Parse(string text)
{
List<string> result = new List<string>();
@ -544,10 +550,38 @@ namespace OpenSim.Framework.Console
if (index % 2 == 0)
{
string[] words = unquoted[index].Split(new char[] {' '});
bool option = false;
foreach (string w in words)
{
if (w != String.Empty)
{
if (optionRegex.Match(w) == Match.Empty)
option = false;
else
option = true;
result.Add(w);
}
}
// The last item matched the regex, put the quotes back
if (option)
{
// If the line ended with it, don't do anything
if (index < (unquoted.Length - 1))
{
// Get and remove the option name
string optionText = result[result.Count - 1];
result.RemoveAt(result.Count - 1);
// Add the quoted value back
optionText += "\"" + unquoted[index + 1] + "\"";
// Push the result into our return array
result.Add(optionText);
// Skip the already used value
index++;
}
}
}
else