From: Vincent Celier Date: Fri, 23 May 2008 13:28:03 +0000 (+0200) Subject: prj-nmsc.adb (Check_Naming_Schemes): Check a file for spec, body and sep. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d3132623b6d9ae24851bfd9c5d053722b4dafbd5;p=gcc.git prj-nmsc.adb (Check_Naming_Schemes): Check a file for spec, body and sep. 2008-05-23 Vincent Celier * 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 --- diff --git a/gcc/ada/prj-nmsc.adb b/gcc/ada/prj-nmsc.adb index 01cef315b7d..b443d4f590a 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