|
|
@ -36,17 +36,13 @@ namespace ICSharpCode.ILSpy.AddIn |
|
|
|
char** arr = CommandLineToArgvW(commandLine, out numberOfArgs); |
|
|
|
char** arr = CommandLineToArgvW(commandLine, out numberOfArgs); |
|
|
|
if (arr == null) |
|
|
|
if (arr == null) |
|
|
|
throw new Win32Exception(); |
|
|
|
throw new Win32Exception(); |
|
|
|
try |
|
|
|
try { |
|
|
|
{ |
|
|
|
|
|
|
|
string[] result = new string[numberOfArgs]; |
|
|
|
string[] result = new string[numberOfArgs]; |
|
|
|
for (int i = 0; i < numberOfArgs; i++) |
|
|
|
for (int i = 0; i < numberOfArgs; i++) { |
|
|
|
{ |
|
|
|
|
|
|
|
result[i] = new string(arr[i]); |
|
|
|
result[i] = new string(arr[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} finally { |
|
|
|
finally |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Free memory obtained by CommandLineToArgW.
|
|
|
|
// Free memory obtained by CommandLineToArgW.
|
|
|
|
LocalFree(new IntPtr(arr)); |
|
|
|
LocalFree(new IntPtr(arr)); |
|
|
|
} |
|
|
|
} |
|
|
@ -68,8 +64,7 @@ namespace ICSharpCode.ILSpy.AddIn |
|
|
|
if (arguments == null) |
|
|
|
if (arguments == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
StringBuilder b = new StringBuilder(); |
|
|
|
StringBuilder b = new StringBuilder(); |
|
|
|
for (int i = 0; i < arguments.Length; i++) |
|
|
|
for (int i = 0; i < arguments.Length; i++) { |
|
|
|
{ |
|
|
|
|
|
|
|
if (i > 0) |
|
|
|
if (i > 0) |
|
|
|
b.Append(' '); |
|
|
|
b.Append(' '); |
|
|
|
AppendArgument(b, arguments[i]); |
|
|
|
AppendArgument(b, arguments[i]); |
|
|
@ -79,33 +74,23 @@ namespace ICSharpCode.ILSpy.AddIn |
|
|
|
|
|
|
|
|
|
|
|
static void AppendArgument(StringBuilder b, string arg) |
|
|
|
static void AppendArgument(StringBuilder b, string arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (arg.Length > 0 && arg.IndexOfAny(charsNeedingQuoting) < 0) |
|
|
|
if (arg.Length > 0 && arg.IndexOfAny(charsNeedingQuoting) < 0) { |
|
|
|
{ |
|
|
|
|
|
|
|
b.Append(arg); |
|
|
|
b.Append(arg); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
b.Append('"'); |
|
|
|
b.Append('"'); |
|
|
|
for (int j = 0; ; j++) |
|
|
|
for (int j = 0; ; j++) { |
|
|
|
{ |
|
|
|
|
|
|
|
int backslashCount = 0; |
|
|
|
int backslashCount = 0; |
|
|
|
while (j < arg.Length && arg[j] == '\\') |
|
|
|
while (j < arg.Length && arg[j] == '\\') { |
|
|
|
{ |
|
|
|
|
|
|
|
backslashCount++; |
|
|
|
backslashCount++; |
|
|
|
j++; |
|
|
|
j++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (j == arg.Length) |
|
|
|
if (j == arg.Length) { |
|
|
|
{ |
|
|
|
|
|
|
|
b.Append('\\', backslashCount * 2); |
|
|
|
b.Append('\\', backslashCount * 2); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} else if (arg[j] == '"') { |
|
|
|
else if (arg[j] == '"') |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
b.Append('\\', backslashCount * 2 + 1); |
|
|
|
b.Append('\\', backslashCount * 2 + 1); |
|
|
|
b.Append('"'); |
|
|
|
b.Append('"'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
b.Append('\\', backslashCount); |
|
|
|
b.Append('\\', backslashCount); |
|
|
|
b.Append(arg[j]); |
|
|
|
b.Append(arg[j]); |
|
|
|
} |
|
|
|
} |
|
|
|