diff options
author | Justin Clark-Casey (justincc) | 2012-02-11 00:11:28 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-02-11 00:11:28 +0000 |
commit | aab30f5e67090496c80c0f1aa7898205da4c7b8b (patch) | |
tree | 76fd5651ee150934254c342c9436d320e2a4c43b /OpenSim/Framework/Console/CommandConsole.cs | |
parent | Make ScenePresence.MovementFlag a private only settable value to reduce compl... (diff) | |
parent | Change parser to leave embedded quotes alone if the pattern is recognized (diff) | |
download | opensim-SC_OLD-aab30f5e67090496c80c0f1aa7898205da4c7b8b.zip opensim-SC_OLD-aab30f5e67090496c80c0f1aa7898205da4c7b8b.tar.gz opensim-SC_OLD-aab30f5e67090496c80c0f1aa7898205da4c7b8b.tar.bz2 opensim-SC_OLD-aab30f5e67090496c80c0f1aa7898205da4c7b8b.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/Console/CommandConsole.cs')
-rw-r--r-- | OpenSim/Framework/Console/CommandConsole.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index a0d3541..0d6288b 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Diagnostics; | 31 | using System.Diagnostics; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Text.RegularExpressions; | ||
34 | using System.Threading; | 35 | using System.Threading; |
35 | using log4net; | 36 | using log4net; |
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
@@ -531,6 +532,11 @@ namespace OpenSim.Framework.Console | |||
531 | 532 | ||
532 | public class Parser | 533 | public class Parser |
533 | { | 534 | { |
535 | // If an unquoted portion ends with an element matching this regex | ||
536 | // and the next element contains a space, then we have stripped | ||
537 | // embedded quotes that should not have been stripped | ||
538 | private static Regex optionRegex = new Regex("^--[a-zA-Z0-9-]+=$"); | ||
539 | |||
534 | public static string[] Parse(string text) | 540 | public static string[] Parse(string text) |
535 | { | 541 | { |
536 | List<string> result = new List<string>(); | 542 | List<string> result = new List<string>(); |
@@ -544,10 +550,38 @@ namespace OpenSim.Framework.Console | |||
544 | if (index % 2 == 0) | 550 | if (index % 2 == 0) |
545 | { | 551 | { |
546 | string[] words = unquoted[index].Split(new char[] {' '}); | 552 | string[] words = unquoted[index].Split(new char[] {' '}); |
553 | |||
554 | bool option = false; | ||
547 | foreach (string w in words) | 555 | foreach (string w in words) |
548 | { | 556 | { |
549 | if (w != String.Empty) | 557 | if (w != String.Empty) |
558 | { | ||
559 | if (optionRegex.Match(w) == Match.Empty) | ||
560 | option = false; | ||
561 | else | ||
562 | option = true; | ||
550 | result.Add(w); | 563 | result.Add(w); |
564 | } | ||
565 | } | ||
566 | // The last item matched the regex, put the quotes back | ||
567 | if (option) | ||
568 | { | ||
569 | // If the line ended with it, don't do anything | ||
570 | if (index < (unquoted.Length - 1)) | ||
571 | { | ||
572 | // Get and remove the option name | ||
573 | string optionText = result[result.Count - 1]; | ||
574 | result.RemoveAt(result.Count - 1); | ||
575 | |||
576 | // Add the quoted value back | ||
577 | optionText += "\"" + unquoted[index + 1] + "\""; | ||
578 | |||
579 | // Push the result into our return array | ||
580 | result.Add(optionText); | ||
581 | |||
582 | // Skip the already used value | ||
583 | index++; | ||
584 | } | ||
551 | } | 585 | } |
552 | } | 586 | } |
553 | else | 587 | else |