[cp-patches] Patch: FYI: accept short options in long-only mode

Tom Tromey tromey at redhat.com
Sun Jun 18 18:32:46 UTC 2006


I'm checking this in.

When parsing a "long" option, if the option is just a single
character, then we should also check to see if it matches a short
option.

Tom

2006-06-18  Tom Tromey  <tromey at redhat.com>

	* tools/gnu/classpath/tools/getopt/Parser.java (handleLongOption):
	Also handle short options.

Index: tools/gnu/classpath/tools/getopt/Parser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/Parser.java,v
retrieving revision 1.7
diff -u -r1.7 Parser.java
--- tools/gnu/classpath/tools/getopt/Parser.java	15 May 2006 15:56:42 -0000	1.7
+++ tools/gnu/classpath/tools/getopt/Parser.java	18 Jun 2006 18:14:24 -0000
@@ -316,6 +316,9 @@
     int eq = option.indexOf('=');
     if (eq != - 1)
       justName = option.substring(0, eq);
+    char shortName = 0;
+    if (justName.length() == 1)
+      shortName = justName.charAt(0);
     Option found = null;
     for (int i = options.size() - 1; i >= 0; --i)
       {
@@ -325,6 +328,11 @@
             found = opt;
             break;
           }
+        if (shortName != 0 && opt.getShortName() == shortName)
+          {
+            found = opt;
+            break;
+          }
       }
     if (found == null)
       {



More information about the Classpath-patches mailing list