From: Andrew Cagney <cagney@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Phil Muldoon <pmuldoon@redhat.com>, Frysk Hackers <frysk@sourceware.org>
Subject: Re: Patch: Add Option Groups
Date: Tue, 01 Apr 2008 21:36:00 -0000 [thread overview]
Message-ID: <47F2AABC.9070609@redhat.com> (raw)
In-Reply-To: <m3r6e5s4l7.fsf@fleche.redhat.com>
Thanks!
I've also applied it locally.
Andrew
Tom Tromey wrote:
>>>>>> "Andrew" == Andrew Cagney <cagney@redhat.com> writes:
>>>>>>
>
> [ Parser and OptionGroup ]
> Andrew> I'm not sure if its an interface restriction, or a bug; either way it
> Andrew> leads to a confusing client problem.
>
> I checked in a fix to the Classpath repository.
> I've appended it as well.
>
> Tom
>
> ChangeLog:
> 2008-03-20 Tom Tromey <tromey@redhat.com>
>
> * tools/gnu/classpath/tools/getopt/Parser.java (options): Don't
> initialize.
> (add, addFinal): Don't update options.
> (requireOptions): New method.
> (printHelp): Synchronize. Call requireOptions.
> (parse): Call requireOptions.
>
> Index: tools/gnu/classpath/tools/getopt/Parser.java
> ===================================================================
> RCS file: /cvsroot/classpath/classpath/tools/gnu/classpath/tools/getopt/Parser.java,v
> retrieving revision 1.9
> diff -u -r1.9 Parser.java
> --- tools/gnu/classpath/tools/getopt/Parser.java 22 Sep 2006 01:01:26 -0000 1.9
> +++ tools/gnu/classpath/tools/getopt/Parser.java 20 Mar 2008 18:02:58 -0000
> @@ -1,5 +1,5 @@
> /* Parser.java - parse command line options
> - Copyright (C) 2006 Free Software Foundation, Inc.
> + Copyright (C) 2006, 2008 Free Software Foundation, Inc.
>
> This file is part of GNU Classpath.
>
> @@ -66,7 +66,9 @@
>
> private boolean longOnly;
>
> - private ArrayList options = new ArrayList();
> + // All of the options. This is null initially; users must call
> + // requireOptions before access.
> + private ArrayList options;
>
> private ArrayList optionGroups = new ArrayList();
>
> @@ -218,7 +220,6 @@
> */
> public synchronized void add(Option opt)
> {
> - options.add(opt);
> defaultGroup.add(opt);
> }
>
> @@ -230,7 +231,6 @@
> */
> protected synchronized void addFinal(Option opt)
> {
> - options.add(opt);
> finalGroup.add(opt);
> }
>
> @@ -242,7 +242,6 @@
> */
> public synchronized void add(OptionGroup group)
> {
> - options.addAll(group.options);
> // This ensures that the final group always appears at the end
> // of the options.
> if (optionGroups.isEmpty())
> @@ -251,13 +250,29 @@
> optionGroups.add(optionGroups.size() - 1, group);
> }
>
> + // Make sure the 'options' field is properly initialized.
> + private void requireOptions()
> + {
> + if (options != null)
> + return;
> + options = new ArrayList();
> + Iterator it = optionGroups.iterator();
> + while (it.hasNext())
> + {
> + OptionGroup group = (OptionGroup) it.next();
> + options.addAll(group.options);
> + }
> + }
> +
> public void printHelp()
> {
> this.printHelp(System.out);
> }
>
> - void printHelp(PrintStream out)
> + synchronized void printHelp(PrintStream out)
> {
> + requireOptions();
> +
> if (headerText != null)
> {
> formatText(out, headerText);
> @@ -417,6 +432,7 @@
> */
> public synchronized void parse(String[] inArgs, FileArgumentCallback files)
> {
> + requireOptions();
> try
> {
> args = inArgs;
>
prev parent reply other threads:[~2008-04-01 21:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-18 17:41 Phil Muldoon
2008-03-18 18:28 ` Tom Tromey
2008-03-19 7:51 ` Phil Muldoon
2008-03-19 13:23 ` Tom Tromey
2008-03-18 20:11 ` Andrew Cagney
2008-03-19 7:46 ` Phil Muldoon
2008-03-20 11:52 ` Andrew Cagney
2008-03-20 14:23 ` Tom Tromey
2008-03-20 16:09 ` Andrew Cagney
2008-03-20 18:06 ` Tom Tromey
2008-04-01 21:36 ` Andrew Cagney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47F2AABC.9070609@redhat.com \
--to=cagney@redhat.com \
--cc=frysk@sourceware.org \
--cc=pmuldoon@redhat.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).