Commit b2ce8696 authored by yoogx's avatar yoogx

* (Add_File_To_Parse_List): change the semantics of

          Add_Suffix, if Add_Suffix is false, and no .aadl suffix is
          found, then simply discard the name.

          Fix for ticket #20
parent 75b97566
......@@ -52,7 +52,7 @@ package body Ocarina.Files is
procedure Add_File_To_Parse_List
(File_Name : Name_Id;
Add_Suffix : Boolean := True)
Add_Suffix : Boolean)
is
File_Name_With_Extension : Name_Id;
......@@ -60,13 +60,17 @@ package body Ocarina.Files is
begin
Get_Name_String (File_Name);
if Add_Suffix then
if Name_Len < 5
or else Name_Buffer (Name_Len - 4 .. Name_Len) /= ".aadl"
then
if Name_Len < 5
or else Name_Buffer (Name_Len - 4 .. Name_Len) /= ".aadl"
then
if Add_Suffix then
Add_Str_To_Name_Buffer (".aadl");
else
return;
end if;
end if;
File_Name_With_Extension := Name_Find;
for J in 1 .. Sources.Last loop
......
......@@ -51,7 +51,11 @@ package Ocarina.Files is
procedure Add_File_To_Parse_List
(File_Name : Name_Id;
Add_Suffix : Boolean := True);
Add_Suffix : Boolean);
-- Add File_Name to the list of files to be parsed. If Add_Suffix
-- is true, and File_Name does not end with ".aadl", add this
-- suffix. It Add_Suffix is false, and File_Name does not end with
-- ".aadl", simply discard this name.
function Search_File (File_Name : Name_Id) return Name_Id;
......
......@@ -883,7 +883,8 @@ package body Ocarina.FE_AADL.Parser.Namespaces is
while Present (I) loop
if Kind (I) = K_Identifier then
Ocarina.Files.Add_File_To_Parse_List (Name (I));
Ocarina.Files.Add_File_To_Parse_List
(Name (I), Add_Suffix => True);
elsif Kind (I) = K_Package_Name then
declare
J : Node_Id;
......@@ -899,7 +900,8 @@ package body Ocarina.FE_AADL.Parser.Namespaces is
("-" & Get_Name_String (Name (J)));
J := Next_Node (J);
end loop;
Ocarina.Files.Add_File_To_Parse_List (Name_Find);
Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
end if;
end;
end if;
......
......@@ -774,7 +774,8 @@ procedure Ocarina_Cmd is
Add_Str_To_Name_Buffer (File_Name & ".aadl");
end;
Ocarina.Files.Add_File_To_Parse_List (Name_Find);
Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
N := Next_Node (N);
end loop;
......@@ -788,7 +789,8 @@ procedure Ocarina_Cmd is
begin
Get_Name_String (Current_Scenario_Dirname);
Add_Str_To_Name_Buffer (File_Name);
Ocarina.Files.Add_File_To_Parse_List (Name_Find);
Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
N := Next_Node (N);
end;
end loop;
......@@ -963,9 +965,9 @@ procedure Ocarina_Cmd is
if Use_CL then
Set_Str_To_Name_Buffer ("ocarina_components.aadl");
Ocarina.Files.Add_File_To_Parse_List (Name_Find);
Ocarina.Files.Add_File_To_Parse_List (Name_Find, Add_Suffix => True);
Set_Str_To_Name_Buffer ("base_types.aadl");
Ocarina.Files.Add_File_To_Parse_List (Name_Find);
Ocarina.Files.Add_File_To_Parse_List (Name_Find, Add_Suffix => True);
end if;
Extract_Referencial_Files (Ref_Files, Ref_Map);
......@@ -1021,7 +1023,8 @@ procedure Ocarina_Cmd is
for J in Result'Range loop
Set_Str_To_Name_Buffer (Result (J).all);
Ocarina.Files.Add_File_To_Parse_List (Name_Find);
Ocarina.Files.Add_File_To_Parse_List
(Name_Find, Add_Suffix => True);
end loop;
-- Avoid memory leaks
......@@ -1161,16 +1164,9 @@ procedure Ocarina_Cmd is
declare
S : constant String := Full_Switch;
begin
-- FIXME: this is not correct. For instance, an
-- unknown switch may be followed by a parameter.
-- The parameter is considered as a file to parse
-- when it is not. Only sections would fix the
-- issue.
-- If there is a new switch, then the previous
-- files must be discarded.
if S (S'First) = '-' then
-- If there is a new switch, then the previous
-- files are discarded.
Sources.Init;
elsif S (S'First) = '@' then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment