[gps-devel] Debian Bug#666958: gnat-gps: GPS isn't looking in /usr/share/ada/adainclude for installed packages
Emmanuel Briot
briot at adacore.com
Tue Apr 10 14:00:53 CEST 2012
> If you look in the sources, you will see that, without the patch, the
> condition "Project_Path (J) = Project_Path (K)" is always true at least
> once (i.e. when J = K) and therefore Found always becomes True and the
> rest of the loop is never executed. Also, there is a risk that a path
> that appears twice (or more) in the Project_Path array is *never*
> processed. The patch carefully ensures that a duplicated path is
> processed once.
Thanks.
I agree there is a bug there, although I chose a different approach than you
patch (using a Set is more efficient than looping as we did before -- this was
pre-Ada2005 code).
The following patch was applied, which I believe should work.
Emmanuel
--- a/prj_editor/src/creation_wizard-dependencies.adb
+++ b/prj_editor/src/creation_wizard-dependencies.adb
@@ -15,6 +15,7 @@
-- of the license. --
------------------------------------------------------------------------------
+with Ada.Containers.Hashed_Sets;
with Glib; use Glib;
with Gtk.Box; use Gtk.Box;
with Gtk.Button; use Gtk.Button;
@@ -58,6 +59,9 @@ package body Creation_Wizard.Dependencies is
package Wizard_Page_Handlers is new Gtk.Handlers.User_Callback
(Gtk_Widget_Record, Project_Wizard_Page);
+ package File_Sets is
+ new Ada.Containers.Hashed_Sets (Virtual_File, Full_Name_Hash,
+
type Dependency_Project_Page is new Project_Wizard_Page_Record with record
Kernel : Kernel_Handle;
Project : Project_Type;
@@ -270,20 +274,14 @@ package body Creation_Wizard.Dependencies is
Files : File_Array_Access;
Imported_Prj : Project_Type;
Imported : Project_Iterator;
+ Visited : File_Sets.Set;
begin
for J in Project_Path'Range loop
- -- Make sure the path isn't duplicated
- Found := False;
-
- for K in Project_Path'Range loop
- if Project_Path (J) = Project_Path (K) then
- Found := True;
- exit;
- end if;
- end loop;
+ Found := Visited.Contains (Project_Path (J));
if not Found then
+ Visited.Include (Project_Path (J));
begin
Files := Project_Path (J).Read_Dir (Files_Only);
More information about the gps-devel
mailing list