aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/osint.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2009-11-30 13:02:49 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2009-11-30 13:02:49 +0100
commit43ccd04be77d9ed7ff4d52fddfc80132639b979a (patch)
treeebc4ad5ed92f287b3b39d8dc7712fcf5e8ff665e /gcc/ada/osint.adb
parent828781519a85aa04c47b5057555938017cec3ae2 (diff)
downloadgcc-43ccd04be77d9ed7ff4d52fddfc80132639b979a.zip
gcc-43ccd04be77d9ed7ff4d52fddfc80132639b979a.tar.gz
gcc-43ccd04be77d9ed7ff4d52fddfc80132639b979a.tar.bz2
[multiple changes]
2009-11-30 Emmanuel Briot <briot@adacore.com> * prj.adb, prj.ads, prj-nmsc.adb (Has_Multi_Unit_Sources): New field in project_data. 2009-11-30 Vincent Celier <celier@adacore.com> * osint.adb (Executable_Name): Correctly decide if the executable suffix should be added when Only_If_No_Suffix is True. 2009-11-30 Robert Dewar <dewar@adacore.com> * frontend.adb, gnatlink.adb, prj-conf.adb, prj-tree.adb, prj-tree.ads: Minor reformatting From-SVN: r154793
Diffstat (limited to 'gcc/ada/osint.adb')
-rw-r--r--gcc/ada/osint.adb86
1 files changed, 50 insertions, 36 deletions
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
index 523852a..1fcff59 100644
--- a/gcc/ada/osint.adb
+++ b/gcc/ada/osint.adb
@@ -813,12 +813,16 @@ package body Osint is
end if;
if Exec_Suffix'Length /= 0 then
- Add_Suffix := not Only_If_No_Suffix;
-
- if not Add_Suffix then
- for J in 1 .. Name_Len loop
+ Add_Suffix := True;
+ if Only_If_No_Suffix then
+ for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
- Add_Suffix := True;
+ Add_Suffix := False;
+ exit;
+
+ elsif Name_Buffer (J) = '/' or else
+ Name_Buffer (J) = Directory_Separator
+ then
exit;
end if;
end loop;
@@ -875,40 +879,50 @@ package body Osint is
Exec_Suffix := new String'(Name_Buffer (1 .. Name_Len));
end if;
- declare
- Suffix : constant String := Exec_Suffix.all;
-
- begin
+ if Exec_Suffix'Length = 0 then
Free (Exec_Suffix);
- Canonical_Case_File_Name (Canonical_Name);
- Add_Suffix := not Only_If_No_Suffix;
+ return Name;
- if not Add_Suffix then
- for J in 1 .. Name_Len loop
- if Name_Buffer (J) = '.' then
- Add_Suffix := True;
- exit;
- end if;
- end loop;
- end if;
+ else
+ declare
+ Suffix : constant String := Exec_Suffix.all;
- if Suffix'Length = 0 and then
- Add_Suffix and then
- (Canonical_Name'Length <= Suffix'Length
- or else Canonical_Name (Canonical_Name'Last - Suffix'Length + 1
- .. Canonical_Name'Last) /= Suffix)
- then
- declare
- Result : String (1 .. Name'Length + Suffix'Length);
- begin
- Result (1 .. Name'Length) := Name;
- Result (Name'Length + 1 .. Result'Last) := Suffix;
- return Result;
- end;
- else
- return Name;
- end if;
- end;
+ begin
+ Free (Exec_Suffix);
+ Canonical_Case_File_Name (Canonical_Name);
+
+ Add_Suffix := True;
+ if Only_If_No_Suffix then
+ for J in reverse 1 .. Name_Len loop
+ if Name_Buffer (J) = '.' then
+ Add_Suffix := False;
+ exit;
+
+ elsif Name_Buffer (J) = '/' or else
+ Name_Buffer (J) = Directory_Separator
+ then
+ exit;
+ end if;
+ end loop;
+ end if;
+
+ if Add_Suffix and then
+ (Canonical_Name'Length <= Suffix'Length
+ or else Canonical_Name (Canonical_Name'Last - Suffix'Length + 1
+ .. Canonical_Name'Last) /= Suffix)
+ then
+ declare
+ Result : String (1 .. Name'Length + Suffix'Length);
+ begin
+ Result (1 .. Name'Length) := Name;
+ Result (Name'Length + 1 .. Result'Last) := Suffix;
+ return Result;
+ end;
+ else
+ return Name;
+ end if;
+ end;
+ end if;
end Executable_Name;
-----------------------