Change parser to leave embedded quotes alone if the pattern is recognized
as an OptionSet long optionavinationmerge
parent
215acbcc96
commit
4455140f30
|
@ -31,6 +31,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -531,6 +532,11 @@ namespace OpenSim.Framework.Console
|
||||||
|
|
||||||
public class Parser
|
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)
|
public static string[] Parse(string text)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
|
@ -544,10 +550,38 @@ namespace OpenSim.Framework.Console
|
||||||
if (index % 2 == 0)
|
if (index % 2 == 0)
|
||||||
{
|
{
|
||||||
string[] words = unquoted[index].Split(new char[] {' '});
|
string[] words = unquoted[index].Split(new char[] {' '});
|
||||||
|
|
||||||
|
bool option = false;
|
||||||
foreach (string w in words)
|
foreach (string w in words)
|
||||||
{
|
{
|
||||||
if (w != String.Empty)
|
if (w != String.Empty)
|
||||||
|
{
|
||||||
|
if (optionRegex.Match(w) == Match.Empty)
|
||||||
|
option = false;
|
||||||
|
else
|
||||||
|
option = true;
|
||||||
result.Add(w);
|
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
|
else
|
||||||
|
|
Loading…
Reference in New Issue