CVS difference for arm/progs/arm_frm.adb

Differences between 1.40 and version 1.41
Log of other versions for file arm/progs/arm_frm.adb

--- arm/progs/arm_frm.adb	2006/02/16 06:47:59	1.40
+++ arm/progs/arm_frm.adb	2006/02/19 06:44:40	1.41
@@ -208,6 +208,11 @@
     --		- RLB - Added the picture command.
     --	2/15/06 - RLB - Added code to prevent the generation of note numbers
     --			for deleted notes in final documents.
+    --  2/17/06 - RLB - Tracked down issues with @ChgImplDef.
+    --		- RLB - Added code so that index entries don't display soft
+    --			hyphens.
+    --		- RLB - Fixed glossary entries to not display insertions if
+    --			the mode would prevent that.
 
     type Command_Kind_Type is (Normal, Begin_Word, Parameter);
 
@@ -1214,6 +1219,18 @@
     end Make_References;
 
 
+    procedure Dump_References (List : in out Reference_Ptr) is
+	-- Destroy any references in List; List will be null afterwards.
+	Temp : Reference_Ptr;
+    begin
+	while List /= null loop
+	    Temp := List;
+	    List := List.Next;
+	    Free_Reference (Temp);
+	end loop;
+    end Dump_References;
+
+
     type Items is record
         Kind : Command_Kind_Type;
         Name : ARM_Input.Command_Name_Type;
@@ -2534,7 +2551,13 @@
 		    -- them on *this* paragraph. Thus, we just output them if
 		    -- they exist here. Note: This deallocates the references
 		    -- after writing them.
-		    Make_References (Format_Object.References, Format_Object, Output_Object);
+		    if Format_Object.No_Start_Paragraph then
+			-- Oh-oh! Can't generate references; there aren't
+			-- supposed to be any at this point.
+		        Ada.Text_IO.Put_Line ("** References generated for no display paragraph; line " & ARM_Input.Line_String (Input_Object));
+		    else
+			Make_References (Format_Object.References, Format_Object, Output_Object);
+		    end if;
 		end if;
 
 		-- Reset the "next" paragraph kind and version (we have to
@@ -2607,7 +2630,7 @@
 		       Added_Version => Format_Object.Current_Old_Change_Version,
 		       Location => ARM_Output.Normal);
 		end if;
-	        ARM_Output.Ordinary_Text (Output_Object, ARM_Index.Clean(Term_Text));
+	        ARM_Output.Ordinary_Text (Output_Object, ARM_Index.Clean(Term_Text, Remove_Soft_Hyphens => True));
 		if not Is_AARM then
 	            ARM_Output.Text_Format (Output_Object,
 		       Bold => False, Italic => False, Font => ARM_Output.Default,
@@ -2714,7 +2737,7 @@
 	end Parse_Tab_Stops;
 
 
-	Do_Not_Display_Text : ARM_Output.Change_Type := ARM_Output.Both;
+	Do_Not_Display_Text : constant ARM_Output.Change_Type := ARM_Output.Both;
 	    -- Special meaning for Calc_Change_Disposition, below.
 	procedure Calc_Change_Disposition
 		    (Version : in ARM_Contents.Change_Version_Type;
@@ -2730,9 +2753,8 @@
 	    -- If Text_Kind is Do_Not_Display_Text (same as Both), the
 	    --   text should not be shown at all.
 	    -- Program_Error is raised if Operation is None or Both.
-	    -- This routine assumes (and checks) that we are not nested
-	    -- in some other change item; Program_Error is raised if
-	    -- we are.
+	    -- This routine assumes that we are not nested
+	    -- in some other change item.
 	    use type ARM_Output.Change_Type;
 	begin
 	    if Operation = ARM_Output.None or else
@@ -3748,6 +3770,8 @@
 	        Version : ARM_Contents.Change_Version_Type;
 	        Display_It : Boolean;
 		use type ARM_Database.Paragraph_Change_Kind_Type;
+		Local_Change : ARM_Output.Change_Type;
+		Skip_Header : Boolean := False;
 	    begin
 	        Get_Change_Version (Is_First => True,
 		    Version => Version);
@@ -3756,27 +3780,71 @@
 	        Get_Change_Kind (Kind);
 		    -- Read a parameter named "Kind".
 
-	        if Format_Object.Changes = ARM_Format.Old_Only and then
-		    Version > '0' then
-		    -- Old only, don't display it (and it won't be
-		    -- inserted, either).
-		    Display_It := False;
-	        elsif (Format_Object.Impdef_Change_Kind = ARM_Database.Inserted or else
-		       Format_Object.Impdef_Change_Kind = ARM_Database.Inserted_Normal_Number) then
-		    if Version <= Format_Object.Change_Version then
-		        Format_Object.Impdef_Version := Version;
-		        Format_Object.Impdef_Change_Kind := Kind;
-		        Display_It := Format_Object.Include_Annotations;
-			    -- Show impdef notes only if we're showing annotations.
-		    else --This reference is too new, ignore it.
-		        Display_It := False;
-		    end if;
+--Ada.Text_IO.Put_Line ("Gen_Chg_xxxx, Kind=" &
+--ARM_Database.Paragraph_Change_Kind_Type'Image(Kind) &
+--"; version=" & Version);
+
+	        if (Kind = ARM_Database.Inserted or else
+		    Kind = ARM_Database.Inserted_Normal_Number) then
+		    Calc_Change_Disposition
+		        (Version => Version,
+			 Operation => ARM_Output.Insertion,
+			 Text_Kind => Local_Change);
+--Ada.Text_IO.Put_Line ("  Insert, Local_Change=" &
+--ARM_Output.Change_Type'Image(Local_Change));
+		    case Local_Change is
+		        when Do_Not_Display_Text =>
+		            Display_It := False;
+			    Local_Change := ARM_Output.None;
+		        when ARM_Output.None|ARM_Output.Insertion =>
+		            Format_Object.Impdef_Version := Version;
+		            Format_Object.Impdef_Change_Kind := Kind;
+		            Display_It := Format_Object.Include_Annotations;
+			        -- Show impdef notes only if we're showing annotations.
+		        when ARM_Output.Deletion =>
+			    raise Program_Error;
+		    end case;
+		elsif Kind = ARM_Database.Deleted or else
+		      Kind = ARM_Database.Deleted_Inserted_Number or else
+		      Kind = ARM_Database.Deleted_No_Delete_Message or else
+		      Kind = ARM_Database.Deleted_Inserted_Number_No_Delete_Message then
+		    Calc_Change_Disposition
+		        (Version => Version,
+			 Operation => ARM_Output.Deletion,
+			 Text_Kind => Local_Change);
+--Ada.Text_IO.Put_Line ("  Delete, Local_Change=" &
+--ARM_Output.Change_Type'Image(Local_Change));
+		    case Local_Change is
+		        when Do_Not_Display_Text =>
+		            --Display_It := False;
+			    -- We need to show the paragraph, without its header,
+			    -- so that we get a proper "this paragraph is deleted"
+			    -- message (if one is needed). Nothing will actually
+			    -- be output in this case.
+			    Local_Change := ARM_Output.None;
+			    Skip_Header := True;
+		            Format_Object.Impdef_Version := Version;
+		            Format_Object.Impdef_Change_Kind := Kind;
+		            Display_It := Format_Object.Include_Annotations;
+			        -- Show impdef notes only if we're showing annotations.
+		        when ARM_Output.None | ARM_Output.Deletion =>
+		            Format_Object.Impdef_Version := Version;
+		            Format_Object.Impdef_Change_Kind := Kind;
+		            Display_It := Format_Object.Include_Annotations;
+			        -- Show impdef notes only if we're showing annotations.
+			    Skip_Header := False;
+		        when ARM_Output.Insertion =>
+			    raise Program_Error;
+		    end case;
 	        else -- we always display it.
+--Ada.Text_IO.Put_Line ("  Other");
 		    Format_Object.Impdef_Version := Version;
 		    Format_Object.Impdef_Change_Kind := Kind;
 		    Display_It := Format_Object.Include_Annotations;
 		        -- Show impdef notes only if we're showing annotations.
+		    Local_Change := ARM_Output.None;
 	        end if;
+--Ada.Text_IO.Put_Line ("  Display_It=" & Boolean'Image(Display_It));
 
 	        ARM_Input.Check_Parameter_Name (Input_Object,
 		    Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
@@ -3820,39 +3888,38 @@
 		        Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
 		        Check_Paragraph;
 
-		        if (Format_Object.Impdef_Change_Kind = ARM_Database.Inserted or else
-			    Format_Object.Impdef_Change_Kind = ARM_Database.Inserted_Normal_Number) and then
-            		    Format_Object.Impdef_Version <= Format_Object.Change_Version and then
-			    Format_Object.Changes /= ARM_Format.New_Only then
-			    ARM_Output.Text_Format (Output_Object,
-			        Bold => True,
-			        Italic => Format_Object.Is_Italic,
-			        Font => Format_Object.Font,
-			        Size => Format_Object.Size,
-			        Change => ARM_Output.Insertion,
-			        Version => Format_Object.Impdef_Version,
-			        Location => Format_Object.Location);
-		        else -- It's revised, or New_Only; no change markers needed. (If we don't
-			    -- want to display it at all, we didn't get here.
-			    ARM_Output.Text_Format (Output_Object,
-			        Bold => True,
+			if not Skip_Header then
+		            if ARM_Output."/=" (Local_Change, ARM_Output.None) then
+			        ARM_Output.Text_Format (Output_Object,
+			            Bold => True,
+			            Italic => Format_Object.Is_Italic,
+			            Font => Format_Object.Font,
+			            Size => Format_Object.Size,
+			            Change => Local_Change,
+			            Version => Format_Object.Impdef_Version,
+			            Location => Format_Object.Location);
+		            else -- No change from us:
+			        ARM_Output.Text_Format (Output_Object,
+			            Bold => True,
+			            Italic => Format_Object.Is_Italic,
+			            Font => Format_Object.Font,
+			            Size => Format_Object.Size,
+			            Change => Format_Object.Change,
+			            Version => Format_Object.Impdef_Version,
+			            Location => Format_Object.Location);
+		            end if;
+		            ARM_Output.Ordinary_Text (Output_Object,
+			         Text => AARM_Prefix);
+		            ARM_Output.Text_Format (Output_Object,
+			        Bold => Format_Object.Is_Bold,
 			        Italic => Format_Object.Is_Italic,
 			        Font => Format_Object.Font,
 			        Size => Format_Object.Size,
 			        Change => Format_Object.Change,
 			        Version => Format_Object.Impdef_Version,
 			        Location => Format_Object.Location);
-		        end if;
-		        ARM_Output.Ordinary_Text (Output_Object,
-			     Text => AARM_Prefix);
-		        ARM_Output.Text_Format (Output_Object,
-			    Bold => Format_Object.Is_Bold,
-			    Italic => Format_Object.Is_Italic,
-			    Font => Format_Object.Font,
-			    Size => Format_Object.Size,
-			    Change => Format_Object.Change,
-			    Version => Format_Object.Impdef_Version,
-			    Location => Format_Object.Location);
+			-- else skip the header, do nothing.
+			end if;
 		        Format_Object.Last_Paragraph_Subhead_Type := Bare_Annotation;
 		        Format_Object.Last_Non_Space := False;
 		    else -- Don't display, skip the text:
@@ -5841,6 +5908,7 @@
 			Key : ARM_Index.Index_Key;
 		        Kind : ARM_Database.Paragraph_Change_Kind_Type;
 			use type ARM_Database.Paragraph_Change_Kind_Type;
+			Local_Change : ARM_Output.Change_Type;
 		    begin
 		        Get_Change_Version (Is_First => True,
 			    Version => Format_Object.Glossary_Version);
@@ -5857,6 +5925,7 @@
 			    -- figure out whether it will get indexed and displayed
 			    -- in the Glossary.
 			    Format_Object.Glossary_Displayed := True;
+			    Local_Change := ARM_Output.None;
 		            if Format_Object.Changes = ARM_Format.Old_Only and then
 			        Format_Object.Glossary_Version > '0' then
 			        -- Old only, don't display it (and it won't be
@@ -5881,35 +5950,51 @@
 			        Format_Object.Add_to_Glossary := True;
 		            end if;
 			else
-		            if Format_Object.Changes = ARM_Format.Old_Only and then
-			        Format_Object.Glossary_Version > '0' then
-			        -- Old only, don't display it (and it won't be
-			        -- inserted, either).
-			        Format_Object.Glossary_Displayed := False;
-			        Format_Object.Add_to_Glossary := False;
-		            elsif (Format_Object.Glossary_Change_Kind = ARM_Database.Inserted or else
-			           Format_Object.Glossary_Change_Kind = ARM_Database.Inserted_Normal_Number) then
-			        if Format_Object.Glossary_Version <= Format_Object.Change_Version then
-			            Format_Object.Glossary_Displayed :=
-					Format_Object.Include_Annotations;
-			            Format_Object.Add_to_Glossary := True;
-			        else --This reference is too new, ignore it.
-			            Format_Object.Glossary_Displayed := False;
-			            Format_Object.Add_to_Glossary := False;
-			        end if;
+		            if (Format_Object.Glossary_Change_Kind = ARM_Database.Inserted or else
+			        Format_Object.Glossary_Change_Kind = ARM_Database.Inserted_Normal_Number) then
 				Format_Object.Glossary_Change_Kind := ARM_Database.Inserted;
+				Calc_Change_Disposition
+				    (Version => Format_Object.Glossary_Version,
+				     Operation => ARM_Output.Insertion,
+				     Text_Kind => Local_Change);
+				case Local_Change is
+				    when Do_Not_Display_Text =>
+				        Format_Object.Glossary_Displayed := False;
+				        Format_Object.Add_to_Glossary := False;
+				        Local_Change := ARM_Output.None;
+				    when ARM_Output.None|ARM_Output.Insertion =>
+			                Format_Object.Glossary_Displayed :=
+					    Format_Object.Include_Annotations;
+			                Format_Object.Add_to_Glossary := True;
+				    when ARM_Output.Deletion =>
+					raise Program_Error;
+				end case;
 		            elsif (Format_Object.Glossary_Change_Kind = ARM_Database.Deleted or else
 			           Format_Object.Glossary_Change_Kind = ARM_Database.Deleted_Inserted_Number or else
 			           Format_Object.Glossary_Change_Kind = ARM_Database.Deleted_No_Delete_Message or else
 			           Format_Object.Glossary_Change_Kind = ARM_Database.Deleted_Inserted_Number_No_Delete_Message) then
-			        Format_Object.Glossary_Displayed :=
-				    Format_Object.Include_Annotations;
-			        Format_Object.Add_to_Glossary := True;
 				Format_Object.Glossary_Change_Kind := ARM_Database.Deleted;
+				Calc_Change_Disposition
+				    (Version => Format_Object.Glossary_Version,
+				     Operation => ARM_Output.Deletion,
+				     Text_Kind => Local_Change);
+				case Local_Change is
+				    when Do_Not_Display_Text =>
+				        Format_Object.Glossary_Displayed := False;
+				        Format_Object.Add_to_Glossary := False;
+				        Local_Change := ARM_Output.None;
+				    when ARM_Output.None|ARM_Output.Deletion =>
+			                Format_Object.Glossary_Displayed :=
+					    Format_Object.Include_Annotations;
+			                Format_Object.Add_to_Glossary := True;
+				    when ARM_Output.Insertion =>
+					raise Program_Error;
+				end case;
 		            else -- we always display it.
 			        Format_Object.Glossary_Displayed :=
 				    Format_Object.Include_Annotations;
 			        Format_Object.Add_to_Glossary := True;
+			        Local_Change := ARM_Output.None;
 		            end if;
 			end if;
 
@@ -5974,20 +6059,12 @@
 			        Format_Object.Next_Paragraph_Version := Format_Object.Glossary_Version;
 			        Format_Object.Next_Paragraph_Change_Kind := Kind;
 
-			        if Format_Object.Glossary_Change_Kind = ARM_Database.Inserted then
-                                    -- We assume no outer changes;
-			            -- set new change state:
-			            Format_Object.Change := ARM_Output.Insertion;
-			            Format_Object.Current_Change_Version :=
-				       Format_Object.Glossary_Version;
-			            Format_Object.Current_Old_Change_Version := '0';
-				elsif Format_Object.Glossary_Change_Kind = ARM_Database.Deleted then
-			            Format_Object.Change := ARM_Output.Deletion;
-			            Format_Object.Current_Change_Version :=
-				       Format_Object.Glossary_Version;
-			            Format_Object.Current_Old_Change_Version := '0';
-				-- else nothing special.
-				end if;
+                                -- We assume no outer changes;
+			        -- set new change state:
+			        Format_Object.Change := Local_Change;
+			        Format_Object.Current_Change_Version :=
+				   Format_Object.Glossary_Version;
+			        Format_Object.Current_Old_Change_Version := '0';
 			            -- Change the state *before* outputting the
 				    -- paragraph header, so the AARM prefix is included.
 			        Display_Index_Entry (Format_Object.Glossary_Term (1..Format_Object.Glossary_Term_Len)); -- Includes Check_Paragraph.
@@ -7668,6 +7745,12 @@
 			       ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
 			        -- In this case, display nothing, period.
 				Display_It := False;
+				-- Check if any Ref's already exist; remove them
+				-- if they do. %% Ugly: This is needed if
+				-- a paragraph is first revised, then deleted,
+				-- as in 4.6. There ought to be a better way
+				-- of handling this, not sure what it is.
+				Dump_References (Format_Object.References);
 			    else
 			        Display_It := Format_Object.Include_Annotations;
 			    end if;

Questions? Ask the ACAA Technical Agent