mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Bug 381804. Fix proposed by Marc Khouzam.
This commit is contained in:
parent
876ea78cbf
commit
2e0ffe0ae5
1 changed files with 2 additions and 54 deletions
|
@ -14,7 +14,6 @@
|
||||||
package org.eclipse.cdt.dsf.gdb.service;
|
package org.eclipse.cdt.dsf.gdb.service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -42,6 +41,7 @@ import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.cdt.utils.CommandLineUtil;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -203,7 +203,7 @@ public class DebugNewProcessSequence extends ReflectionSequence {
|
||||||
String args = fBackend.getProgramArguments();
|
String args = fBackend.getProgramArguments();
|
||||||
|
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
String[] argArray = splitArguments(args);
|
String[] argArray = CommandLineUtil.argumentsToArray(args);
|
||||||
fCommandControl.queueCommand(
|
fCommandControl.queueCommand(
|
||||||
fCommandFactory.createMIGDBSetArgs(getContainerContext(), argArray),
|
fCommandFactory.createMIGDBSetArgs(getContainerContext(), argArray),
|
||||||
new ImmediateDataRequestMonitor<MIInfo>(rm));
|
new ImmediateDataRequestMonitor<MIInfo>(rm));
|
||||||
|
@ -216,58 +216,6 @@ public class DebugNewProcessSequence extends ReflectionSequence {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Splits an argument string into individual arguments. Arguments can be separated by
|
|
||||||
* one or more spaces and/or newline characters. Spaces inside single and double quotes
|
|
||||||
* and backslash-escaped spaces are not considered separators and are preserved as part
|
|
||||||
* of the arguments.
|
|
||||||
*
|
|
||||||
* @param args arguments as a single string
|
|
||||||
* @return an array of arguments, each argument in a separate element
|
|
||||||
*/
|
|
||||||
private String[] splitArguments(String args) {
|
|
||||||
ArrayList<String> argList = new ArrayList<String>();
|
|
||||||
StringBuilder buf = new StringBuilder();
|
|
||||||
boolean insideSingleQuotes = false;
|
|
||||||
boolean insideDoubleQuotes = false;
|
|
||||||
boolean escaped = false;;
|
|
||||||
for (int i = 0; i < args.length(); i++) {
|
|
||||||
char c = args.charAt(i);
|
|
||||||
switch (c) {
|
|
||||||
case '\\':
|
|
||||||
escaped = !escaped;
|
|
||||||
break;
|
|
||||||
case '\'':
|
|
||||||
if (!escaped && !insideDoubleQuotes) {
|
|
||||||
insideSingleQuotes = !insideSingleQuotes;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '"':
|
|
||||||
if (!escaped && !insideSingleQuotes) {
|
|
||||||
insideDoubleQuotes = !insideDoubleQuotes;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
case '\t':
|
|
||||||
c = ' ';
|
|
||||||
//$FALL-THROUGH$
|
|
||||||
case ' ':
|
|
||||||
if (!escaped && !insideDoubleQuotes && !insideSingleQuotes) {
|
|
||||||
if (buf.length() > 0) {
|
|
||||||
argList.add(buf.toString());
|
|
||||||
buf.delete(0, buf.length());
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
buf.append(c);
|
|
||||||
}
|
|
||||||
if (buf.length() > 0)
|
|
||||||
argList.add(buf.toString());
|
|
||||||
return argList.toArray(new String[argList.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we are dealing with a remote debugging session, connect to the target.
|
* If we are dealing with a remote debugging session, connect to the target.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue