# HG changeset patch # User mhaupt # Date 1433234419 -7200 # Node ID d03088193a17a85f450da230724d4e6f5dd1630b # Parent 4632d53923d4586ea9d1e463e9f4d612015282ee 8081604: rename ScriptingFunctions.tokenizeCommandLine Summary: This used to be a single-purpose private helper; it is now used by external clients, and for new purposes. Consequently, it deserves a less specific name. Reviewed-by: attila, lagergren, sundar diff -r 4632d53923d4 -r d03088193a17 src/jdk/nashorn/internal/runtime/ScriptingFunctions.java --- a/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Tue Jun 02 10:40:10 2015 +0200 +++ b/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Tue Jun 02 10:40:19 2015 +0200 @@ -137,7 +137,7 @@ final ScriptObject global = Context.getGlobal(); // Set up initial process. - final ProcessBuilder processBuilder = new ProcessBuilder(tokenizeCommandLine(JSType.toString(string))); + final ProcessBuilder processBuilder = new ProcessBuilder(tokenizeString(JSType.toString(string))); // Current ENV property state. final Object env = global.get(ENV_NAME); @@ -237,23 +237,22 @@ } /** - * Break an exec string into tokens, honoring quoted arguments and escaped - * spaces. + * Break a string into tokens, honoring quoted arguments and escaped spaces. * - * @param execString a {@link String} with the command line to execute. + * @param str a {@link String} to tokenize. * @return a {@link List} of {@link String}s representing the tokens that - * constitute the command line. + * constitute the string. * @throws IOException in case {@link StreamTokenizer#nextToken()} raises it. */ - public static List tokenizeCommandLine(final String execString) throws IOException { - final StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(execString)); + public static List tokenizeString(final String str) throws IOException { + final StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(str)); tokenizer.resetSyntax(); tokenizer.wordChars(0, 255); tokenizer.whitespaceChars(0, ' '); tokenizer.commentChar('#'); tokenizer.quoteChar('"'); tokenizer.quoteChar('\''); - final List cmdList = new ArrayList<>(); + final List tokenList = new ArrayList<>(); final StringBuilder toAppend = new StringBuilder(); while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) { final String s = tokenizer.sval; @@ -265,13 +264,13 @@ // omit trailing \, append space instead toAppend.append(s.substring(0, s.length() - 1)).append(' '); } else { - cmdList.add(toAppend.append(s).toString()); + tokenList.add(toAppend.append(s).toString()); toAppend.setLength(0); } } if (toAppend.length() != 0) { - cmdList.add(toAppend.toString()); + tokenList.add(toAppend.toString()); } - return cmdList; + return tokenList; } } diff -r 4632d53923d4 -r d03088193a17 test/src/jdk/nashorn/internal/test/framework/TestFinder.java --- a/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Tue Jun 02 10:40:10 2015 +0200 +++ b/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Tue Jun 02 10:40:19 2015 +0200 @@ -225,7 +225,7 @@ boolean explicitOptimistic = false; String allContent = new String(Files.readAllBytes(testFile)); - Iterator scanner = ScriptingFunctions.tokenizeCommandLine(allContent).iterator(); + Iterator scanner = ScriptingFunctions.tokenizeString(allContent).iterator(); while (scanner.hasNext()) { // TODO: Scan for /ref=file qualifiers, etc, to determine run // behavior