texinfo-commits
[Top][All Lists]
Advanced

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

[5979] parsetexi update


From: Gavin D. Smith
Subject: [5979] parsetexi update
Date: Fri, 19 Dec 2014 23:28:24 +0000

Revision: 5979
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5979
Author:   gavin
Date:     2014-12-19 23:28:23 +0000 (Fri, 19 Dec 2014)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/Makefile.am
    trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
    trunk/parsetexi/command_data.txt
    trunk/parsetexi/dump_perl.c
    trunk/parsetexi/element_types.c
    trunk/parsetexi/element_types.h
    trunk/parsetexi/element_types.txt
    trunk/parsetexi/end_line.c
    trunk/parsetexi/handle_commands.c
    trunk/parsetexi/parser.c
    trunk/parsetexi/parser.h
    trunk/parsetexi/separator.c
    trunk/parsetexi/tree.c
    trunk/parsetexi/tree.h

Added Paths:
-----------
    trunk/parsetexi/menus.c

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/ChangeLog   2014-12-19 23:28:23 UTC (rev 5979)
@@ -1,3 +1,25 @@
+2014-12-19  Gavin Smith  <address@hidden>
+
+       * element_types.txt: Add menu_entry and menu_star types.
+       * menus.c: New file.
+       (handle_menu, enter_menu_entry_node): Add functions.
+       * parser.c (big_loop): Call handle_menu in menus.c.
+
+       * handle_commands.c (handle_block_command) <menu commands>: 
+       Outline of menu handling.
+       * separator.c (handle_separator): Handle separators inside a 
+       menu entry.
+       * end_line.c (end_line): Start processing a menu at end of 
+       "@menu" line.  Handle end of a line inside a menu.
+
+       * Parsetexi/lib/Parsetexi.pm: Complete 'menus' arrays for each 
+       node element, and 'menu_entry' 'extra' keys on menu entries.
+
+       * parser.c (isolate_last_space): Take an extra argument giving 
+       type of whitespace element.
+       * tree.c (destroy_element): Free the contents and args arrays.
+       (pop_element_from_args): New function.
+
 2014-12-17  Gavin Smith  <address@hidden>
 
        * tree_types.h (LINE_NR): Fields added to struct.

Modified: trunk/parsetexi/Makefile.am
===================================================================
--- trunk/parsetexi/Makefile.am 2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/Makefile.am 2014-12-19 23:28:23 UTC (rev 5979)
@@ -23,7 +23,8 @@
                  handle_commands.c handle_commands.h \
                  def.c def.h \
                  dump_perl.c \
-                 extra.c
+                 extra.c \
+                 menus.c
 
 parsetexi_SOURCES=$(libparsetexi_a_SOURCES) main.c
 

Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2014-12-19 20:47:21 UTC (rev 
5978)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2014-12-19 23:28:23 UTC (rev 
5979)
@@ -180,6 +180,45 @@
   }
 }
 
+# Set the 'menu_entry' extra key on each menu entry.  This was the
+# return value of _parse_node_manual (line 2257, Parser.pm).
+sub _add_menu_entry_node_keys ($) {
+  my $menu = shift;
+  foreach my $entry (@{$menu->{'contents'}}) {
+    next if !$entry->{'type'} or $entry->{'type'} ne 'menu_entry';
+    foreach my $part (@{$entry->{'args'}}) {
+      if ($part->{'type'} eq 'menu_entry_node') {
+       #$entry->{'extra'}->{'menu_entry_node'}->{'manual_content'} = ...;
+
+       # In Texinfo::Parser::_parse_node_manual, a copy was taken of
+       # the contents, and leading and trailing whitespace elements
+       # removed with _trim_spaces_comment_from_content.
+       $entry->{'extra'}->{'menu_entry_node'}->{'node_content'}
+         = $part->{'contents'};
+
+       # TODO: Actually get normalized node name of target.
+       $entry->{'extra'}->{'menu_entry_node'}->{'normalized'}
+         = $part->{'contents'}[0]{'text'};
+      }
+    }
+  }
+}
+
+# Look for a menu in the node, saving in the 'menus' array reference
+# of the node element
+# This array was built on line 4800 of Parser.pm.
+sub _find_menus_of_node ($) {
+  my $node = shift;
+
+  foreach my $child
+          (@{$node->{'extra'}{'associated_section'}->{'contents'}}) {
+    if ($child->{'cmdname'} and $child->{'cmdname'} eq 'menu') {
+      push @{$node->{'menus'}}, $child;
+      _add_menu_entry_node_keys ($child);
+    }
+  }
+}
+
 # Loop through the top-level elements in the tree, collecting node 
 # elements into $ROOT->{'nodes').  This is used in 
 # Structuring.pm:nodes_tree.
