texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[7159] parsetexi global commands


From: gavinsmith0123
Subject: [7159] parsetexi global commands
Date: Sun, 8 May 2016 17:43:39 +0000 (UTC)

Revision: 7159
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7159
Author:   gavin
Date:     2016-05-08 17:43:39 +0000 (Sun, 08 May 2016)
Log Message:
-----------
parsetexi global commands

Modified Paths:
--------------
    trunk/tp/parsetexi/api.c
    trunk/tp/parsetexi/command_data.txt
    trunk/tp/parsetexi/handle_commands.c
    trunk/tp/parsetexi/handle_commands.h
    trunk/tp/parsetexi/separator.c
    trunk/tp/parsetexi/tree_types.h

Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c    2016-05-08 16:33:27 UTC (rev 7158)
+++ trunk/tp/parsetexi/api.c    2016-05-08 17:43:39 UTC (rev 7159)
@@ -230,9 +230,12 @@
       /* TODO: Same optimizations as for 'type'. */
     }
 
+  /* FIXME sort out all these special cases */
   if (e->contents.number > 0
-      || e->type == ET_text_root // FIXME special case
+      || e->type == ET_text_root
       || e->cmd == CM_image // why image?
+      || e->cmd == CM_item && e->parent && e->parent->type == ET_row
+      || e->cmd == CM_tab && e->parent && e->parent->type == ET_row
       || e->cmd == CM_anchor
       || e->cmd == CM_macro
       || e->cmd == CM_multitable
@@ -785,14 +788,156 @@
 build_global_info2 (void)
 {
   HV *hv;
+  AV *av;
+  int i;
+  ELEMENT *e;
 
   dTHX;
 
   hv = newHV ();
+
+  /* These should be unique elements. */
+
   if (global_info.settitle && global_info.settitle->hv)
     {
       hv_store (hv, "settitle", strlen ("settitle"),
                 newRV_inc ((SV *) global_info.settitle->hv), 0);
     }
+  if (global_info.copying && global_info.copying->hv)
+    {
+      hv_store (hv, "copying", strlen ("copying"),
+                newRV_inc ((SV *) global_info.copying->hv), 0);
+    }
+  if (global_info.shorttitlepage && global_info.shorttitlepage->hv)
+    {
+      hv_store (hv, "shorttitlepage", strlen ("shorttitlepage"),
+                newRV_inc ((SV *) global_info.shorttitlepage->hv), 0);
+    }
+  if (global_info.title && global_info.title->hv)
+    {
+      hv_store (hv, "title", strlen ("title"),
+                newRV_inc ((SV *) global_info.title->hv), 0);
+    }
+  if (global_info.titlepage && global_info.titlepage->hv)
+    {
+      hv_store (hv, "titlepage", strlen ("titlepage"),
+                newRV_inc ((SV *) global_info.titlepage->hv), 0);
+    }
+  if (global_info.top && global_info.top->hv)
+    {
+      hv_store (hv, "top", strlen ("top"),
+                newRV_inc ((SV *) global_info.top->hv), 0);
+    }
+
+  /* The following are arrays of elements. */
+
+  if (global_info.footnotes.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "footnote", strlen ("footnote"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.footnotes.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.footnotes, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.hyphenation.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "hyphenation", strlen ("hyphenation"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.hyphenation.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.hyphenation, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.insertcopying.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "insertcopying", strlen ("insertcopying"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.insertcopying.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.insertcopying, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.printindex.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "printindex", strlen ("printindex"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.printindex.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.printindex, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.subtitle.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "subtitle", strlen ("subtitle"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.subtitle.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.subtitle, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.titlefont.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "titlefont", strlen ("titlefont"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.titlefont.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.titlefont, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.listoffloats.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "listoffloats", strlen ("listoffloats"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.listoffloats.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.listoffloats, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.detailmenu.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "detailmenu", strlen ("detailmenu"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.detailmenu.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.detailmenu, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+  if (global_info.part.contents.number > 0)
+    {
+      av = newAV ();
+      hv_store (hv, "part", strlen ("part"),
+                newRV_inc ((SV *) av), 0);
+      for (i = 0; i < global_info.part.contents.number; i++)
+        {
+          e = contents_child_by_index (&global_info.part, i);
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
   return hv;
 }

Modified: trunk/tp/parsetexi/command_data.txt
===================================================================
--- trunk/tp/parsetexi/command_data.txt 2016-05-08 16:33:27 UTC (rev 7158)
+++ trunk/tp/parsetexi/command_data.txt 2016-05-08 17:43:39 UTC (rev 7159)
@@ -325,8 +325,8 @@
 math           brace   BRACE_context
 
 # explained commands 624
-abbr           brace   1
-acronym                brace   1
+abbr           brace   2
+acronym                brace   2
 
 # inline format command
 inlineraw              brace,inline    BRACE_inline

Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c        2016-05-08 16:33:27 UTC (rev 
7158)
+++ trunk/tp/parsetexi/handle_commands.c        2016-05-08 17:43:39 UTC (rev 
7159)
@@ -84,18 +84,69 @@
 }
 
 // 1056
-/* Record the information from a command of global effect. */
-static int
+/* Record the information from a command of global effect.
+   TODO: Could we scrap the first argument and use CURRENT->cmd? */
+int
 register_global_command (enum command_id cmd, ELEMENT *current)
 {
-  if (cmd == CM_shortcontents)
-    cmd == CM_summarycontents;
+  if ((command_data(cmd).flags & CF_global_unique))
+    {
+      if (cmd == CM_shortcontents)
+        cmd == CM_summarycontents;
+      switch (cmd)
+        {
+        case CM_copying:
+          global_info.copying = current; break;
+        case CM_settitle:
+          global_info.settitle = current; break;
+        case CM_shorttitlepage:
+          global_info.shorttitlepage = current; break;
+        case CM_title:
+          global_info.title = current; break;
+        case CM_titlepage:
+          global_info.titlepage = current; break;
+        case CM_top:
+          global_info.top = current; break;
+        }
+    }
 
+
   // TODO: Why even give @author this flag in the first place?
   if (cmd != CM_author && (command_data(cmd).flags & CF_global))
     {
       if (!current->line_nr.line_nr)
         current->line_nr = line_nr;
+      switch (cmd)
+        {
+        case CM_footnote:
+          add_to_contents_as_array (&global_info.footnotes, current);
+          break;
+        case CM_hyphenation:
+          add_to_contents_as_array (&global_info.hyphenation, current);
+          break;
+        case CM_insertcopying:
+          add_to_contents_as_array (&global_info.insertcopying, current);
+          break;
+        case CM_printindex:
+          add_to_contents_as_array (&global_info.printindex, current);
+          break;
+        case CM_subtitle:
+          add_to_contents_as_array (&global_info.subtitle, current);
+          break;
+        case CM_titlefont:
+          add_to_contents_as_array (&global_info.titlefont, current);
+          break;
+        case CM_listoffloats:
+          add_to_contents_as_array (&global_info.listoffloats, current);
+          break;
+        case CM_detailmenu:
+          add_to_contents_as_array (&global_info.detailmenu, current);
+          break;
+        case CM_part:
+          add_to_contents_as_array (&global_info.part, current);
+          break;
+        }
+      /* TODO: Check if all of these are necessary. */
       return 1;
     }
   else if ((command_data(cmd).flags & CF_global_unique))

Modified: trunk/tp/parsetexi/handle_commands.h
===================================================================
--- trunk/tp/parsetexi/handle_commands.h        2016-05-08 16:33:27 UTC (rev 
7158)
+++ trunk/tp/parsetexi/handle_commands.h        2016-05-08 17:43:39 UTC (rev 
7159)
@@ -6,3 +6,4 @@
 ELEMENT *handle_brace_command (ELEMENT *current, char **line_inout,
                                enum command_id cmd_id);
 int check_no_text (ELEMENT *current);
+int register_global_command (enum command_id cmd, ELEMENT *current);

Modified: trunk/tp/parsetexi/separator.c
===================================================================
--- trunk/tp/parsetexi/separator.c      2016-05-08 16:33:27 UTC (rev 7158)
+++ trunk/tp/parsetexi/separator.c      2016-05-08 17:43:39 UTC (rev 7159)
@@ -337,6 +337,9 @@
         }
       else if (command_data(closed_command).flags & (CF_explained | CF_inline))
         { // 5129
+          /* TODO: For @abbr and @acronym, keep track of whether an expansion
+             for the abbreviation has been given.  This is used in the HTML
+             output for the <abbr title> attribute. */
         }
       else if (closed_command == CM_errormsg) // 5173
         {
@@ -352,7 +355,7 @@
           add_extra_element (current->parent->parent->parent,
                              "command_as_argument", current->parent);
         }
-      //register_global_command ();
+      register_global_command (current->parent->cmd, current->parent);
 
       // 5190
       if (current->parent->cmd == CM_anchor
@@ -394,7 +397,8 @@
           debug ("CLOSING(context command)");
           closed_command = current->parent->cmd;
 
-          // 5211
+          register_global_command (current->parent->cmd, current->parent);
+          // 5220
           current = current->parent->parent;
           if (close_preformatted_command(closed_command))
             current = begin_preformatted (current);

Modified: trunk/tp/parsetexi/tree_types.h
===================================================================
--- trunk/tp/parsetexi/tree_types.h     2016-05-08 16:33:27 UTC (rev 7158)
+++ trunk/tp/parsetexi/tree_types.h     2016-05-08 17:43:39 UTC (rev 7159)
@@ -104,7 +104,25 @@
 typedef struct GLOBAL_INFO {
     char *input_file_name;
     char *input_encoding_name;
+
+    /* Elements that should be unique. */
     ELEMENT *settitle; /* Title of document. */
+    ELEMENT *copying;
+    ELEMENT *shorttitlepage;
+    ELEMENT *title;
+    ELEMENT *titlepage;
+    ELEMENT *top;
+
+    /* Arrays of elements */
+    ELEMENT footnotes;
+    ELEMENT hyphenation;
+    ELEMENT insertcopying;
+    ELEMENT printindex;
+    ELEMENT subtitle;
+    ELEMENT titlefont;
+    ELEMENT listoffloats;
+    ELEMENT detailmenu;
+    ELEMENT part;
 } GLOBAL_INFO;
 
 typedef struct {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]