aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/mass test client/Parsing.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/mass test client/Parsing.cs61
1 files changed, 0 insertions, 61 deletions
diff --git a/tools/mass test client/Parsing.cs b/tools/mass test client/Parsing.cs
deleted file mode 100644
index 371c3cd..0000000
--- a/tools/mass test client/Parsing.cs
+++ /dev/null
@@ -1,61 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace libsecondlife.TestClient {
6 class Parsing {
7 public static string[] ParseArguments(string str) {
8 List<string> list = new List<string>();
9 string current = "";
10 string trimmed = null;
11 bool withinQuote = false;
12 bool escaped = false;
13 foreach (char c in str) {
14 if (c == '"') {
15 if (escaped) {
16 current += '"';
17 escaped = false;
18 } else {
19 current += '"';
20 withinQuote = !withinQuote;
21 }
22 } else if (c == ' ' || c == '\t') {
23 if (escaped || withinQuote) {
24 current += c;
25 escaped = false;
26 } else {
27 trimmed = current.Trim();
28 if (trimmed.StartsWith("\"") && trimmed.EndsWith("\"")) {
29 trimmed = trimmed.Remove(0, 1);
30 trimmed = trimmed.Remove(trimmed.Length - 1);
31 trimmed = trimmed.Trim();
32 }
33 if (trimmed.Length > 0)
34 list.Add(trimmed);
35 current = "";
36 }
37 } else if (c == '\\') {
38 if (escaped) {
39 current += '\\';
40 escaped = false;
41 } else {
42 escaped = true;
43 }
44 } else {
45 if (escaped)
46 throw new FormatException(c.ToString() + " is not an escapable character.");
47 current += c;
48 }
49 }
50 trimmed = current.Trim();
51 if (trimmed.StartsWith("\"") && trimmed.EndsWith("\"")) {
52 trimmed = trimmed.Remove(0, 1);
53 trimmed = trimmed.Remove(trimmed.Length - 1);
54 trimmed = trimmed.Trim();
55 }
56 if (trimmed.Length > 0)
57 list.Add(trimmed);
58 return list.ToArray();
59 }
60 }
61}