@@ -210,6 +249,8 @@
        #  $child->{'extra'}->{'node_content'} =  $node_arg->{'contents'};
        #}
       }
+
+      _find_menus_of_node ($child);
     }
   }
 }

Modified: trunk/parsetexi/command_data.txt
===================================================================
--- trunk/parsetexi/command_data.txt    2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/command_data.txt    2014-12-19 23:28:23 UTC (rev 5979)
@@ -376,9 +376,9 @@
 multitable             block,blockitem         BLOCK_multitable
 
 # menu commands
-menu                   block
-detailmenu             block
-direntry               block
+menu                   block,menu
+detailmenu             block,menu
+direntry               block,menu
 
 # align commands
 raggedright            block

Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/dump_perl.c 2014-12-19 23:28:23 UTC (rev 5979)
@@ -225,6 +225,7 @@
     }
 
   /* TODO: macro. */
+  dump_indent ();
   printf ("'macro' => ''\n");
 
   indent -= 2;

Modified: trunk/parsetexi/element_types.c
===================================================================
--- trunk/parsetexi/element_types.c     2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/element_types.c     2014-12-19 23:28:23 UTC (rev 5979)
@@ -32,12 +32,14 @@
 "block_line_arg",
 "misc_line_arg",
 "misc_arg",
+"menu_entry",
 "menu_entry_leading_text",
 "menu_entry_name",
 "menu_entry_separator",
 "menu_entry_node",
 "menu_entry_description",
 "menu_comment",
+"menu_star",
 "macro_name",
 "macro_arg",
 "before_item",

Modified: trunk/parsetexi/element_types.h
===================================================================
--- trunk/parsetexi/element_types.h     2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/element_types.h     2014-12-19 23:28:23 UTC (rev 5979)
@@ -33,12 +33,14 @@
 ET_block_line_arg,
 ET_misc_line_arg,
 ET_misc_arg,
+ET_menu_entry,
 ET_menu_entry_leading_text,
 ET_menu_entry_name,
 ET_menu_entry_separator,
 ET_menu_entry_node,
 ET_menu_entry_description,
 ET_menu_comment,
+ET_menu_star,
 ET_macro_name,
 ET_macro_arg,
 ET_before_item,

Modified: trunk/parsetexi/element_types.txt
===================================================================
--- trunk/parsetexi/element_types.txt   2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/element_types.txt   2014-12-19 23:28:23 UTC (rev 5979)
@@ -36,12 +36,17 @@
 block_line_arg
 misc_line_arg
 misc_arg
+
+menu_entry
 menu_entry_leading_text
 menu_entry_name
 menu_entry_separator
 menu_entry_node
 menu_entry_description
 menu_comment
+# Used internally
+menu_star
+
 macro_name
 macro_arg
 before_item

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/end_line.c  2014-12-19 23:28:23 UTC (rev 5979)
@@ -17,6 +17,7 @@
   char *end_command = 0;
   enum command_id end_id;
 
+  // 2621
   /* If empty line, start a new paragraph. */
   if (last_contents_child (current)
       && last_contents_child (current)->type == ET_empty_line)
@@ -40,8 +41,52 @@
         }
     }
 
