diff mbox

[Ada] Simplify Get_Target_Prefix in mlib-tgt-specific-xi.adb

Message ID 20111212112906.GA31375@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Dec. 12, 2011, 11:29 a.m. UTC
Avoid hard-coded constants and simply reuse the prefix for ar and ranlib.
No behavioural change.

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

2011-12-12  Tristan Gingold  <gingold@adacore.com>

	* mlib-tgt-specific-xi.adb: (Get_Target_Prefix): Simplify code.
diff mbox

Patch

Index: mlib-tgt-specific-xi.adb
===================================================================
--- mlib-tgt-specific-xi.adb	(revision 182223)
+++ mlib-tgt-specific-xi.adb	(working copy)
@@ -3,11 +3,10 @@ 
 --                         GNAT COMPILER COMPONENTS                         --
 --                                                                          --
 --                     M L I B . T G T. S P E C I F I C                     --
---                           (Bare Board Version)                           --
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2003-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 2003-2011, 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- --
@@ -139,33 +138,11 @@ 
 
    function Get_Target_Prefix return String is
       Target_Name : constant String_Ptr := Sdefault.Target_Name;
-      Index       : Positive            := Target_Name'First;
 
    begin
-      while Index < Target_Name'Last
-        and then Target_Name (Index + 1) /= '-'
-      loop
-         Index := Index + 1;
-      end loop;
+      --  Target_name is the program prefix without '-' but with a trailing '/'
 
-      if Target_Name (Target_Name'First .. Index) = "avr" then
-         return "avr-";
-      elsif Target_Name (Target_Name'First .. Index) = "erc32" then
-         return "erc32-elf-";
-      elsif Target_Name (Target_Name'First .. Index) = "leon" then
-         return "leon-elf-";
-      elsif Target_Name (Target_Name'First .. Index) = "powerpc" then
-         if Target_Name'Length >= 23 and then
-           Target_Name (Target_Name'First .. Target_Name'First + 22) =
-                                              "powerpc-unknown-eabispe"
-         then
-            return "powerpc-eabispe-";
-         else
-            return "powerpc-elf-";
-         end if;
-      else
-         return "";
-      end if;
+      return Target_Name (Target_Name'First .. Target_Name'Last - 1) & '-';
    end Get_Target_Prefix;
 
    --------------------------------------