|
From: David C. <dc...@us...> - 2005-09-24 20:19:54
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28302/src/org/rubypeople/rdt/internal/launching Modified Files: RubyInterpreter.java Added Files: ArgumentSplitter.java Log Message: Fixed splitting of arguments to allow quotes. --- NEW FILE: ArgumentSplitter.java --- package org.rubypeople.rdt.internal.launching; import java.util.ArrayList; import java.util.List; public class ArgumentSplitter { private List args; private StringBuffer currentArg; private boolean inQuotedArg; private char expectedCloseQuote; public static List split(String input) { return new ArgumentSplitter().internalSplit(input); } private ArgumentSplitter() {} private List internalSplit(String input) { currentArg = new StringBuffer(); args = new ArrayList(); for (int i=0; i< input.length(); i++) { char c = input.charAt(i); if (isEnddingQuote(c)) { recordArg(true); continue; } if (isStartingQuote(c)) { startQuotedArgument(c); continue; } if (isArgumentSeparator(c)) { recordArg(false); continue; } currentArg.append(c); } recordArg(false); return args; } private void startQuotedArgument(char c) { inQuotedArg = true; expectedCloseQuote = c; } private boolean isArgumentSeparator(char c) { return c == ' ' && !inQuotedArg; } private boolean isStartingQuote(char c) { return isQuote(c) && !inQuotedArg; } private boolean isEnddingQuote(char c) { return isQuote(c) && inQuotedArg && c == expectedCloseQuote; } private boolean isQuote(char c) { return c == '\'' || c == '\"'; } private void recordArg(boolean allowEmptyArg) { String arg = currentArg.toString(); if (allowEmptyArg || arg.length() > 0) args.add(arg); currentArg = new StringBuffer(); inQuotedArg = false; } } Index: RubyInterpreter.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RubyInterpreter.java 24 Sep 2005 12:44:02 -0000 1.11 --- RubyInterpreter.java 24 Sep 2005 20:19:41 -0000 1.12 *************** *** 5,9 **** import java.text.MessageFormat; import java.util.ArrayList; - import java.util.Arrays; import java.util.List; --- 5,8 ---- *************** *** 49,54 **** public Process exec(String arguments, File workingDirectory) throws CoreException { ! List argList = Arrays.asList(arguments.trim().split("\\s+")); ! return exec(argList, workingDirectory); } --- 48,52 ---- public Process exec(String arguments, File workingDirectory) throws CoreException { ! return exec(ArgumentSplitter.split(arguments), workingDirectory); } |