Hi,

Thank you for applying the gnatdoc.diff patch to
gnat-gps-17.0.2017-1~exp1. Unfortunately, one of the changes was
applied to the wrong line. I guess code duplication in
gnatdoc-frontend.adb confused the patching tool.

Please find attached a fixed gnatdoc.diff.

(Note : I haven't been able yet to rebuild and test the package with
this new patch due to #892148.)

Thanks.

On Sun, 04 Mar 2018 15:06:14 +0000
"Debian Bug Tracking System" <ow...@bugs.debian.org> wrote:

> This is an automatic notification regarding your Bug report
> which was filed against the gnat-gps package:
> 
> #861616: gnat-gps: Inaccuracies in documentation generated by GNATdoc
> 
> It has been closed by Nicolas Boulenguez <nico...@debian.org>.
> 
> Their explanation is attached below along with your original report.
> If this explanation is unsatisfactory and you have not received a
> better one in a separate message then please contact Nicolas
> Boulenguez <nico...@debian.org> by replying to this email.
> 
> 
Description: gnat-gps: Inaccuracies in documentation generated by GNATdoc
 The "not overriding" indicators appear as "overriding" indicators.
 .
 The line numbers shown for the subprogram declarations are wrong (one
 unit too high) if there is an "overriding" or a "not overriding"
 indicator on the previous line. NOT FIXED with gnat-gps 6.1.2016-1.
 .
 When there is a quantified expression in the precondition or
 postcondition of a subprogram, then the documentation for the
 subprogram is not rendered. I guess it's not a new issue but I
 discovered it recently with 6.1.2016-1. I managed to patch the
 frontend.
 .
 The sample code at https://github.com/thierr26/gnatdoc_test
 reproduces the issue.
Bug-Debian: https://bugs.debian.org/861616
Author: Thierry Rascle <thier...@free.fr>

--- a/gnatdoc/src/gnatdoc-backend-html.adb
+++ b/gnatdoc/src/gnatdoc-backend-html.adb
@@ -1059,12 +1059,45 @@
                declare
                   Buffer : aliased String := To_String (Get_Src (E));
                   Code   : JSON_Value;
+                  Line : Positive := LL.Get_Location (E).Line;
+                  Start_Col : Positive;
 
                begin
+                  if Buffer'Length > 0
+                    and then (Get_Kind (E) = E_Procedure
+                    or else Get_Kind (E) = E_Function
+                    or else Get_Kind (E) = E_Entry) then
+                     Start_Col := Buffer'First;
+                     while (Buffer (Start_Col) = ' '
+                       or else Buffer (Start_Col) = ASCII.HT)
+                       and then Start_Col < Buffer'Last loop
+                        Start_Col := Start_Col + 1;
+                     end loop;
+                     if Buffer (Start_Col) /= ' '
+                       and then Buffer (Start_Col) /= ASCII.HT
+                       and then Buffer'Last >= Start_Col + 11
+                       and then (Buffer (Start_Col + 10) = ASCII.LF
+                       or else Buffer (Start_Col + 11) = ASCII.LF) then
+                        if Buffer (Start_Col .. Start_Col + 9)
+                          = "overriding" then
+                           Line := Line - 1;
+                        end if;
+                     end if;
+                     if Buffer (Start_Col) /= ' '
+                       and then Buffer (Start_Col) /= ASCII.HT
+                       and then Buffer'Last >= Start_Col + 15
+                       and then (Buffer (Start_Col + 14) = ASCII.LF
+                       or else Buffer (Start_Col + 15) = ASCII.LF) then
+                        if Buffer (Start_Col .. Start_Col + 13)
+                          = "not overriding" then
+                           Line := Line - 1;
+                        end if;
+                     end if;
+                  end if;
                   Self.Print_Source_Code
                     (Tree.File,
                      Buffer'Unchecked_Access,
-                     LL.Get_Location (E).Line,
+                     Line,
                      Printer,
                      Code);
                   Prepend (Description, Code);
--- a/gnatdoc/src/gnatdoc-frontend.adb
+++ b/gnatdoc/src/gnatdoc-frontend.adb
@@ -63,6 +63,7 @@
       Tok_Is,
       Tok_Limited,
       Tok_New,
+      Tok_Not,
       Tok_Null,
       Tok_Others,
       Tok_Package,
@@ -1636,6 +1637,8 @@
          Cursor                 : Extended_Cursor.Extended_Cursor;
          Last_Idx               : Natural := 0;
          Par_Count              : Natural := 0;
+         Prev_Prev_Token        : Tokens := Tok_Unknown;
+         Prev_Prev_Token_Loc    : Source_Location;
          Prev_Token             : Tokens := Tok_Unknown;
          Prev_Token_Loc         : Source_Location;
          Token                  : Tokens := Tok_Unknown;
@@ -1698,12 +1701,14 @@
          procedure Clear_Parser_State is
             No_Source_Location : constant Source_Location := (0, 0, 0);
          begin
-            Last_Idx       := 0;
-            Par_Count      := 0;
-            Prev_Token     := Tok_Unknown;
-            Prev_Token_Loc := No_Source_Location;
-            Token          := Tok_Unknown;
-            Token_Loc      := No_Source_Location;
+            Last_Idx            := 0;
+            Par_Count           := 0;
+            Prev_Prev_Token     := Tok_Unknown;
+            Prev_Prev_Token_Loc := No_Source_Location;
+            Prev_Token          := Tok_Unknown;
+            Prev_Token_Loc      := No_Source_Location;
+            Token               := Tok_Unknown;
+            Token_Loc           := No_Source_Location;
 
             Nested_Variants_Count  := 0;
             In_Compilation_Unit    := False;
@@ -3832,8 +3837,13 @@
                         Clear_Src;
 
                         if Prev_Token = Tok_Overriding then
-                           Append_Src
-                             ("overriding", Prev_Token_Loc.Column);
+                           if Prev_Prev_Token = Tok_Not then
+                              Append_Src
+                                ("not overriding", Prev_Prev_Token_Loc.Column);
+                           else
+                              Append_Src
+                                ("overriding", Prev_Token_Loc.Column);
+                           end if;
 
                            if Prev_Token_Loc.Line = Sloc_Start.Line then
                               Append_Src (" " & S);
@@ -3964,6 +3974,8 @@
                procedure Update_Prev_Known_Token is
                begin
                   if Token /= Tok_Unknown then
+                     Prev_Prev_Token := Prev_Token;
+                     Prev_Prev_Token_Loc := Prev_Token_Loc;
                      Prev_Token := Token;
                      Prev_Token_Loc := Token_Loc;
                   end if;
@@ -4169,6 +4181,7 @@
                            In_Type_Definition := False;
                            In_Derived_Type_Definition := False;
                         end if;
+                        In_Aspect_Spec := False;
                      end if;
 
                when Normal_Text             |
@@ -4217,7 +4230,7 @@
                Next_Entity : constant Entity_Id :=
                                Extended_Cursor.Entity (Cursor);
             begin
-               if No (Next_Entity) then
+               if In_Aspect_Spec or else No (Next_Entity) then
                   return False;
                end if;
 
@@ -5291,6 +5304,8 @@
                procedure Update_Prev_Known_Token is
                begin
                   if Token /= Tok_Unknown then
+                     Prev_Prev_Token := Prev_Token;
+                     Prev_Prev_Token_Loc := Prev_Token_Loc;
                      Prev_Token := Token;
                      Prev_Token_Loc := Token_Loc;
                   end if;

Reply via email to