From patchwork Thu Apr 11 09:41:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 235655 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9EDA22C00A9 for ; Thu, 11 Apr 2013 19:42:01 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=B9ae5sF7a9RhExCwXvzcysnfoI2RgDqa4d2rfNedpOc76smoBZ L4hbU+Foikuxpk4P3Yz1XWCJB+8fXdqvRLy+XOHJq7VMxwDrO5AarJrfWAMedawR 8hPDSwxyT5qVaDnZxbQjha2PS/PPzzw+VKBOaEwU5vdXVVTTR4hhfoqHY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=/t/TvyD9CRWgRDlBOsTlMVORr9g=; b=hPMYrP3HDQuLDwQ579nZ mv3GPWUD3f67ibOY1fFscxjCGtOtMgO3hGcFIcryN/gBZd+Y+oP0sUC9iig4Grx8 l/fWF1drNUF+LuYvHS7jtFMEqdvOR3drQ2i8NDD+cE/wr6NMjPc0yY9IqdrAPxwk GG/6GaDJUdj8PgNCFLrjpl4= Received: (qmail 13162 invoked by alias); 11 Apr 2013 09:41:55 -0000 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 Received: (qmail 13152 invoked by uid 89); 11 Apr 2013 09:41:54 -0000 X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO, TW_PR autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 11 Apr 2013 09:41:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A633E2E543; Thu, 11 Apr 2013 05:41:52 -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 n-Upz4gdLgl4; Thu, 11 Apr 2013 05:41:52 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8A2FA2E123; Thu, 11 Apr 2013 05:41:52 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 804593FF09; Thu, 11 Apr 2013 05:41:52 -0400 (EDT) Date: Thu, 11 Apr 2013 05:41:52 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] gnatname creates backup copy of project file Message-ID: <20130411094152.GA24010@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Found: No When invoked with an existing project file, gnatname now creates a backup copy of the project file before modifying it, unless it is invoked with the new switch --no-backup. Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-11 Vincent Celier * gnatname.adb (Scan_Args): Recognize new switch --no-backup (Usage): Add line for --no-backup. * opt.ads (No_Nackup): New Boolean variable, initialized to False. * prj-makr.adb (Initialize): Create a backup for an existing project file if gnatname is not invoked with --no-backup. Index: prj-makr.adb =================================================================== --- prj-makr.adb (revision 197743) +++ prj-makr.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -24,6 +24,7 @@ ------------------------------------------------------------------------------ with Csets; +with Hostparm; with Opt; with Output; with Osint; use Osint; @@ -1047,6 +1048,39 @@ Project_File_Extension; Output_Name_Last := Output_Name_Last + Project_File_Extension'Length; + -- Back up project file if it already exists + + if not Hostparm.OpenVMS + and then not Opt.No_Backup + and then + Is_Regular_File (Path_Name (1 .. Path_Last)) + then + declare + Discard : Boolean; + Saved_Path : constant String := + Path_Name (1 .. Path_Last) & ".saved_"; + Nmb : Natural := 0; + begin + loop + declare + Img : constant String := Nmb'Img; + begin + if not Is_Regular_File + (Saved_Path & Img (2 .. Img'Last)) + then + Copy_File + (Name => Path_Name (1 .. Path_Last), + Pathname => Saved_Path & Img (2 .. Img'Last), + Mode => Overwrite, + Success => Discard); + exit; + end if; + + Nmb := Nmb + 1; + end; + end loop; + end; + end if; end if; -- Change the current directory to the directory of the project file, Index: opt.ads =================================================================== --- opt.ads (revision 197743) +++ opt.ads (working copy) @@ -119,14 +119,11 @@ -- Think twice before using "="; Ada_Version >= Ada_2012 is more likely -- what you want, because it will apply to future versions of the language. - Ada_Version_Default : constant Ada_Version_Type := Ada_2005; + Ada_Version_Default : constant Ada_Version_Type := Ada_2012; pragma Warnings (Off, Ada_Version_Default); -- GNAT -- Default Ada version if no switch given. The Warnings off is to kill -- constant condition warnings. - -- - -- WARNING: some scripts rely on the format of this line of code. Any - -- change must be coordinated with the scripts requirements. Ada_Version : Ada_Version_Type := Ada_Version_Default; -- GNAT @@ -986,6 +983,11 @@ -- in this variable (e.g. 2 = select second unit in file). A value of -- zero indicates that we are in normal (one unit per file) mode. + No_Backup : Boolean := False; + -- GNATNAME + -- Set by switch --no-backup. + -- Do not create backup copies of project files. + No_Deletion : Boolean := False; -- GNATPREP -- Set by preprocessor switch -a. Do not eliminate any source text. Implies Index: gnatname.adb =================================================================== --- gnatname.adb (revision 197743) +++ gnatname.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -346,6 +346,11 @@ Subdirs := new String'(Arg (Subdirs_Switch'Length + 1 .. Arg'Last)); + -- --no-backup + + elsif Arg = "--no-backup" then + Opt.No_Backup := True; + -- -c elsif Arg'Length >= 2 and then Arg (1 .. 2) = "-c" then @@ -515,6 +520,7 @@ Display_Usage_Version_And_Help; Write_Line (" --subdirs=dir real obj/lib/exec dirs are subdirs"); + Write_Line (" --no-backup do not create backup of project file"); Write_Eol; Write_Line (" --and use different patterns");