Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2007-07-18 19:45:39 +0000
committerThomas Watson2007-07-18 19:45:39 +0000
commit336b9cc4a2f80363cb3b7c7de7ce94a25467eb33 (patch)
treebfe62353f70862d42c213144721a9d846f99b1ab
parent2f785d9fd7e5ac8145bb9dc58cd711fc3fb39b30 (diff)
downloadrt.equinox.framework-336b9cc4a2f80363cb3b7c7de7ce94a25467eb33.tar.gz
rt.equinox.framework-336b9cc4a2f80363cb3b7c7de7ce94a25467eb33.tar.xz
rt.equinox.framework-336b9cc4a2f80363cb3b7c7de7ce94a25467eb33.zip
Bug 190399 console command line parsing problem
-rw-r--r--bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandInterpreter.java43
1 files changed, 24 insertions, 19 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..1307427d6 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -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