public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Johannes Kanig <kanig@adacore.com>
Subject: [Ada] Do not call Callback function when switch is dealt with automatically
Date: Fri, 02 Sep 2011 07:10:00 -0000	[thread overview]
Message-ID: <20110902071030.GA27174@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

This patch modifies the behavior of Getopt in GNAT.Command_Line to not call
the Callback function in argument on switches that have been dealt with
automatically.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-02  Johannes Kanig  <kanig@adacore.com>

	* g-comlin.adb (Getopt): Return when switch is dealt with automatically,
	instead of calling the callback function


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1304 bytes --]

Index: g-comlin.adb
===================================================================
--- g-comlin.adb	(revision 178381)
+++ g-comlin.adb	(working copy)
@@ -3290,11 +3290,14 @@
                           with "Expected integer parameter for '"
                             & Switch & "'";
                   end;
+                  return;
 
                when Switch_String =>
                   Free (Config.Switches (Index).String_Output.all);
                   Config.Switches (Index).String_Output.all :=
                     new String'(Parameter);
+                  return;
+
             end case;
          end if;
 
Index: g-comlin.ads
===================================================================
--- g-comlin.ads	(revision 178381)
+++ g-comlin.ads	(working copy)
@@ -707,7 +707,8 @@
       Callback : Switch_Handler := null;
       Parser   : Opt_Parser := Command_Line_Parser);
    --  Similar to the standard Getopt function.
-   --  For each switch found on the command line, this calls Callback.
+   --  For each switch found on the command line, this calls Callback, if the
+   --  switch is not handled automatically.
    --
    --  The list of valid switches are the ones from the configuration. The
    --  switches that were declared through Define_Switch with an Output

                 reply	other threads:[~2011-09-02  7:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20110902071030.GA27174@adacore.com \
    --to=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kanig@adacore.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).