CVS difference for arm/progs/arm_db.adb

Differences between 1.18 and version 1.19
Log of other versions for file arm/progs/arm_db.adb

--- arm/progs/arm_db.adb	2019/01/28 04:38:34	1.18
+++ arm/progs/arm_db.adb	2022/06/21 06:09:11	1.19
@@ -55,6 +55,9 @@
     -- 10/20/11 - RLB - Added Initial_Version parameter.
     --  3/19/12 - RLB - Added code to suppress indexing of deleted glossary items.
     --  1/27/19 - RLB - Lengthened components to allow Reduce attributes.
+    --  5/25/22 - RLB - Added note strings to Insert for Terms DBs. Implemented
+    --                  Term formatting and output.
+    --  6/ 1/22 - RLB - Redid formatting for terms in the RM.
 
     type String_Ptr is access String;
     type Item is record
@@ -63,6 +66,9 @@
 	Hang : String(1 .. 85);
 	Hang_Len : Natural;
 	Text : String_Ptr;
+	Note1_Text : String_Ptr;
+	Note2_Text : String_Ptr;
+	Note3_Text : String_Ptr;
 	Change_Kind : Paragraph_Change_Kind_Type;
 	Version : Character;
 	Initial_Version : Character;
@@ -101,6 +107,9 @@
 		      Sort_Key : in String;
 		      Hang_Item : in String;
 		      Text : in String;
+                      Note1_Text : in String := "";
+                      Note2_Text : in String := "";
+                      Note3_Text : in String := "";
 		      Change_Kind : in Paragraph_Change_Kind_Type := ARM_Database.None;
 		      Version : in Character := '0';
 		      Initial_Version : in Character := '0') is
@@ -108,9 +117,10 @@
 	-- Sort_Key is the string on which this item will be sorted (if it
 	-- is sorted). Hang_Item is the item which hangs out for the item
 	-- in the report (if any). Text is the text for the item; the text
-	-- may include formatting codes. Change_Kind and Version are the
-	-- revision status for this item. Initial_Version is the version of
-	-- the initial text for this item.
+	-- may include formatting codes. Note1_Text, Note2_Text, and Note3_Text
+        -- are optional note text, these also may include formatting codes.
+        -- Change_Kind and Version are the revision status for this item.
+        -- Initial_Version is the version of the initial text for this item.
 	Temp_Item : Item;
     begin
 	if not Database_Object.Is_Valid then
@@ -139,6 +149,21 @@
 	    -- Note: If this second item doesn't fit, we error so we can make
 	    -- the size larger.
 	Temp_Item.Text := new String'(Text);
+        if Note1_Text /= "" then
+	    Temp_Item.Note1_Text := new String'(Note1_Text);        
+        else
+            Temp_Item.Note1_Text := null;
+        end if;
+        if Note2_Text /= "" then
+	    Temp_Item.Note2_Text := new String'(Note2_Text);        
+        else
+            Temp_Item.Note2_Text := null;
+        end if;
+        if Note3_Text /= "" then
+	    Temp_Item.Note3_Text := new String'(Note3_Text);        
+        else
+            Temp_Item.Note3_Text := null;
+        end if;
 	Temp_Item.Change_Kind := Change_Kind;
 	Temp_Item.Version := Version;
 	Temp_Item.Initial_Version := Initial_Version;
@@ -171,6 +196,7 @@
 	Temp : Item_List;
 
 	function Change_if_Needed (Item : in Item_List) return String is
+            -- Return the @ChgRef command needed for item.
 	begin
 	    -- Note: In the report, we always decide inserted/not inserted
 	    -- as determined by the initial version number, and not the
@@ -223,6 +249,28 @@
 	    end case;
 	end Change_if_Needed;
 
+
+	function Insert_and_Change_if_Needed (Item : in Item_List) return String is
+            -- Return the @ChgRef and @ChgAdded commands needed for item.
+        begin
+            if Temp.Initial_Version = '0' then -- No ChgAdded needed.
+                return Change_if_Needed (Item);
+            else
+                return Change_if_Needed (Item) & "@ChgAdded{Version=[" &
+                   Temp.Initial_Version & "],Text=[";
+            end if;
+        end Insert_and_Change_if_Needed;
+
+	function Close_Insert_and_Change_if_Needed (Item : in Item_List) return String is
+            -- Close the commands generated by Insert_and_Change_if_Needed.
+        begin
+            if Temp.Initial_Version = '0' then -- No ChgAdded needed.
+                return "";
+            else
+                return "]}";
+            end if;
+        end Close_Insert_and_Change_if_Needed;
+
     begin
 	if not Database_Object.Is_Valid then
 	    raise Not_Valid_Error;
