langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
changeset 41635 cb3d04878117
parent 38539 71874886920f
child 42827 36468b5fa7f4
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java	Wed Oct 19 16:58:09 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java	Thu Oct 20 12:53:11 2016 -0700
@@ -30,7 +30,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Stream;
 import static java.util.stream.Collectors.toList;
 
 /**
@@ -78,7 +77,12 @@
         while (true) {
             nextToken();
             if (sval != null && !isQuoted() && sval.startsWith("-")) {
-                foundOption(sval);
+                // allow POSIX getopt() option format,
+                // to be consistent with command-line
+                String opt = sval.startsWith("--")
+                        ? sval.substring(1)
+                        : sval;
+                foundOption(opt);
             } else {
                 break;
             }
@@ -104,28 +108,13 @@
         }
     }
 
-    String[] next(String... strings) {
-        return next(Arrays.stream(strings));
-    }
-
-    String[] next(Stream<String> stream) {
-        next();
-        if (sval == null) {
-            return null;
-        }
-        String[] matches = stream
-                .filter(s -> s.startsWith(sval))
-                .toArray(size -> new String[size]);
-        return matches;
-    }
-
     /**
      * Set the allowed options. Must be called before any options would be read
      * and before calling any of the option functionality below.
      */
     void allowedOptions(String... opts) {
         for (String opt : opts) {
-            options.put(opt, false);
+            options.putIfAbsent(opt, false);
         }
     }