summaryrefslogtreecommitdiff
path: root/gcc/ada/gnatchop.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-29 08:56:01 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-29 08:56:01 +0000
commit086161d0e63327d328ff3b96d1707f28ec81c2b7 (patch)
treecb52e4a743dca38df679be386ba0c94ca39728f9 /gcc/ada/gnatchop.adb
parent64f7f579ebc1d607b685a456d0732969673cbc39 (diff)
downloadgcc-086161d0e63327d328ff3b96d1707f28ec81c2b7.tar.gz
PR ada/864
* osint.ads, osint.adb (Program_Name): New parameter "Prog" to allow recognition of program suffix in addition to prefix. * gnatchop.adb (Locate_Executable): Add support for prefix. * make.adb, gnatcmd.adb, gnatlink.adb, prj-makr.adb, mlib-utl.adb: Adjust calls to Program_Name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136149 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gnatchop.adb')
-rw-r--r--gcc/ada/gnatchop.adb23
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/ada/gnatchop.adb b/gcc/ada/gnatchop.adb
index e7cacadcdd4..766a474afbf 100644
--- a/gcc/ada/gnatchop.adb
+++ b/gcc/ada/gnatchop.adb
@@ -524,13 +524,16 @@ procedure Gnatchop is
(Program_Name : String;
Look_For_Prefix : Boolean := True) return String_Access
is
+ Gnatchop_Str : constant String := "gnatchop";
Current_Command : constant String := Normalize_Pathname (Command_Name);
End_Of_Prefix : Natural;
Start_Of_Prefix : Positive;
+ Start_Of_Suffix : Positive;
Result : String_Access;
begin
Start_Of_Prefix := Current_Command'First;
+ Start_Of_Suffix := Current_Command'Last + 1;
End_Of_Prefix := Start_Of_Prefix - 1;
if Look_For_Prefix then
@@ -549,18 +552,28 @@ procedure Gnatchop is
-- Find End_Of_Prefix
- for J in reverse Start_Of_Prefix .. Current_Command'Last loop
- if Current_Command (J) = '-' then
- End_Of_Prefix := J;
+ for J in Start_Of_Prefix ..
+ Current_Command'Last - Gnatchop_Str'Length + 1
+ loop
+ if Current_Command (J .. J + Gnatchop_Str'Length - 1) =
+ Gnatchop_Str
+ then
+ End_Of_Prefix := J - 1;
exit;
end if;
end loop;
end if;
+ if End_Of_Prefix > Current_Command'First then
+ Start_Of_Suffix := End_Of_Prefix + Gnatchop_Str'Length + 1;
+ end if;
+
declare
Command : constant String :=
- Current_Command (Start_Of_Prefix .. End_Of_Prefix) &
- Program_Name;
+ Current_Command (Start_Of_Prefix .. End_Of_Prefix)
+ & Program_Name
+ & Current_Command (Start_Of_Suffix ..
+ Current_Command'Last);
begin
Result := Locate_Exec_On_Path (Command);