Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2012-10-25 12:42:48 +0000
committerMarkus Keller2012-10-25 12:42:48 +0000
commit05be2519c00be901ef1067b044790fa07dc9871e (patch)
tree24f4ae0ed9976036b14c2153152e7049d8181a7f
parent6eec50eec8559204a878257b6487d40afa2912bc (diff)
downloadeclipse.platform.debug-05be2519c00be901ef1067b044790fa07dc9871e.tar.gz
eclipse.platform.debug-05be2519c00be901ef1067b044790fa07dc9871e.tar.xz
eclipse.platform.debug-05be2519c00be901ef1067b044790fa07dc9871e.zip
Bug 387504 comment 13: Bugs in program argument parsing (compared to command line)v20121025-124248
Reverted special treatment of Windows arguments in DebugPlugin.exec(..)
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java28
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java37
2 files changed, 36 insertions, 29 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
index e1be26ba6..5e814fea9 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
@@ -853,13 +853,6 @@ public class DebugPlugin extends Plugin {
* @since 3.0
*/
public static Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
- if (Platform.getOS().equals(Constants.OS_WIN32)) {
- String[] winCmdLine= new String[cmdLine.length];
- for (int i= 0; i < cmdLine.length; i++) {
- winCmdLine[i]= winQuote(cmdLine[i]);
- }
- cmdLine= winCmdLine;
- }
Process p= null;
try {
if (workingDirectory == null) {
@@ -885,27 +878,6 @@ public class DebugPlugin extends Plugin {
return p;
}
- private static boolean needsQuoting(String s) {
- int len = s.length();
- if (len == 0) // empty string has to be quoted
- return true;
- for (int i = 0; i < len; i++) {
- switch (s.charAt(i)) {
- case ' ': case '\t': case '\\': case '"':
- return true;
- }
- }
- return false;
- }
-
- private static String winQuote(String s) {
- if (! needsQuoting(s))
- return s;
- s = s.replaceAll("([\\\\]*)\"", "$1$1\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$
- s = s.replaceAll("([\\\\]*)\\z", "$1$1"); //$NON-NLS-1$ //$NON-NLS-2$
- return "\"" + s + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
/**
* Returns whether this plug-in is in the process of
* being shutdown.
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java
index 2262084d6..b42235869 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java
@@ -32,7 +32,7 @@ import org.eclipse.osgi.service.environment.Constants;
/**
* Tests {@link org.eclipse.debug.core.DebugPlugin#parseArguments(String)} and
- * {@link org.eclipse.debug.core.DebugPlugin#renderCommandLine(String[], int[])}.
+ * {@link org.eclipse.debug.core.DebugPlugin#renderArguments(String[], int[])}.
*/
public class ArgumentParsingTests extends TestCase {
@@ -105,6 +105,7 @@ public class ArgumentParsingTests extends TestCase {
private static ArrayList runCommandLine(String[] execArgs)
throws CoreException, IOException {
+ execArgs = quoteWindowsArgs(execArgs);
Process process = DebugPlugin.exec(execArgs, null);
BufferedReader procOut = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -116,6 +117,40 @@ public class ArgumentParsingTests extends TestCase {
return procArgs;
}
+ private static String[] quoteWindowsArgs(String[] cmdLine) {
+ // see https://bugs.eclipse.org/387504#c13 , workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6511002
+ if (Platform.getOS().equals(Constants.OS_WIN32)) {
+ String[] winCmdLine = new String[cmdLine.length];
+ for (int i = 0; i < cmdLine.length; i++) {
+ winCmdLine[i] = winQuote(cmdLine[i]);
+ }
+ cmdLine = winCmdLine;
+ }
+ return cmdLine;
+ }
+
+
+ private static boolean needsQuoting(String s) {
+ int len = s.length();
+ if (len == 0) // empty string has to be quoted
+ return true;
+ for (int i = 0; i < len; i++) {
+ switch (s.charAt(i)) {
+ case ' ': case '\t': case '\\': case '"':
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String winQuote(String s) {
+ if (! needsQuoting(s))
+ return s;
+ s = s.replaceAll("([\\\\]*)\"", "$1$1\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$
+ s = s.replaceAll("([\\\\]*)\\z", "$1$1"); //$NON-NLS-1$ //$NON-NLS-2$
+ return "\"" + s + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
// -- tests:
public void testEmpty() throws Exception {

Back to the top