Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2004-10-29 15:37:23 +0000
committerDarin Wright2004-10-29 15:37:23 +0000
commit3dc4e84962270e92578b0be5589c33d34cbad9c2 (patch)
treeeab55e75a64a2766b453aa1cc599807ca6ef08d7 /org.eclipse.ui.externaltools
parent3bd3a2a2ca13b59b5e2168ec493d1b9fbfd47b4a (diff)
downloadeclipse.platform.debug-3dc4e84962270e92578b0be5589c33d34cbad9c2.tar.gz
eclipse.platform.debug-3dc4e84962270e92578b0be5589c33d34cbad9c2.tar.xz
eclipse.platform.debug-3dc4e84962270e92578b0be5589c33d34cbad9c2.zip
Bug 72054 - Literal quotes no longer work in external tool arguments
Bug 77295 - Argument parsing for command line launching
Diffstat (limited to 'org.eclipse.ui.externaltools')
-rw-r--r--org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java105
1 files changed, 2 insertions, 103 deletions
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java
index fbbecb0c3..06b108a46 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java
@@ -14,21 +14,18 @@ package org.eclipse.ui.externaltools.internal.launchConfigurations;
import java.io.File;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.ui.RefreshTab;
-import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
/**
@@ -198,106 +195,8 @@ public class ExternalToolsUtil {
if (arguments == null || arguments.length() == 0) {
return new String[0];
}
- ArgumentParser parser= new ArgumentParser(arguments);
- String[] res= parser.parseArguments();
+ String[] res= DebugPlugin.parseArguments(arguments);
return res;
}
- private static class ArgumentParser {
- private String fArgs;
- private int fIndex= 0;
- private int ch= -1;
-
- public ArgumentParser(String args) {
- fArgs= args;
- }
-
- public String[] parseArguments() {
- List v= new ArrayList();
-
- ch= getNext();
- while (ch > 0) {
- if (Character.isWhitespace((char)ch)) {
- ch= getNext();
- } else {
- if (ch == '"') {
- v.add(parseString());
- } else {
- v.add(parseToken());
- }
- }
- }
-
- String[] result= new String[v.size()];
- v.toArray(result);
- return result;
- }
-
- private int getNext() {
- if (fIndex < fArgs.length())
- return fArgs.charAt(fIndex++);
- return -1;
- }
-
- private String parseString() {
- StringBuffer buf= new StringBuffer();
- ch= getNext();
- while (ch > 0 && ch != '"') {
- if (ch == '\\') {
- ch= getNext();
- if (ch != '"') { // Only escape double quotes
- buf.append('\\');
- } else {
- if (Platform.getOS().equals(Constants.OS_WIN32)) {
- // @see Bug 26870. Windows requires an extra escape for embedded strings
- buf.append('\\');
- }
- }
- }
- if (ch > 0) {
- buf.append((char)ch);
- ch= getNext();
- }
- }
-
- ch= getNext();
-
- return buf.toString();
- }
-
- private String parseToken() {
- StringBuffer buf= new StringBuffer();
-
- while (ch > 0 && !Character.isWhitespace((char)ch)) {
- if (ch == '\\') {
- ch= getNext();
- if (Character.isWhitespace((char)ch)) {
- // end of token, don't lose trailing backslash
- buf.append('\\');
- return buf.toString();
- }
- if (ch > 0) {
- if (ch != '"') { // Only escape double quotes
- buf.append('\\');
- } else {
- if (Platform.getOS().equals(Constants.OS_WIN32)) {
- // @see Bug 26870. Windows requires an extra escape for embedded strings
- buf.append('\\');
- }
- }
- buf.append((char)ch);
- ch= getNext();
- } else if (ch == -1) { // Don't lose a trailing backslash
- buf.append('\\');
- }
- } else if (ch == '"') {
- buf.append(parseString());
- } else {
- buf.append((char)ch);
- ch= getNext();
- }
- }
- return buf.toString();
- }
- }
}

Back to the top