I'm checking this in.

This is a getopt refactoring I've wanted to do for a while now.
It:

* Adds support for "joined" short options.  These are one-character
  options whose argument is part of the same string, like "-Ifoo".
  I updated javah's -I option to be joined and I removed some special
  cases for -J.

* Move ClasspathToolParser out of the getopt package.  I think it is
  somewhat useful to use getopt outside of Classpath, and
  ClasspathToolParser is Classpath-specific: it should only really be
  used by tools shipped with Classpath, and it depends on a class
  which is only part of Classpath (this is the only such dependency).
  I updated all users.  As part of this I moved -J from being a
  generic option supported by Parser to being a Classpath-specific
  option.  -J only makes sense if you really do have a tool wrapper
  that strips these, which not all users of getopt do.

I think getopt is now feature complete.  At least, there is nothing
left on my to-do list.

Tom

2006-09-21  Tom Tromey  <[EMAIL PROTECTED]>

        * tools/gnu/classpath/tools/javah/PathOptionGroup.java
        (PathOptionGroup): Make -I a joined option.
        * tools/gnu/classpath/tools/keytool/CACertCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/CertReqCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/DeleteCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/ExportCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/GenKeyCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/IdentityDBCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/ImportCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/KeyCloneCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/ListCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/MainCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/PrintCertCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/SelfCertCmd.java: Updated.
        * tools/gnu/classpath/tools/keytool/StorePasswdCmd.java: Updated.
        * tools/gnu/classpath/tools/appletviewer/Main.java: Updated.
        * tools/gnu/classpath/tools/jar/Main.java: Updated.
        * tools/gnu/classpath/tools/jarsigner/Main.java: Updated.
        * tools/gnu/classpath/tools/javah/Main.java: Updated.
        * tools/gnu/classpath/tools/native2ascii/Main.java: Updated.
        * tools/gnu/classpath/tools/serialver/SerialVer.java: Updated.
        * resource/gnu/classpath/tools/getopt/Messages.properties: Removed
        unused entries.
        * resource/gnu/classpath/tools/common/Messages.properties: New file.
        * tools/gnu/classpath/tools/common/Messages.java: New file.
        * tools/gnu/classpath/tools/getopt/Messages.java: Now package-private.
        * tools/gnu/classpath/tools/common/ClasspathToolParser.java: Moved
        from getopt.
        (ClasspathToolParser): Add -J option here.
        (ClasspathToolParser): Call other constructor in this class.
        * tools/gnu/classpath/tools/getopt/Parser.java (handleLongOption):
        Handle joined options.
        (handleShortOptions): Likewise.
        (handleShortOption): Removed.
        (finalGroup): New field.
        (Parser): Initialize new field.  Don't add -J option.
        (addFinal): New method.
        * tools/gnu/classpath/tools/getopt/OptionGroup.java (printHelp): Use
        isJoined.
        * tools/gnu/classpath/tools/getopt/Option.java (isJoined): New method.
        (Option): Check short option for validity.
        (Option): New constructors.
        (joined): New field.
 
Index: resource/gnu/classpath/tools/getopt/Messages.properties
===================================================================
RCS file: 
/cvsroot/classpath/classpath/resource/gnu/classpath/tools/getopt/Messages.properties,v
retrieving revision 1.2
diff -u -r1.2 Messages.properties
--- resource/gnu/classpath/tools/getopt/Messages.properties     15 May 2006 
17:06:32 -0000      1.2
+++ resource/gnu/classpath/tools/getopt/Messages.properties     22 Sep 2006 
00:49:11 -0000
@@ -38,12 +38,9 @@
 Parser.StdOptions=Standard options
 Parser.PrintHelp=print this help, then exit
 Parser.PrintVersion=print version number, then exit
-Parser.JArgument=pass argument to the Java runtime
-Parser.JName=OPTION
 Parser.ArgReqd=option ''{0}'' requires an argument
 Parser.Unrecognized=unrecognized option ''{0}''
 Parser.NoArg=option ''{0}'' doesn''t allow an argument
 Parser.UnrecDash=unrecognized option ''-{0}''
 Parser.TryHelpShort=Try ''{0} -help'' for more information
 Parser.TryHelpLong=Try ''{0} --help'' for more information
-ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2006 
Free Software Foundation, Inc.\nThis is free software; see the source for 
copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.
Index: tools/gnu/classpath/tools/appletviewer/Main.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/appletviewer/Main.java,v
retrieving revision 1.5
diff -u -r1.5 Main.java
--- tools/gnu/classpath/tools/appletviewer/Main.java    8 Sep 2006 18:31:31 
-0000       1.5
+++ tools/gnu/classpath/tools/appletviewer/Main.java    22 Sep 2006 00:49:15 
-0000
@@ -37,7 +37,7 @@
 
 package gnu.classpath.tools.appletviewer;
 
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
===================================================================
RCS file: tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
diff -N tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
--- tools/gnu/classpath/tools/getopt/ClasspathToolParser.java   15 May 2006 
15:56:42 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-/* ClasspathToolParser.java -- Parser subclass for classpath tools
-   Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.tools.getopt;
-
-import java.text.MessageFormat;
-
-import gnu.classpath.Configuration;
-
-/**
- * This is like the Parser class, but is specialized for use by
- * tools distributed with GNU Classpath.  In particular it automatically
- * computes the version string using the program's name.
- */
-public class ClasspathToolParser
-    extends Parser
-{
-  private static String getVersionString(String programName)
-  {
-    String fmt = (Messages.getString("ClasspathToolParser.VersionFormat")); 
//$NON-NLS-1$
-    return MessageFormat.format(fmt, 
-                                new Object[]
-                                  {
-                                    programName,
-                                    Configuration.CLASSPATH_VERSION
-                                  });
-  }
-
-  public ClasspathToolParser(String programName)
-  {
-    super(programName, getVersionString(programName));
-  }
-
-  public ClasspathToolParser(String programName, boolean longOnly)
-  {
-    super(programName, getVersionString(programName), longOnly);
-  }
-}
Index: tools/gnu/classpath/tools/getopt/Messages.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/Messages.java,v
retrieving revision 1.1
diff -u -r1.1 Messages.java
--- tools/gnu/classpath/tools/getopt/Messages.java      15 May 2006 15:56:42 
-0000      1.1
+++ tools/gnu/classpath/tools/getopt/Messages.java      22 Sep 2006 00:49:15 
-0000
@@ -41,7 +41,7 @@
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-public class Messages
+class Messages
 {
   private static final String BUNDLE_NAME
     = "gnu.classpath.tools.getopt.Messages"; //$NON-NLS-1$
Index: tools/gnu/classpath/tools/getopt/Option.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/Option.java,v
retrieving revision 1.2
diff -u -r1.2 Option.java
--- tools/gnu/classpath/tools/getopt/Option.java        15 May 2006 15:56:42 
-0000      1.2
+++ tools/gnu/classpath/tools/getopt/Option.java        22 Sep 2006 00:49:15 
-0000
@@ -44,7 +44,10 @@
  * like '--verbose'; if the parser is working in "long option only" mode, then 
a
  * long flag has a single dash, like '-verbose'. Both a long and a short form
  * may be specified; it is not valid to have neither. A description is 
mandatory
- * for options; this is used to automatically generate '--help' output.
+ * for options; this is used to automatically generate '--help' output.  An 
option
+ * which takes an argument and which has a short form can also be "joined", in
+ * this case the option's argument can either be separated, like "-I path" or
+ * joined with the short option name, like "-Ipath".
  */
 public abstract class Option
 {
@@ -56,6 +59,8 @@
 
   private String argumentName;
 
+  private boolean joined;
+
   /**
    * Create a new option with the given short name and description.
    * 
@@ -64,6 +69,8 @@
    */
   protected Option(char shortName, String description)
   {
+    if (shortName == 0)
+      throw new IllegalArgumentException("short name must not be \\0");
     this.shortName = shortName;
     this.description = description;
   }
@@ -78,12 +85,34 @@
    */
   protected Option(char shortName, String description, String argumentName)
   {
+    if (shortName == 0)
+      throw new IllegalArgumentException("short name must not be \\0");
     this.shortName = shortName;
     this.description = description;
     this.argumentName = argumentName;
   }
 
   /**
+   * Create a new option with the given short name and description.
+   * 
+   * @param shortName the short name
+   * @param description the description
+   * @param argumentName the descriptive name of the argument, if this option
+   *          takes an argument; otherwise null
+   * @param joined true if the short option is joined to its argument
+   */
+  protected Option(char shortName, String description, String argumentName,
+                   boolean joined)
+  {
+    if (shortName == 0)
+      throw new IllegalArgumentException("short name must not be \\0");
+    this.shortName = shortName;
+    this.description = description;
+    this.argumentName = argumentName;
+    this.joined = joined;
+  }
+
+  /**
    * Create a new option with the given long name and description. The long 
name
    * should be specified without any leading dashes.
    * 
@@ -122,6 +151,8 @@
    */
   protected Option(String longName, char shortName, String description)
   {
+    if (shortName == 0)
+      throw new IllegalArgumentException("short name must not be \\0");
     this.shortName = shortName;
     this.longName = longName;
     this.description = description;
@@ -140,10 +171,35 @@
   protected Option(String longName, char shortName, String description,
                    String argumentName)
   {
+    if (shortName == 0)
+      throw new IllegalArgumentException("short name must not be \\0");
+    this.shortName = shortName;
+    this.longName = longName;
+    this.argumentName = argumentName;
+    this.description = description;
+  }
+
+  /**
+   * Create a new option with the given short and long names and description.
+   * The long name should be specified without any leading dashes.
+   * 
+   * @param longName the long name
+   * @param shortName the short name
+   * @param description the description
+   * @param argumentName the descriptive name of the argument, if this option
+   *          takes an argument; otherwise null
+   * @param joined true if the short option is joined to its argument
+   */
+  protected Option(String longName, char shortName, String description,
+                   String argumentName, boolean joined)
+  {
+    if (shortName == 0)
+      throw new IllegalArgumentException("short name must not be \\0");
     this.shortName = shortName;
     this.longName = longName;
     this.argumentName = argumentName;
     this.description = description;
+    this.joined = joined;
   }
 
   /**
@@ -188,6 +244,16 @@
   }
 
   /**
+   * Return true if this is a "joined" option, false otherwise.
+   * Only the short form of an option can be joined; this will always
+   * return false for an option which does not have a short form.
+   */
+  public boolean isJoined()
+  {
+    return joined;
+  }
+
+  /**
    * This is called by the parser when this option is recognized. It may be
    * called multiple times during a single parse. If this option takes an
    * argument, the argument will be passed in. Otherwise the argument will be
Index: tools/gnu/classpath/tools/getopt/OptionGroup.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java,v
retrieving revision 1.4
diff -u -r1.4 OptionGroup.java
--- tools/gnu/classpath/tools/getopt/OptionGroup.java   10 May 2006 21:00:43 
-0000      1.4
+++ tools/gnu/classpath/tools/getopt/OptionGroup.java   22 Sep 2006 00:49:15 
-0000
@@ -231,10 +231,7 @@
               {
                 if (argName != null)
                   {
-                    // This is a silly hack just for '-J'.  We don't
-                    // support joined options in general, but this option
-                    // is filtered out before argument processing can see it.
-                    if (option.getShortName() != 'J')
+                    if (! option.isJoined())
                       {
                         out.print(' ');
                         ++column;
Index: tools/gnu/classpath/tools/getopt/Parser.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/Parser.java,v
retrieving revision 1.8
diff -u -r1.8 Parser.java
--- tools/gnu/classpath/tools/getopt/Parser.java        18 Jun 2006 18:45:19 
-0000      1.8
+++ tools/gnu/classpath/tools/getopt/Parser.java        22 Sep 2006 00:49:15 
-0000
@@ -72,6 +72,8 @@
 
   private OptionGroup defaultGroup = new OptionGroup();
 
+  private OptionGroup finalGroup;
+
   // These are used while parsing.
   private int currentIndex;
 
@@ -166,7 +168,7 @@
     this.longOnly = longOnly;
 
     // Put standard options in their own section near the end.
-    OptionGroup finalGroup = new 
OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
+    finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); 
//$NON-NLS-1$
     finalGroup.add(new Option("help", Messages.getString("Parser.PrintHelp")) 
//$NON-NLS-1$ //$NON-NLS-2$
     {
       public void parsed(String argument) throws OptionException
@@ -183,15 +185,6 @@
         System.exit(0);
       }
     });
-    finalGroup.add(new Option('J', Messages.getString("Parser.JArgument"), 
Messages.getString("Parser.JName")) //$NON-NLS-1$ //$NON-NLS-2$
-    {
-      public void parsed(String argument) throws OptionException
-      {
-        // -J should be handled by the appletviewer wrapper binary.
-        // We add it here so that it shows up in the --help output.
-        // Note that there is a special case for this in OptionGroup.
-      }
-    });
     add(finalGroup);
 
     add(defaultGroup);
@@ -230,6 +223,18 @@
   }
 
   /**
+   * This is like [EMAIL PROTECTED] #add(Option)}, but adds the option to the 
"final"
+   * group.  This should be used sparingly, if at all; it is intended for
+   * other very generic options like --help or --version.
+   * @param opt the option to add
+   */
+  protected synchronized void addFinal(Option opt)
+  {
+    options.add(opt);
+    finalGroup.add(opt);
+  }
+
+  /**
    * Add an option group to this parser. All the options in this group will be
    * recognized by the parser.
    * 
@@ -314,11 +319,10 @@
     String option = real.substring(index);
     String justName = option;
     int eq = option.indexOf('=');
-    if (eq != - 1)
+    if (eq != -1)
       justName = option.substring(0, eq);
-    char shortName = 0;
-    if (justName.length() == 1)
-      shortName = justName.charAt(0);
+    boolean isPlainShort = justName.length() == 1;
+    char shortName = justName.charAt(0);
     Option found = null;
     for (int i = options.size() - 1; i >= 0; --i)
       {
@@ -328,8 +332,14 @@
             found = opt;
             break;
           }
-        if (shortName != 0 && opt.getShortName() == shortName)
+        if ((isPlainShort || opt.isJoined())
+            && opt.getShortName() == shortName)
           {
+            if (! isPlainShort)
+              {
+                // The rest of the option string is the argument.
+                eq = 0;
+              }
             found = opt;
             break;
           }
@@ -343,7 +353,7 @@
     String argument = null;
     if (found.getTakesArgument())
       {
-        if (eq == - 1)
+        if (eq == -1)
           argument = getArgument(real);
         else
           argument = option.substring(eq + 1);
@@ -358,35 +368,42 @@
     found.parsed(argument);
   }
 
-  private void handleShortOption(char option) throws OptionException
+  private void handleShortOptions(String option) throws OptionException
   {
-    Option found = null;
-    for (int i = options.size() - 1; i >= 0; --i)
+    for (int charIndex = 1; charIndex < option.length(); ++charIndex)
       {
-        Option opt = (Option) options.get(i);
-        if (option == opt.getShortName())
+        char optChar = option.charAt(charIndex);
+        Option found = null;
+        for (int i = options.size() - 1; i >= 0; --i)
           {
-            found = opt;
-            break;
+            Option opt = (Option) options.get(i);
+            if (optChar == opt.getShortName())
+              {
+                found = opt;
+                break;
+              }
           }
-      }
-    if (found == null)
-      {
-        String msg = 
MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
-                                          new Object[] { "" + option }); 
//$NON-NLS-1$
-        throw new OptionException(msg);
-      }
-    String argument = null;
-    if (found.getTakesArgument())
-      argument = getArgument("-" + option); //$NON-NLS-1$
-    found.parsed(argument);
-  }
-
-  private void handleShortOptions(String option) throws OptionException
-  {
-    for (int i = 1; i < option.length(); ++i)
-      {
-        handleShortOption(option.charAt(i));
+        if (found == null)
+          {
+            String msg = 
MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
+                                              new Object[] { "" + optChar }); 
//$NON-NLS-1$
+            throw new OptionException(msg);
+          }
+        String argument = null;
+        if (found.getTakesArgument())
+          {
+            // If this is a joined short option, and there are more
+            // characters left in this argument, use those as the
+            // argument.
+            if (found.isJoined() && charIndex + 1 < option.length())
+              {
+                argument = option.substring(charIndex + 1);
+                charIndex = option.length();
+              }
+            else
+              argument = getArgument("-" + optChar); //$NON-NLS-1$
+          }
+        found.parsed(argument);
       }
   }
 
Index: tools/gnu/classpath/tools/jar/Main.java
===================================================================
RCS file: /cvsroot/classpath/classpath/tools/gnu/classpath/tools/jar/Main.java,v
retrieving revision 1.6
diff -u -r1.6 Main.java
--- tools/gnu/classpath/tools/jar/Main.java     15 May 2006 16:23:47 -0000      
1.6
+++ tools/gnu/classpath/tools/jar/Main.java     22 Sep 2006 00:49:15 -0000
@@ -38,7 +38,7 @@
 
 package gnu.classpath.tools.jar;
 
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.FileArgumentCallback;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
Index: tools/gnu/classpath/tools/jarsigner/Main.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/jarsigner/Main.java,v
retrieving revision 1.13
diff -u -r1.13 Main.java
--- tools/gnu/classpath/tools/jarsigner/Main.java       12 Jun 2006 05:14:06 
-0000      1.13
+++ tools/gnu/classpath/tools/jarsigner/Main.java       22 Sep 2006 00:49:15 
-0000
@@ -41,8 +41,8 @@
 import gnu.classpath.Configuration;
 import gnu.classpath.SystemProperties;
 import gnu.classpath.tools.common.CallbackUtil;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.common.ProviderUtil;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
 import gnu.classpath.tools.getopt.FileArgumentCallback;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
Index: tools/gnu/classpath/tools/javah/Main.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/Main.java,v
retrieving revision 1.2
diff -u -r1.2 Main.java
--- tools/gnu/classpath/tools/javah/Main.java   9 Aug 2006 16:35:43 -0000       
1.2
+++ tools/gnu/classpath/tools/javah/Main.java   22 Sep 2006 00:49:15 -0000
@@ -38,7 +38,7 @@
 
 package gnu.classpath.tools.javah;
 
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.Parser;
Index: tools/gnu/classpath/tools/javah/PathOptionGroup.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/javah/PathOptionGroup.java,v
retrieving revision 1.1
diff -u -r1.1 PathOptionGroup.java
--- tools/gnu/classpath/tools/javah/PathOptionGroup.java        28 Jul 2006 
15:22:29 -0000      1.1
+++ tools/gnu/classpath/tools/javah/PathOptionGroup.java        22 Sep 2006 
00:49:15 -0000
@@ -96,7 +96,7 @@
         setPath(classpath, path);
       }
     });
-    add(new Option('I', "Add directory to class path", "DIR")
+    add(new Option('I', "Add directory to class path", "DIR", true)
     {
       public void parsed(String path) throws OptionException
       {
Index: tools/gnu/classpath/tools/keytool/CACertCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java,v
retrieving revision 1.2
diff -u -r1.2 CACertCmd.java
--- tools/gnu/classpath/tools/keytool/CACertCmd.java    12 Jun 2006 05:14:07 
-0000      1.2
+++ tools/gnu/classpath/tools/keytool/CACertCmd.java    22 Sep 2006 00:49:15 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/CertReqCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java,v
retrieving revision 1.5
diff -u -r1.5 CertReqCmd.java
--- tools/gnu/classpath/tools/keytool/CertReqCmd.java   12 Jun 2006 05:14:07 
-0000      1.5
+++ tools/gnu/classpath/tools/keytool/CertReqCmd.java   22 Sep 2006 00:49:15 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/DeleteCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java,v
retrieving revision 1.5
diff -u -r1.5 DeleteCmd.java
--- tools/gnu/classpath/tools/keytool/DeleteCmd.java    12 Jun 2006 05:14:07 
-0000      1.5
+++ tools/gnu/classpath/tools/keytool/DeleteCmd.java    22 Sep 2006 00:49:15 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/ExportCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java,v
retrieving revision 1.6
diff -u -r1.6 ExportCmd.java
--- tools/gnu/classpath/tools/keytool/ExportCmd.java    12 Jun 2006 05:14:07 
-0000      1.6
+++ tools/gnu/classpath/tools/keytool/ExportCmd.java    22 Sep 2006 00:49:16 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/GenKeyCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java,v
retrieving revision 1.7
diff -u -r1.7 GenKeyCmd.java
--- tools/gnu/classpath/tools/keytool/GenKeyCmd.java    28 Jul 2006 19:50:08 
-0000      1.7
+++ tools/gnu/classpath/tools/keytool/GenKeyCmd.java    22 Sep 2006 00:49:16 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java,v
retrieving revision 1.6
diff -u -r1.6 IdentityDBCmd.java
--- tools/gnu/classpath/tools/keytool/IdentityDBCmd.java        16 Jul 2006 
05:55:59 -0000      1.6
+++ tools/gnu/classpath/tools/keytool/IdentityDBCmd.java        22 Sep 2006 
00:49:16 -0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/ImportCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java,v
retrieving revision 1.8
diff -u -r1.8 ImportCmd.java
--- tools/gnu/classpath/tools/keytool/ImportCmd.java    28 Jul 2006 19:50:08 
-0000      1.8
+++ tools/gnu/classpath/tools/keytool/ImportCmd.java    22 Sep 2006 00:49:16 
-0000
@@ -40,7 +40,7 @@
 
 import gnu.classpath.Configuration;
 import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java,v
retrieving revision 1.5
diff -u -r1.5 KeyCloneCmd.java
--- tools/gnu/classpath/tools/keytool/KeyCloneCmd.java  12 Jun 2006 05:14:07 
-0000      1.5
+++ tools/gnu/classpath/tools/keytool/KeyCloneCmd.java  22 Sep 2006 00:49:16 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java,v
retrieving revision 1.5
diff -u -r1.5 KeyPasswdCmd.java
--- tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java 12 Jun 2006 05:14:07 
-0000      1.5
+++ tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java 22 Sep 2006 00:49:16 
-0000
@@ -40,7 +40,7 @@
 
 import gnu.classpath.Configuration;
 import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/ListCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java,v
retrieving revision 1.5
diff -u -r1.5 ListCmd.java
--- tools/gnu/classpath/tools/keytool/ListCmd.java      12 Jun 2006 05:14:07 
-0000      1.5
+++ tools/gnu/classpath/tools/keytool/ListCmd.java      22 Sep 2006 00:49:16 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/Main.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/Main.java,v
retrieving revision 1.5
diff -u -r1.5 Main.java
--- tools/gnu/classpath/tools/keytool/Main.java 28 Jul 2006 19:50:08 -0000      
1.5
+++ tools/gnu/classpath/tools/keytool/Main.java 22 Sep 2006 00:49:16 -0000
@@ -39,8 +39,8 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.common.ProviderUtil;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/PrintCertCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java,v
retrieving revision 1.3
diff -u -r1.3 PrintCertCmd.java
--- tools/gnu/classpath/tools/keytool/PrintCertCmd.java 12 Jun 2006 05:14:07 
-0000      1.3
+++ tools/gnu/classpath/tools/keytool/PrintCertCmd.java 22 Sep 2006 00:49:16 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/SelfCertCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java,v
retrieving revision 1.5
diff -u -r1.5 SelfCertCmd.java
--- tools/gnu/classpath/tools/keytool/SelfCertCmd.java  12 Jun 2006 05:14:07 
-0000      1.5
+++ tools/gnu/classpath/tools/keytool/SelfCertCmd.java  22 Sep 2006 00:49:16 
-0000
@@ -39,7 +39,7 @@
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java,v
retrieving revision 1.5
diff -u -r1.5 StorePasswdCmd.java
--- tools/gnu/classpath/tools/keytool/StorePasswdCmd.java       12 Jun 2006 
05:14:07 -0000      1.5
+++ tools/gnu/classpath/tools/keytool/StorePasswdCmd.java       22 Sep 2006 
00:49:16 -0000
@@ -40,7 +40,7 @@
 
 import gnu.classpath.Configuration;
 import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.OptionGroup;
Index: tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java,v
retrieving revision 1.2
diff -u -r1.2 Native2ASCII.java
--- tools/gnu/classpath/tools/native2ascii/Native2ASCII.java    20 May 2006 
22:10:31 -0000      1.2
+++ tools/gnu/classpath/tools/native2ascii/Native2ASCII.java    22 Sep 2006 
00:49:16 -0000
@@ -38,7 +38,7 @@
 
 package gnu.classpath.tools.native2ascii;
 
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.FileArgumentCallback;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
Index: tools/gnu/classpath/tools/serialver/SerialVer.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java,v
retrieving revision 1.2
diff -u -r1.2 SerialVer.java
--- tools/gnu/classpath/tools/serialver/SerialVer.java  22 May 2006 15:53:47 
-0000      1.2
+++ tools/gnu/classpath/tools/serialver/SerialVer.java  22 Sep 2006 00:49:16 
-0000
@@ -21,7 +21,7 @@
 
 package gnu.classpath.tools.serialver;
 
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
 import gnu.classpath.tools.getopt.FileArgumentCallback;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
Index: resource/gnu/classpath/tools/common/Messages.properties
===================================================================
RCS file: resource/gnu/classpath/tools/common/Messages.properties
diff -N resource/gnu/classpath/tools/common/Messages.properties
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ resource/gnu/classpath/tools/common/Messages.properties     1 Jan 1970 
00:00:00 -0000
@@ -0,0 +1,40 @@
+# MessagesBundle.properties -- English language messages
+# Copyright (C) 2006  Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING.  If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library.  Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module.  An independent module is a module which is not derived from
+# or based on this library.  If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so.  If you do not wish to do so, delete this
+# exception statement from your version.
+
+ClasspathToolParser.JArgument=pass argument to the Java runtime
+ClasspathToolParser.JName=OPTION
+ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2006 
Free Software Foundation, Inc.\nThis is free software; see the source for 
copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.
Index: tools/gnu/classpath/tools/common/ClasspathToolParser.java
===================================================================
RCS file: tools/gnu/classpath/tools/common/ClasspathToolParser.java
diff -N tools/gnu/classpath/tools/common/ClasspathToolParser.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/common/ClasspathToolParser.java   1 Jan 1970 
00:00:00 -0000
@@ -0,0 +1,87 @@
+/* ClasspathToolParser.java -- Parser subclass for classpath tools
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.text.MessageFormat;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+/**
+ * This is like the Parser class, but is specialized for use by
+ * tools distributed with GNU Classpath.  In particular it automatically
+ * computes the version string using the program's name.
+ */
+public class ClasspathToolParser
+    extends Parser
+{
+  private static String getVersionString(String programName)
+  {
+    String fmt = (Messages.getString("ClasspathToolParser.VersionFormat")); 
//$NON-NLS-1$
+    return MessageFormat.format(fmt, 
+                                new Object[]
+                                  {
+                                    programName,
+                                    Configuration.CLASSPATH_VERSION
+                                  });
+  }
+
+  public ClasspathToolParser(String programName)
+  {
+    this(programName, false);
+  }
+
+  public ClasspathToolParser(String programName, boolean longOnly)
+  {
+    super(programName, getVersionString(programName), longOnly);
+    addFinal(new Option('J',
+                        
Messages.getString("ClasspathToolParser.JArgument"),//$NON-NLS-1$
+                        Messages.getString("ClasspathToolParser.JName"), 
//$NON-NLS-1$
+                        true)
+             {
+               public void parsed(String argument) throws OptionException
+               {
+                 // -J should be handled by the wrapper binary.
+                 // We add it here so that it shows up in the --help output.
+               }
+             });
+  }
+}
Index: tools/gnu/classpath/tools/common/Messages.java
===================================================================
RCS file: tools/gnu/classpath/tools/common/Messages.java
diff -N tools/gnu/classpath/tools/common/Messages.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tools/gnu/classpath/tools/common/Messages.java      1 Jan 1970 00:00:00 
-0000
@@ -0,0 +1,67 @@
+/* Messages.java -- i18n support for tools common code
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library.  Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module.  An independent module is a module which is not derived from
+ or based on this library.  If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so.  If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class Messages
+{
+  private static final String BUNDLE_NAME
+    = "gnu.classpath.tools.common.Messages"; //$NON-NLS-1$
+
+  private static final ResourceBundle RESOURCE_BUNDLE
+    = ResourceBundle.getBundle(BUNDLE_NAME);
+
+  private Messages()
+  {
+  }
+
+  public static String getString(String key)
+  {
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return '!' + key + '!';
+      }
+  }
+}

Reply via email to