@@ -234,6 +234,9 @@ package body Gnatcheck.Source_Table is
234
234
Duplication_Report : Boolean := True;
235
235
Status : SF_Status := Waiting)
236
236
is
237
+ use GPR2;
238
+ use GPR2.Project.Tree;
239
+
237
240
Old_SF : SF_Id;
238
241
New_SF : SF_Id;
239
242
@@ -242,63 +245,53 @@ package body Gnatcheck.Source_Table is
242
245
First_Idx : Natural;
243
246
Last_Idx : Natural;
244
247
245
- use GPR2;
246
- use GPR2.Project.Tree;
248
+ Root : constant GPR2.Project.View.Object :=
249
+ Arg_Project.Tree.Namespace_Root_Projects.First_Element;
250
+ Res : constant GPR2.Build.Source.Object :=
251
+ Root.View_Db.Visible_Source
252
+ (GPR2.Path_Name.Simple_Name (Filename_Type (Fname)));
247
253
begin
248
254
Free (Full_Source_Name_String);
249
255
Free (Short_Source_Name_String);
250
256
251
- if Arg_Project.Tree.Is_Defined then
252
- declare
253
- Root : constant GPR2.Project.View.Object :=
254
- Arg_Project.Tree.Namespace_Root_Projects.First_Element;
255
- Res : constant GPR2.Build.Source.Object :=
256
- Root.View_Db.Visible_Source
257
- (GPR2.Path_Name.Simple_Name (Filename_Type (Fname)));
258
- begin
259
- if not Res.Is_Defined then
260
- Free (Short_Source_Name_String);
261
- else
262
- Short_Source_Name_String :=
263
- new String'(Res.Path_Name.String_Value);
264
- end if ;
265
- end ;
266
- end if ;
267
-
268
- if Short_Source_Name_String = null then
269
- Warning (Fname & " not found" );
257
+ if not Res.Is_Defined then
258
+ if Is_Regular_File (Fname) then
259
+ Warning (Fname & " is not in the analysed project closure (" &
260
+ String (Arg_Project.Tree.Root_Project.Name) & " )" );
261
+ else
262
+ Warning (Fname & " not found" );
263
+ end if ;
270
264
Missing_File_Detected := True;
271
265
return ;
272
266
else
273
- Full_Source_Name_String := new String'
274
- (Normalize_Pathname
275
- (Short_Source_Name_String.all ,
276
- Resolve_Links => False,
277
- Case_Sensitive => True));
278
-
279
- Free (Short_Source_Name_String);
267
+ Short_Source_Name_String :=
268
+ new String'(Res.Path_Name.String_Value);
280
269
end if ;
281
270
271
+ Full_Source_Name_String := new String'
272
+ (Normalize_Pathname
273
+ (Short_Source_Name_String.all ,
274
+ Resolve_Links => False,
275
+ Case_Sensitive => True));
276
+ Free (Short_Source_Name_String);
277
+
282
278
Short_Source_Name_String := new String'(Base_Name (Fname));
283
279
Hash_Index := Hash (To_Lower (Short_Source_Name_String.all ));
284
280
285
281
-- Check if we already have a file with the same short name:
286
-
287
282
if Present (Hash_Table (Hash_Index)) then
288
283
Old_SF := File_Find (Full_Source_Name_String.all );
289
284
285
+ -- Check if we already stored exactly the same file.
290
286
if Present (Old_SF) then
291
- -- This means that we have already stored exactly the same file.
292
-
293
287
if Duplication_Report then
294
288
Error (Short_Source_Name_String.all & " duplicated" );
295
289
end if ;
296
-
297
290
return ;
298
291
292
+ -- Else, look for files with the same name but with a difference path
299
293
else
300
294
Old_SF := Same_Name_File_Find (Full_Source_Name_String.all );
301
-
302
295
if Present (Old_SF) then
303
296
Error (" more than one version of "
304
297
& Short_Source_Name_String.all & " processed" );
@@ -307,7 +300,6 @@ package body Gnatcheck.Source_Table is
307
300
end if ;
308
301
309
302
-- If we are here, we have to store the file in the table
310
-
311
303
Source_File_Table.Append (New_SF_Record);
312
304
Last_Arg_Source := Source_File_Table.Last;
313
305
New_SF := Last_Arg_Source;
0 commit comments