CVS difference for arm/progs/arm_cont.adb

Differences between 1.15 and version 1.16
Log of other versions for file arm/progs/arm_cont.adb

--- arm/progs/arm_cont.adb	2011/10/19 23:58:04	1.15
+++ arm/progs/arm_cont.adb	2011/10/21 06:40:45	1.16
@@ -52,6 +52,7 @@
     -- 10/24/08 - RLB - More old titles.
     --  5/07/09 - RLB - Added Dead_Clause.
     -- 10/18/11 - RLB - Changed to GPLv3 license.
+    -- 10/19/11 - RLB - Added Parent_Clause from Stephen Leake's version.
 
     function "<" (Left, Right : Clause_Number_Type) return Boolean is
 	-- True if Left comes before Right in the collating order.
@@ -579,6 +580,41 @@
 	end loop;
 	raise Not_Found_Error;
     end Next_Clause;
+
+
+    function Parent_Clause (Clause : in String) return String is
+        -- Returns the string of the parent clause (in the table of contents)
+        -- for the properly formatted clause string Clause.
+        --
+        -- Result is a null string if Clause is a top level clause;
+        -- Section, Unnumbered_Section, Normative_Annex,
+        -- Informative_Annex, Plain_Annex.
+        Clause_Number : Clause_Number_Type;
+    begin
+	Make_Clause (Clause, Clause_Number);
+
+	if Clause_Number.Clause = 0 then
+	   -- Clause is a section; no parent
+	   return "";
+
+	elsif Clause_Number.Subclause = 0 then
+	   -- Clause is a clause; parent is Section or Annex
+	   if Clause_Number.Section >= ANNEX_START then
+	      return Make_Clause_Number (Normative_Annex, (Clause_Number.Section, 0, 0, 0));
+	   else
+	      return Make_Clause_Number (Section, (Clause_Number.Section, 0, 0, 0));
+	   end if;
+
+	elsif Clause_Number.Subsubclause = 0 then
+	   -- Clause is a subclause; clause is parent
+	   return Make_Clause_Number (ARM_Contents.Clause, (Clause_Number.Section, Clause_Number.Clause, 0, 0));
+
+	else
+	   -- Clause is a subsubclause; subclause is parent
+	   return Make_Clause_Number
+	     (Subclause, (Clause_Number.Section, Clause_Number.Clause, Clause_Number.Subclause, 0));
+	end if;
+    end Parent_Clause;
 
 
     procedure For_Each is

Questions? Ask the ACAA Technical Agent