-  /* Is it a line of a menu? */ /* line 2667 */
+  // 2667
+  /* The end of the line of a menu. */
+  else if (current->type == ET_menu_entry_name
+           || current->type == ET_menu_entry_node)
+    {
+      ELEMENT *end_comment;
+      int empty_menu_entry_node = 0;
 
+      if (current->type == ET_menu_entry_node)
+        {
+          ELEMENT *last = last_contents_child (current);
+
+          if (current->contents.number > 0
+              && (last->cmd == CM_c || last->cmd == CM_comment))
+            {
+              end_comment = pop_element_from_contents (current);
+            }
+
+          /* If contents empty or is all whitespace. */
+          if (current->contents.number == 0
+              || (current->contents.number == 1
+                  && last->text.end > 0
+                  && !last->text.text[strspn (last->text.text, 
+                                              whitespace_chars)]))
+            {
+              empty_menu_entry_node = 1;
+              if (end_comment)
+                add_to_element_contents (current, end_comment);
+            }
+        }
+
+      // 2689
+      /* Abort the menu entry if there is no destination node given. */
+      if (empty_menu_entry_node || current->type == ET_menu_entry_name)
+        {
+        }
+      else // 2768
+        {
+          debug ("MENU ENTRY END LINE");
+          current = current->parent;
+          current = enter_menu_entry_node (current);
+          if (end_comment)
+            add_to_element_contents (current, end_comment);
+        }
+    }
+
   /* Is it a def line 2778 */
   else if (current->parent && current->parent->type == ET_def_line)
     {
@@ -65,7 +110,8 @@
 
     }
 
-  /* block line arg command 2872 */
+  // 2872
+  /* End of a line starting a block. */
   else if (current->type == ET_block_line_arg)
     {
       enum context c;
@@ -129,6 +175,20 @@
             current = bi;
           }
         } /* CF_blockitem */
+
+      // 3077
+      if (command_flags(current) & CF_menu)
+        {
+          /* Start reading a menu.  Processing will continue in
+             handle_menu in menus.c. */
+
+          ELEMENT *menu_comment = new_element (ET_menu_comment);
+          add_to_element_contents (current, menu_comment);
+          current = menu_comment;
+          debug ("MENU COMMENT OPEN");
+          push_context (ct_preformatted);
+        }
+      current = begin_preformatted (current);
     }
 
   /* after an "@end verbatim" 3090 */
@@ -155,7 +215,7 @@
       int cmd_id, arg_type;
       enum context c;
 
-      isolate_last_space (current);
+      isolate_last_space (current, 0);
 
       current = current->parent;
       cmd_id = current->cmd;

Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c   2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/handle_commands.c   2014-12-19 23:28:23 UTC (rev 5979)
@@ -366,7 +366,34 @@
           // regionsstack
 
           // 4784 menu commands
