aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVincent Celier <celier@adacore.com>2008-05-23 15:28:03 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2008-05-23 15:28:03 +0200
commitd3132623b6d9ae24851bfd9c5d053722b4dafbd5 (patch)
treefcb17ea6e426698ed471cf23efd3e52d205ea711 /gcc
parentc2898ec95001c8fa2818dff36e839787c8cf72d8 (diff)
downloadgcc-d3132623b6d9ae24851bfd9c5d053722b4dafbd5.zip
gcc-d3132623b6d9ae24851bfd9c5d053722b4dafbd5.tar.gz
gcc-d3132623b6d9ae24851bfd9c5d053722b4dafbd5.tar.bz2
prj-nmsc.adb (Check_Naming_Schemes): Check a file for spec, body and sep.
2008-05-23 Vincent Celier <celier@adacore.com> * prj-nmsc.adb (Check_Naming_Schemes): Check a file for spec, body and sep. If there are several possibilities, choose the one with the longer prefix. From-SVN: r135803
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/prj-nmsc.adb62
1 files changed, 41 insertions, 21 deletions
diff --git a/gcc/ada/prj-nmsc.adb b/gcc/ada/prj-nmsc.adb
index 01cef31..b443d4f 100644
--- a/gcc/ada/prj-nmsc.adb
+++ b/gcc/ada/prj-nmsc.adb
@@ -6222,12 +6222,12 @@ package body Prj.Nmsc is
String_Element_Table.Increment_Last
(In_Tree.String_Elements);
Element :=
- (Value => Canonical_Path,
+ (Value => Canonical_Path,
Display_Value => Non_Canonical_Path,
- Location => No_Location,
- Flag => False,
- Next => Nil_String,
- Index => 0);
+ Location => No_Location,
+ Flag => False,
+ Next => Nil_String,
+ Index => 0);
-- Case of first source directory
@@ -7943,6 +7943,10 @@ package body Prj.Nmsc is
First_Language : Language_Index;
OK : Boolean;
+ Last_Spec : Natural;
+ Last_Body : Natural;
+ Last_Sep : Natural;
+
begin
Unit := No_Name;
Alternate_Languages := No_Alternate_Language;
@@ -8081,7 +8085,9 @@ package body Prj.Nmsc is
end if;
if OK then
- OK := False;
+ Last_Spec := Natural'Last;
+ Last_Body := Natural'Last;
+ Last_Sep := Natural'Last;
if Config.Naming_Data.Separate_Suffix /= No_File
and then
@@ -8099,16 +8105,12 @@ package body Prj.Nmsc is
(Last - Suffix'Length + 1 .. Last) =
Suffix
then
- Kind := Sep;
- Last := Last - Suffix'Length;
- OK := True;
+ Last_Sep := Last - Suffix'Length;
end if;
end;
end if;
- if not OK
- and then Config.Naming_Data.Body_Suffix /= No_File
- then
+ if Config.Naming_Data.Body_Suffix /= No_File then
declare
Suffix : constant String :=
Get_Name_String
@@ -8120,16 +8122,12 @@ package body Prj.Nmsc is
(Last - Suffix'Length + 1 .. Last) =
Suffix
then
- Kind := Impl;
- Last := Last - Suffix'Length;
- OK := True;
+ Last_Body := Last - Suffix'Length;
end if;
end;
end if;
- if not OK
- and then Config.Naming_Data.Spec_Suffix /= No_File
- then
+ if Config.Naming_Data.Spec_Suffix /= No_File then
declare
Suffix : constant String :=
Get_Name_String
@@ -8141,12 +8139,34 @@ package body Prj.Nmsc is
(Last - Suffix'Length + 1 .. Last) =
Suffix
then
- Kind := Spec;
- Last := Last - Suffix'Length;
- OK := True;
+ Last_Spec := Last - Suffix'Length;
end if;
end;
end if;
+
+ declare
+ Last_Min : constant Natural :=
+ Natural'Min (Natural'Min (Last_Spec,
+ Last_Body),
+ Last_Sep);
+
+ begin
+ OK := Last_Min < Last;
+
+ if OK then
+ Last := Last_Min;
+
+ if Last_Min = Last_Spec then
+ Kind := Spec;
+
+ elsif Last_Min = Last_Body then
+ Kind := Impl;
+
+ else
+ Kind := Sep;
+ end if;
+ end if;
+ end;
end if;
if OK then