Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utils.Drivers: fix Counter decrement for ignored files #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kilian-gebhardt
Copy link

Fix #25.

@JonDeMartini
Copy link

Still running into this issue. I debugged it before I saw this PR and came to a similar conclusion. I'm not sure I like your solution because it might not take into account the path through the first loop in Process_Files if Tool.Run_First_Pass is set. That would reset Counter := N_File_Names, and not take into account the ignored files for the second loop.

I had a slightly different approach contained to Process_Files. I count the number of Ignored filed by getting the length of the Ignored String_Set. Then before each loop I set Counter := N_File_Names - Ignored_Count:

` procedure Process_Files is
N_File_Names : constant Natural := Num_File_Names (Cmd);

     Ignored_Count  : Natural := 0;
     Counter        : Natural;
     Has_Syntax_Err : Boolean := False;

     use Directories;
  begin
     --  First compute the Ignored set by looking at all the --ignored
     --  switches.

     for Ignored_Arg of Arg (Cmd, Ignore) loop
        Read_File_Names_From_File (Ignored_Arg.all, Include_One'Access);
     end loop;
     Ignored_Count := Natural (String_Sets.Length (Ignored));
     Counter       := N_File_Names - Ignored_Count;
     if Tool.Run_First_Pass then
        if Arg (Cmd, Verbose) then
           Err_Out.Put ("First pass:\n");
        end if;
        for F_Name of File_Names (Cmd) loop
           if not Contains (Ignored, Simple_Name (F_Name.all)) then
              if Arg (Cmd, Verbose) then
                 Err_Out.Put ("[\1] \2\n", Image (Counter), F_Name.all);
              end if;

              Counter        := Counter - 1;
              Has_Syntax_Err := False;
              Process_File
                (Tool, Cmd, F_Name.all, Counter, Has_Syntax_Err,
                 Pass => First_Pass);
              if Has_Syntax_Err and then not Utils.Syntax_Errors then
                 Utils.Syntax_Errors := True;
              end if;
           end if;
        end loop;

        pragma Assert (Counter = 0);
        Tool.First_Pass_Post_Process (Cmd);
        Counter := N_File_Names - Ignored_Count;
        if Arg (Cmd, Verbose) then
           Err_Out.Put ("Second pass:\n");
        end if;
     end if;
     for F_Name of File_Names (Cmd) loop
        if not Contains (Ignored, Simple_Name (F_Name.all)) then
           if Arg (Cmd, Verbose) then
              Err_Out.Put ("[\1] \2\n", Image (Counter), F_Name.all);
           elsif not Arg (Cmd, Quiet) and then N_File_Names > 1 then
              Err_Out.Put ("Units remaining: \1     \r", Image (Counter));
           end if;

           Counter        := Counter - 1;
           Has_Syntax_Err := False;
           Process_File
             (Tool, Cmd, F_Name.all, Counter, Has_Syntax_Err,
              Pass => Second_Pass);
           if Has_Syntax_Err and then not Utils.Syntax_Errors then
              Utils.Syntax_Errors := True;
           end if;
        end if;

     end loop;
     pragma Assert (Counter = 0);
  end Process_Files;

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gnattest: Utils.Drivers.Driver.Process_Files: logic bug with ignored switch
2 participants