+          if (command_data(cmd_id).flags & CF_menu)
+            {
+              if (current_context () == ct_preformatted)
+                push_context (ct_preformatted);
+              else
+                push_context (ct_menu);
 
+              /* Check if we are ignoring "global commands". */
+
+              // Record dir entry here
+
+              if (current_node)
+                {
+                  if (cmd_id == CM_direntry)
+                    {
+                      // warning
+                    }
+                  else if (cmd_id == CM_menu)
+                    {
+                      // add to array of menus for current node
+                    }
+                }
+              else
+                {
+                }
+            }
+
+          // 4816
           {
             ELEMENT *bla = new_element (ET_block_line_arg);
             add_to_element_args (current, bla);

Added: trunk/parsetexi/menus.c
===================================================================
--- trunk/parsetexi/menus.c                             (rev 0)
+++ trunk/parsetexi/menus.c     2014-12-19 23:28:23 UTC (rev 5979)
@@ -0,0 +1,227 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "parser.h"
+#include "input.h"
+#include "text.h"
+
+// 3549
+/* Save 'menu_entry_name' 'menu_entry_node', and 'menu_entry_description'
+   extra keys on the top-level @menu element. */
+void
+register_extra_menu_entry_information (ELEMENT *current)
+{
+  int i;
+
+  for (i = 0; i < current->args.number; i++)
+    {
+      ELEMENT *arg = current->args.list[i];
+
+      if (arg->type == ET_menu_entry_name)
+        {
+          add_extra_key_element (current, "menu_entry_name", arg);
+
+          // Check menu label isn't empty
+        }
+      else if (arg->type == ET_menu_entry_node)
+        {
+          isolate_last_space (arg, ET_space_at_end_menu_node);
+
+          // parsed_entry_node = parse_node_manual ();
+          // What kind of object is the "menu_entry_node" key?
+          // parse_node_manual returns another hash?
+          // add_extra_key_??? (current, "menu_entry_node",
+          //                    parsed_entry_node);
+        }
+      else if (arg->type == ET_menu_entry_description)
+        {
+          add_extra_key_element (current, "menu_entry_description", arg);
+        }
+    }
+}
+
+/* Process the destination of the menu entry, and start a menu entry 
+   description.  */
+ELEMENT *
+enter_menu_entry_node (ELEMENT *current)
+{
+  ELEMENT *description, *preformatted;
+
+  description = new_element (ET_menu_entry_description);
+  add_to_element_args (current, description);
+  register_extra_menu_entry_information (current);
+  current->line_nr = line_nr;
+  current = description;
+
+  preformatted = new_element (ET_preformatted);
+  add_to_element_contents (current, preformatted);
+  current = preformatted;
+  push_context (ct_preformatted);
+  return current;
+}
+
+/* Called from 'big_loop' in parser.c.  Return 1 if we find menu syntax to 
+   process, otherwise return 0. */
+int
+handle_menu (ELEMENT **current_inout, char **line_inout)
+{
+  ELEMENT *current = *current_inout;
+  char *line = *line_inout;
+  int retval = 1;
+
+  // 4052
+  /* A "*" at the start of a line beginning a menu entry. */
+  if (*line == '*'
+      && current->type == ET_preformatted
+      && (current->parent->type == ET_menu_comment
+          || current->parent->type == ET_menu_entry_description)
+      && current->contents.number > 0
+      && last_contents_child(current)->type == ET_empty_line)
+    {
+      ELEMENT *star;
+
+      debug ("MENU STAR");
+      abort_empty_line (&current, 0);
+      line++; /* Past the '*'. */
+
+      star = new_element (ET_menu_star);
+      text_append (&star->text, "*");
+      add_to_element_contents (current, star);
+
+      /* The ET_menu_star element won't appear in the final tree. */
+    }
+  // 4067
+  /* A space after a "*" at the beginning of a line. */
+  else if (strchr (whitespace_chars, *line)
+           && current->contents.number > 0
+           && last_contents_child(current)->type == ET_menu_star)
+    {
+      ELEMENT *menu_entry, *leading_text, *entry_name;
+      int leading_spaces;
+
+      debug ("MENU ENTRY (certainly)");
+      leading_spaces = strspn (line, whitespace_chars);
+
+      destroy_element (pop_element_from_contents (current));
+
+      if (current->type == ET_preformatted
+          && current->parent->type == ET_menu_comment)
+        {
+          ELEMENT *menu = current->parent->parent;
+
+          /* Remove an empty ET_preformatted, and an empty ET_menu_comment. */
+          if (current->contents.number == 0)
+            {
+              pop_element_from_contents (current->parent);
+              if (current->parent->contents.number == 0)
+                {
+                  pop_element_from_contents (menu);
+                  destroy_element (current->parent);
+                }
+              destroy_element (current);
+            }
+
+          current = menu;
+        }
+      else
+        {
+          /* current should be ET_preformatted,
+             1st parent ET_menu_entry_description,
+             2nd parent ET_menu_entry,
+             3rd parent @menu. */
+          current = current->parent->parent->parent;
+        }
+
+      if (pop_context () != ct_preformatted)
+        abort (); // bug
+
+      menu_entry = new_element (ET_menu_entry);
+      leading_text = new_element (ET_menu_entry_leading_text);
+      entry_name = new_element (ET_menu_entry_name);
+      add_to_element_contents (current, menu_entry);
+      add_to_element_args (menu_entry, leading_text);
+      add_to_element_args (menu_entry, entry_name);
+      current = entry_name;
+
+      text_append (&leading_text->text, "*");
+      text_append_n (&leading_text->text, line, leading_spaces);
+      line += leading_spaces;
+    }
+  // 4116
+  /* A "*" followed by anything other than a space. */
+  else if (current->contents.number > 0
+           && last_contents_child(current)->type == ET_menu_star)
+    {
+      debug ("ABORT MENU STAR");
+      destroy_element (pop_element_from_contents (current));
+    }
+  // 4122
+  /* After a separator in a menu. */
+  else if (current->args.number > 0
+           && last_args_child (current)->type == ET_menu_entry_separator)
+    {
+      ELEMENT *last_child;
+      char *separator;
+
+      last_child = last_args_child (current);
+      separator = last_child->text.text;
+
+      /* Separator is "::". */
+      if (!strcmp (separator, ":") && *line == ':')
+        {
+          text_append (&last_child->text, ":");
+          line++;
+          /* Whitespace following the "::" is subsequently appended to
+             the separator element. */
+        }
+      /* A "." not followed by a space.  Not a separator. */
+      else if (!strcmp (separator, ".") && !strchr (whitespace_chars, *line))
+        {
+          pop_element_from_args (current);
+          current = last_args_child (current);
+          merge_text (current, last_child->text.text);
+          destroy_element (last_child);
+        }
+      else if (strchr (whitespace_chars_except_newline, *line))
+        {
+          int n;
+
+          n = strspn (line, whitespace_chars_except_newline);
+          text_append_n (&last_child->text, line, n);
+          line += n;
+        }
+      else if (!strncmp (separator, "::", 2))
+        {
+          ELEMENT *entry_name;
+
+          debug ("MENU NODE no entry %s", separator);
+          entry_name = args_child_by_index (current, -2);
+
+          /* Change it from ET_menu_entry_name (i.e. the label). */
+          entry_name->type = ET_menu_entry_node;
+          current = enter_menu_entry_node (current);
+        }
+      /* End of the label.  Begin the element for the destination. */
+      else if (*separator == ':')
+        {
+          ELEMENT *entry_node;
+
+          debug ("MENU ENTRY %s", separator);
+          entry_node = new_element (ET_menu_entry_node);
+          add_to_element_args (current, entry_node);
+          current = entry_node;
+        }
+      else
+        {
+          debug ("MENU NODE");
+          current = enter_menu_entry_node (current);
+        }
+    }
+  else
+    retval = 0;
+
+  *current_inout = current;
+  *line_inout = line;
+
+  return retval;
+}

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/parser.c    2014-12-19 23:28:23 UTC (rev 5979)
@@ -362,12 +362,13 @@
 
 /* 2149 */
 void
-isolate_last_space (ELEMENT *current)
+isolate_last_space (ELEMENT *current, enum element_type element_type)
 {
-  int element_type;
   ELEMENT *last = last_contents_child (current);
 
-  element_type = ET_spaces_at_end;
+  if (!element_type)
+    element_type = ET_spaces_at_end;
+
   if (last)
     {
       int index = -1;
@@ -677,6 +678,10 @@
           current = current->parent;
         }
     }
+  else if (handle_menu (&current, &line))
+    {
+      ; /* Nothing. */
+    }
 
 #if 0
 

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/parser.h    2014-12-19 23:28:23 UTC (rev 5979)
@@ -34,7 +34,7 @@
 ELEMENT *parse_texi_file (char *filename);
 int abort_empty_line (ELEMENT **current_inout, char *additional);
 ELEMENT *end_paragraph (ELEMENT *current);
-void isolate_last_space (ELEMENT *current);
+void isolate_last_space (ELEMENT *current, enum element_type type);
 int command_with_command_as_argument (ELEMENT *current);
 ELEMENT *begin_preformatted (ELEMENT *current);
 ELEMENT *end_preformatted (ELEMENT *current);
@@ -66,3 +66,7 @@
 void add_extra_key_contents (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_key_text (ELEMENT *e, char *key, ELEMENT *value);
 KEY_PAIR *lookup_extra_key (ELEMENT *e, char *key);
+
+/* In menus.c */
+int handle_menu (ELEMENT **current_inout, char **line_inout);
+ELEMENT *enter_menu_entry_node (ELEMENT *current);

Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/separator.c 2014-12-19 23:28:23 UTC (rev 5979)
@@ -261,53 +261,59 @@
   return current;
 }
 
+/* Actions to be taken when a special character appears in the input. */
 ELEMENT *
 handle_separator (ELEMENT *current, char separator, char **line_inout)
 {
   char *line = *line_inout;
 
-  switch (separator)
+  if (separator == '{') // 4888
     {
-    case '{': /* 4888 */
       current = handle_open_brace (current, &line);
-      goto funexit;
-    case '}': /* 5007 */
+    }
+  else if (separator == '}') // 5007
+    {
       current = handle_close_brace (current, &line);
-      goto funexit;
-    case ',': /* 5228 */
-      if (current->parent->remaining_args > 0)
-        current = handle_comma (current, &line);
-      else
-        {
-          /* 5297 */
-        /* error - superfluous argument for @node. */
-        break;
-        /* if (...) */
-          goto funexit;
-        }
+    }
+  else if (separator == ',' && current->remaining_args > 0) // 5228
+    {
+      current = handle_comma (current, &line);
+    }
+  else if (separator == ',' && current->type == ET_misc_line_arg
+           && current->parent->cmd == CM_node) // 5297
+    {
+      // Warning - superfluous arguments for node
+    }
+  /* 5303 After a separator in a menu. */
+  else if ((separator == ','
+            || separator == '\t'
+            || separator == '.')
+           && current->type == ET_menu_entry_node
+           || separator == ':' && current->type == ET_menu_entry_name)
+    {
+      ELEMENT *e;
+      
+      current = current->parent;
+      e = new_element (ET_menu_entry_separator);
+      text_append_n (&e->text, &separator, 1);
+      add_to_element_args (current, e);
 
-      /* Fall through */
-    case '\t':
-    case '.':
-      break;
-        /* Menu entry separator. */
-      goto funexit;
-
-    case '\f':
-      break;
-      /* Form feed stops and restarts a paragraph. */
-      goto funexit;
+      /* Note in 'handle_menu' in menus.c, if a '.' is not followed by
+         whitespace, we revert was was done here. */
     }
+  else if (separator == '\f' && current->type == ET_paragraph)
+    {
+      /* A form feed stops and restarts a paragraph. */
+    }
+  else // 5322
+    {
+      /* Default - merge the character as usual. */
+      char t[2];
+      t[0] = separator;
+      t[1] = '\0';
+      merge_text (current, t);
+    }
 
-  /* Default: merge character. */
-  {
-    char t[2];
-    t[0] = separator;
-    t[1] = '\0';
-    merge_text (current, t);
-  }
-
-funexit:
   *line_inout = line;
   return current;
 }

Modified: trunk/parsetexi/tree.c
===================================================================
--- trunk/parsetexi/tree.c      2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/tree.c      2014-12-19 23:28:23 UTC (rev 5979)
@@ -29,6 +29,12 @@
 void
 destroy_element (ELEMENT *e)
 {
+  free (e->text.text);
+
+  /* Note the pointers in these lists are not themselves freed. */
+  free (e->contents.list);
+  free (e->args.list);
+
   free (e);
 }
 
@@ -85,6 +91,14 @@
 
 
 ELEMENT *
+pop_element_from_args (ELEMENT *parent)
+{
+  ELEMENT_LIST *list = &parent->args;
+
+  return list->list[--list->number];
+}
+
+ELEMENT *
 pop_element_from_contents (ELEMENT *parent)
 {
   ELEMENT_LIST *list = &parent->contents;

Modified: trunk/parsetexi/tree.h
===================================================================
--- trunk/parsetexi/tree.h      2014-12-19 20:47:21 UTC (rev 5978)
+++ trunk/parsetexi/tree.h      2014-12-19 23:28:23 UTC (rev 5979)
@@ -4,6 +4,7 @@
 void insert_into_contents (ELEMENT *parent, ELEMENT *e, int where);
 ELEMENT *last_args_child (ELEMENT *current);
 ELEMENT *last_contents_child (ELEMENT *current);
+ELEMENT *pop_element_from_args (ELEMENT *parent);
 ELEMENT *pop_element_from_contents (ELEMENT *parent);
 ELEMENT *contents_child_by_index (ELEMENT *e, int index);
 ELEMENT *args_child_by_index (ELEMENT *e, int index);




reply via email to

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