Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2007-06-21 19:03:09 +0000
committerThomas Watson2007-06-21 19:03:09 +0000
commitd5070a722a8c1b020deb4ff89f895caf998a0594 (patch)
tree22a01e7b554b8200245488c82ea2a90b9b75b995 /bundles/org.eclipse.osgi/console
parenta9b120ca8937b06e1e4b08b9b928ab44a69586ff (diff)
downloadrt.equinox.framework-d5070a722a8c1b020deb4ff89f895caf998a0594.tar.gz
rt.equinox.framework-d5070a722a8c1b020deb4ff89f895caf998a0594.tar.xz
rt.equinox.framework-d5070a722a8c1b020deb4ff89f895caf998a0594.zip
Bug 190399 console command line parsing problem
Diffstat (limited to 'bundles/org.eclipse.osgi/console')
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java41
1 files changed, 23 insertions, 18 deletions
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
index a330aaa8a..e83178f1a 100644
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
+++ b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java
@@ -31,6 +31,7 @@ import org.osgi.framework.Bundle;
* FrameworkCommandInterpreter provides several print methods which handle the "More" command.
*/
public class FrameworkCommandInterpreter implements CommandInterpreter {
+ private static final String WS_DELIM = " \t\n\r\f"; //$NON-NLS-1$
/** The command line in StringTokenizer form */
private StringTokenizer tok;
@@ -75,28 +76,32 @@ public class FrameworkCommandInterpreter implements CommandInterpreter {
@return A string containing the next argument on the command line
*/
public String nextArgument() {
- if (tok == null || !tok.hasMoreElements()) {
+ if (tok == null || !tok.hasMoreElements())
return null;
- }
- String token = tok.nextToken();
- //check for quotes
- int index = token.indexOf('"');
- if (index != -1) {
- //if we only have one quote, find the second quote
- if (index == token.lastIndexOf('"')) {
- token += tok.nextToken("\""); //$NON-NLS-1$
+
+ String arg = tok.nextToken();
+ if (arg.startsWith("\"")) { //$NON-NLS-1$
+ if (arg.endsWith("\"")) { //$NON-NLS-1$
+ if (arg.length() >= 2)
+ // strip the beginning and ending quotes
+ return arg.substring(1, arg.length() - 1);
}
- StringBuffer buf = new StringBuffer(token);
-
- //strip quotes
- while (index != -1) {
- buf.deleteCharAt(index);
- token = buf.toString();
- index = token.indexOf('"');
+ String remainingArg = tok.nextToken("\""); //$NON-NLS-1$
+ arg = arg.substring(1) + remainingArg;
+ // skip to next whitespace separated token
+ tok.nextToken(WS_DELIM);
+ } else if (arg.startsWith("'")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (arg.endsWith("'")) { //$NON-NLS-1$
+ if (arg.length() >= 2)
+ // strip the beginning and ending quotes
+ return arg.substring(1, arg.length() - 1);
}
- return buf.toString();
+ String remainingArg = tok.nextToken("'"); //$NON-NLS-1$
+ arg = arg.substring(1) + remainingArg;
+ // skip to next whitespace separated token
+ tok.nextToken(WS_DELIM);
}
- return (token);
+ return arg;
}
/**

Back to the top