@@ -281,6 +329,12 @@
 		    Format_Text (Change_if_Needed (Temp) &
 			Temp.Hang(1..Temp.Hang_Len) & "@\" &
 			Temp.Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                    if Temp.Note1_Text /= null or else
+                       Temp.Note2_Text /= null or else
+                       Temp.Note3_Text /= null then
+                        -- Should not happen.
+                        raise Program_Error with "Notes specified in Hanging_List";
+                    end if;
 		    Temp := Temp.Next;
 		end loop;
 		Format_Text ("@end(description)" & Ascii.LF, "Suffix");
@@ -290,6 +344,14 @@
 		while Temp /= null loop
 		    Format_Text (Change_if_Needed (Temp) &
 		    		 Temp.Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                    if Temp.Note1_Text /= null or else
+                       Temp.Note2_Text /= null or else
+                       Temp.Note3_Text /= null then
+                        -- Should not happen.
+                        raise Program_Error with "Notes specified in Bullet_List";
+                    elsif Temp.Hang_Len /= 0 then
+                        raise Program_Error with "Hang item specified in Bullet_List";
+                    end if;
 		    Temp := Temp.Next;
 		end loop;
 		Format_Text ("@end(itemize)" & Ascii.LF, "Suffix");
@@ -299,6 +361,14 @@
 		while Temp /= null loop
 		    Format_Text (Change_if_Needed (Temp) &
 				 Temp.Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                    if Temp.Note1_Text /= null or else
+                       Temp.Note2_Text /= null or else
+                       Temp.Note3_Text /= null then
+                        -- Should not happen.
+                        raise Program_Error with "Notes specified in Normal_List";
+                    elsif Temp.Hang_Len /= 0 then
+                        raise Program_Error with "Hang item specified in Normal_List";
+                    end if;
 		    Temp := Temp.Next;
 		end loop;
 		Format_Text ("@end(intro)" & Ascii.LF, "Suffix");
@@ -328,9 +398,124 @@
 		            Format_Text (Change_if_Needed (Temp) & Ascii.LF &
 			        Temp.Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
 		    end case;
+                    if Temp.Note1_Text /= null or else
+                       Temp.Note2_Text /= null or else
+                       Temp.Note3_Text /= null then
+                        -- Should not happen.
+                        raise Program_Error with "Notes specified in Normal_Indexed_List";
+                    elsif Temp.Hang_Len /= 0 then
+                        raise Program_Error with "Hang item specified in Normal_Indexed_List";
+                    end if;
 		    Temp := Temp.Next;
 		end loop;
 		Format_Text ("@end(intro)" & Ascii.LF, "Suffix");
+	    when Numbered_T_and_D_List => -- Terms and Definitions list for ISO.
+		Format_Text ("@begin(intro)" & Ascii.LF, "Prefix");
+		Temp := Database_Object.List;
+		while Temp /= null loop
+ 		    Format_Text ("@subnumber" & Ascii.LF & Ascii.LF, "number for " & Temp.Sort_Key);
+                        -- For ISO, these need to be numbered, based on the
+                        -- enclosing subclause number. The subnumber command was
+                        -- added for this purpose.
+                    -- First, the item name:                   
+		    case Temp.Change_Kind is
+			when None |
+			     Inserted | Inserted_Normal_Number |
+			     Revised | Revised_Inserted_Number =>
+--** Debug:
+--Ada.Text_IO.Put_Line("Format " & Change_if_Needed (Temp) &
+--			"@defn{" & Ada.Strings.Fixed.Trim (Temp.Sort_Key, Ada.Strings.Right) & "}");
+			    -- Index this item.
+		            Format_Text (Change_if_Needed (Temp) &
+			        "@defn{" & Ada.Strings.Fixed.Trim (Temp.Sort_Key, Ada.Strings.Right) & "}@b{" & 
+                                Temp.Hang(1..Temp.Hang_Len) & "}" & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+			when Deleted | Deleted_Inserted_Number |
+			     Deleted_No_Delete_Message |
+			     Deleted_Inserted_Number_No_Delete_Message =>
+--** Debug:
+--Ada.Text_IO.Put_Line("Format " & Change_if_Needed (Temp));
+			    -- Don't index deleted items.
+		            Format_Text (Change_if_Needed (Temp) & "@b{" & 
+                                Temp.Hang(1..Temp.Hang_Len) & "}" & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+		    end case;
+                    -- Now, the definition:
+	            Format_Text (Temp.Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                    if Temp.Note1_Text /= null or else
+                       Temp.Note2_Text /= null or else
+                       Temp.Note3_Text /= null then
+		        Format_Text ("@begin{indent}@begin{small}" & Ascii.LF, Temp.Sort_Key & " note prefix" & Ascii.LF);
+                        if Temp.Note1_Text /= null then
+                            Format_Text ("Note 1 to entry: " & Temp.Note1_Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                        end if;
+                        if Temp.Note2_Text /= null then
+                            Format_Text ("Note 2 to entry: " & Temp.Note2_Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                        end if;
+                        if Temp.Note3_Text /= null then
+                            Format_Text ("Note 3 to entry:"  & Temp.Note3_Text.all & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                        end if;
+		        Format_Text ("@end{small}@end{indent}" & Ascii.LF, Temp.Sort_Key & " note suffix" & Ascii.LF);
+                    -- else no notes.
+                    end if;
+	            Format_Text (Ascii.LF & "", Temp.Sort_Key);
+		    Temp := Temp.Next;
+		end loop;
+		Format_Text ("@end(intro)" & Ascii.LF, "Suffix");
+	    when T_and_D_List => -- Terms and Definitions list for RM.
+                -- Format this like hanging text:
+		Format_Text ("@begin(hang1list)" & Ascii.LF, "Prefix");
+		Temp := Database_Object.List;
+		while Temp /= null loop
+                    -- First, the item name and definition:                   
+		    case Temp.Change_Kind is
+			when None |
+			     Inserted | Inserted_Normal_Number |
+			     Revised | Revised_Inserted_Number =>
+--** Debug:
+--Ada.Text_IO.Put_Line("Format " & Change_if_Needed (Temp) &
+--			"@defn{" & Ada.Strings.Fixed.Trim (Temp.Sort_Key, Ada.Strings.Right) & "}");
+			    -- Index this item.
+                            Format_Text (Insert_and_Change_if_Needed (Temp) & 
+                                "@defn{" & Ada.Strings.Fixed.Trim (Temp.Sort_Key, Ada.Strings.Right) & "}@b{" & 
+                                Temp.Hang(1..Temp.Hang_Len) & "}@\" & Temp.Text.all &
+                                Close_Insert_and_Change_if_Needed (Temp) & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+			when Deleted | Deleted_Inserted_Number |
+			     Deleted_No_Delete_Message |
+			     Deleted_Inserted_Number_No_Delete_Message =>
+--** Debug:
+--Ada.Text_IO.Put_Line("Format " & Change_if_Needed (Temp));
+			    -- Don't index deleted items.
+		            Format_Text (Insert_and_Change_if_Needed (Temp) & "@b{" & 
+                                Temp.Hang(1..Temp.Hang_Len) & "}@\" & Temp.Text.all & 
+                                Close_Insert_and_Change_if_Needed (Temp) & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+		    end case;
+                    if Temp.Note1_Text /= null or else
+                       Temp.Note2_Text /= null or else
+                       Temp.Note3_Text /= null then
+		        Format_Text ("@begin{small}@begin{indent}" & Ascii.LF, Temp.Sort_Key & " note prefix" & Ascii.LF);
+                        if Temp.Note1_Text /= null then
+                            if Temp.Note2_Text = null and then Temp.Note3_Text = null then
+                                Format_Text (Insert_and_Change_if_Needed (Temp) & "Note: " & Temp.Note1_Text.all &
+                                             Close_Insert_and_Change_if_Needed (Temp) & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                            else
+                                Format_Text (Insert_and_Change_if_Needed (Temp) & "Note 1: " & Temp.Note1_Text.all &
+                                             Close_Insert_and_Change_if_Needed (Temp) & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                            end if;
+                        end if;
+                        if Temp.Note2_Text /= null then
+                            Format_Text (Insert_and_Change_if_Needed (Temp) & "Note 2: " & Temp.Note2_Text.all &
+                                         Close_Insert_and_Change_if_Needed (Temp) & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                        end if;
+                        if Temp.Note3_Text /= null then
+                            Format_Text (Insert_and_Change_if_Needed (Temp) & "Note 3: " & Temp.Note3_Text.all &
+                                         Close_Insert_and_Change_if_Needed (Temp) & Ascii.LF & Ascii.LF, Temp.Sort_Key);
+                        end if;
+		        Format_Text ("@end{indent}@end{small}" & Ascii.LF, Temp.Sort_Key & " note suffix" & Ascii.LF);
+                    -- else no notes.
+                    end if;
+	            Format_Text (Ascii.LF & "", Temp.Sort_Key);
+		    Temp := Temp.Next;
+		end loop;
+		Format_Text ("@end(hang1list)" & Ascii.LF, "Suffix");
 	end case;
     end Report;
 

Questions? Ask the ACAA Technical Agent