diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-29 08:56:01 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-29 08:56:01 +0000 |
commit | 086161d0e63327d328ff3b96d1707f28ec81c2b7 (patch) | |
tree | cb52e4a743dca38df679be386ba0c94ca39728f9 /gcc/ada/osint.adb | |
parent | 64f7f579ebc1d607b685a456d0732969673cbc39 (diff) | |
download | gcc-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/osint.adb')
-rw-r--r-- | gcc/ada/osint.adb | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index b226802cf07..993ecdf3578 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -1874,8 +1874,10 @@ package body Osint is -- Program_Name -- ------------------ - function Program_Name (Nam : String) return String_Access is - Res : String_Access; + function Program_Name (Nam : String; Prog : String) return String_Access is + End_Of_Prefix : Natural := 0; + Start_Of_Prefix : Positive := 1; + Start_Of_Suffix : Positive; begin -- GNAAMP tool names require special treatment @@ -1907,34 +1909,42 @@ package body Osint is Find_Program_Name; - -- Find the target prefix if any, for the cross compilation case. - -- For instance in "alpha-dec-vxworks-gcc" the target prefix is - -- "alpha-dec-vxworks-" - - while Name_Len > 0 loop + Start_Of_Suffix := Name_Len + 1; - -- All done if we find the last hyphen + -- Find the target prefix if any, for the cross compilation case. + -- For instance in "powerpc-elf-gcc" the target prefix is + -- "powerpc-elf-" + -- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1" - if Name_Buffer (Name_Len) = '-' then + for J in reverse 1 .. Name_Len loop + if Name_Buffer (J) = '/' + or else Name_Buffer (J) = Directory_Separator + or else Name_Buffer (J) = ':' + then + Start_Of_Prefix := J + 1; exit; + end if; + end loop; - -- If directory separator found, we don't want to look further - -- since in this case, no prefix has been found. + -- Find End_Of_Prefix - elsif Is_Directory_Separator (Name_Buffer (Name_Len)) then - Name_Len := 0; + for J in Start_Of_Prefix .. Name_Len - Prog'Length + 1 loop + if Name_Buffer (J .. J + Prog'Length - 1) = Prog then + End_Of_Prefix := J - 1; exit; end if; - - Name_Len := Name_Len - 1; end loop; + if End_Of_Prefix > 1 then + Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1; + end if; + -- Create the new program name - Res := new String (1 .. Name_Len + Nam'Length); - Res.all (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); - Res.all (Name_Len + 1 .. Name_Len + Nam'Length) := Nam; - return Res; + return new String' + (Name_Buffer (Start_Of_Prefix .. End_Of_Prefix) + & Nam + & Name_Buffer (Start_Of_Suffix .. Name_Len)); end Program_Name; ------------------------------ |