From patchwork Fri Sep 2 07:10:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 113042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4EBCBB6F94 for ; Fri, 2 Sep 2011 17:10:49 +1000 (EST) Received: (qmail 32650 invoked by alias); 2 Sep 2011 07:10:46 -0000 Received: (qmail 32613 invoked by uid 22791); 2 Sep 2011 07:10:44 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Sep 2011 07:10:31 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 818512BB238; Fri, 2 Sep 2011 03:10:30 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id NNmOJEAiEuZl; Fri, 2 Sep 2011 03:10:30 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 6EB442BB191; Fri, 2 Sep 2011 03:10:30 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 693ED3FEE8; Fri, 2 Sep 2011 03:10:30 -0400 (EDT) Date: Fri, 2 Sep 2011 03:10:30 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Johannes Kanig Subject: [Ada] Do not call Callback function when switch is dealt with automatically Message-ID: <20110902071030.GA27174@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * g-comlin.adb (Getopt): Return when switch is dealt with automatically, instead of calling the callback function 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