texinfo-commits
[Top][All Lists]
Advanced

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

[8244] parsetexi no trim_spaces_comment_from_content


From: gavinsmith0123
Subject: [8244] parsetexi no trim_spaces_comment_from_content
Date: Sat, 29 Sep 2018 04:28:30 -0400 (EDT)

Revision: 8244
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8244
Author:   gavin
Date:     2018-09-29 04:28:28 -0400 (Sat, 29 Sep 2018)
Log Message:
-----------
parsetexi no trim_spaces_comment_from_content

Modified Paths:
--------------
    trunk/tp/Texinfo/XS/parsetexi/end_line.c
    trunk/tp/Texinfo/XS/parsetexi/indices.c
    trunk/tp/Texinfo/XS/parsetexi/parser.c
    trunk/tp/Texinfo/XS/parsetexi/parser.h
    trunk/tp/Texinfo/XS/parsetexi/tree.c

Modified: trunk/tp/Texinfo/XS/parsetexi/end_line.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/end_line.c    2018-09-29 07:58:48 UTC (rev 
8243)
+++ trunk/tp/Texinfo/XS/parsetexi/end_line.c    2018-09-29 08:28:28 UTC (rev 
8244)
@@ -795,6 +795,47 @@
 #undef ADD_ARG
 }
 
+/* Return a new element whose contents are the same as those of ORIGINAL,
+   but with some elements representing empty spaces removed. */
+ELEMENT *
+trim_spaces_comment_from_content (ELEMENT *original)
+{
+  ELEMENT *trimmed;
+  int i, j, k;
+  enum element_type t;
+
+  trimmed = new_element (ET_NONE);
+  trimmed->parent_type = route_not_in_tree;
+
+  if (original->contents.number == 0)
+    return trimmed;
+
+  i = 1;
+  t = original->contents.list[0]->type;
+  if (t != ET_empty_line_after_command
+      && t != ET_empty_spaces_after_command
+      && t != ET_empty_spaces_before_argument
+      && t != ET_empty_space_at_end_def_bracketed
+      && t != ET_empty_spaces_after_close_brace)
+    i = 0;
+
+  for (j = original->contents.number - 1; j >= 0; j--)
+    {
+      enum element_type t = original->contents.list[j]->type;
+      if (original->contents.list[j]->cmd != CM_c
+          && original->contents.list[j]->cmd != CM_comment
+          && t != ET_spaces_at_end
+          && t != ET_space_at_end_block_command)
+        break;
+    }
+  for (k = i; k <= j; k++)
+    {
+      add_to_contents_as_array (trimmed, original->contents.list[k]);
+    }
+
+  return trimmed;
+}
+
 // 2257
 /* NODE->contents is the Texinfo for the specification of a node.  This
    function sets three fields on the returned object:
@@ -979,7 +1020,6 @@
 int
 parse_float_type (ELEMENT *current)
 {
-  ELEMENT *type_contents;
   EXTRA_FLOAT_TYPE *eft;
   eft = malloc (sizeof (EXTRA_FLOAT_TYPE));
   eft->content = 0;
@@ -987,22 +1027,16 @@
 
   if (current->args.number > 0)
     {
-      type_contents = trim_spaces_comment_from_content 
-        (args_child_by_index(current, 0));
-      if (type_contents->contents.number > 0)
+      if (current->args.list[0]->contents.number > 0)
         {
           char *normalized;
-          normalized = convert_to_texinfo (type_contents);
-          eft->content = type_contents;
+          normalized = convert_to_texinfo (current->args.list[0]);
+          eft->content = current->args.list[0];
           eft->normalized = normalized;
 
           add_extra_float_type (current, "type", eft);
           return 1;
         }
-      else
-        {
-          destroy_element (type_contents);
-        }
     }
   eft->normalized = strdup ("");
   add_extra_float_type (current, "type", eft);
@@ -1354,18 +1388,10 @@
       char *text = 0;
       int superfluous_arg = 0;
       int i;
-      ELEMENT *trimmed = 0;
 
       if (current->args.number > 0)
-        {
-          trimmed = trim_spaces_comment_from_content
-            (args_child_by_index(current, 0));
+        text = convert_to_text (current->args.list[0], &superfluous_arg);
 
-          text = convert_to_text (trimmed, &superfluous_arg);
-        }
-
-      destroy_element (trimmed);
-
       if (!text || !strcmp (text, ""))
         {
           if (!superfluous_arg)
@@ -1737,15 +1763,11 @@
     }
   else
     {
-      /* All the other "line" commands" */
-      ELEMENT *misc_content;
-
-      misc_content = trim_spaces_comment_from_content 
-        (last_args_child(current));
-
-      if (current->cmd != CM_top && misc_content->contents.number == 0)
+      /* All the other "line" commands. Check they have an argument. Empty 
+         @top is allowed. */
+      if (current->args.list[0]->contents.number == 0
+          && current->cmd != CM_top)
         {
-          destroy_element (misc_content);
           command_warn (current, "@%s missing argument", 
                         command_name(current->cmd));
           add_extra_integer (current, "missing_argument", 1);
@@ -1752,8 +1774,6 @@
         }
       else
         {
-          // 3266
-          add_extra_contents (current, "misc_content", misc_content);
           if ((current->parent->cmd == CM_ftable
                || current->parent->cmd == CM_vtable)
               && (current->cmd == CM_item || current->cmd == CM_itemx))
@@ -1760,7 +1780,8 @@
             {
               enter_index_entry (current->parent->cmd,
                                  current->cmd,
-                                 current, misc_content);
+                                 current,
+                                 current->args.list[0]);
             }
           else
             {
@@ -1776,7 +1797,7 @@
 
               // 3274
               enter_index_entry (current->cmd, current->cmd, current,
-                                 misc_content);
+                                 current->args.list[0]);
               current->type = ET_index_entry_command;
             }
         }

Modified: trunk/tp/Texinfo/XS/parsetexi/indices.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/indices.c     2018-09-29 07:58:48 UTC (rev 
8243)
+++ trunk/tp/Texinfo/XS/parsetexi/indices.c     2018-09-29 08:28:28 UTC (rev 
8244)
@@ -135,9 +135,7 @@
     {
       ie = &idx->index_entries[i];
       //destroy_element (ie->content);
-      ; /* all data is referenced elsewhere */
-      // FIXME: the content is referenced for commands like @cindex
-      // in the "misc_content" array, but not for commands like @deffn.
+      // TODO - check if above is required
     }
   free (idx->index_entries);
 }

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-09-29 07:58:48 UTC (rev 
8243)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-09-29 08:28:28 UTC (rev 
8244)
@@ -597,50 +597,6 @@
 }
 
 
-// 5467, also in Common.pm 1334
-/* Return a new element whose contents are the same as those of ORIGINAL,
-   but with some elements representing empty spaces removed.  Elements like 
-   these are used to represent some of the "content" extra keys. */
-ELEMENT *
-trim_spaces_comment_from_content (ELEMENT *original)
-{
-  ELEMENT *trimmed;
-  int i, j, k;
-  enum element_type t;
-
-  trimmed = new_element (ET_NONE);
-  trimmed->parent_type = route_not_in_tree;
-
-  if (original->contents.number == 0)
-    return trimmed;
-
-  i = 1;
-  t = original->contents.list[0]->type;
-  if (t != ET_empty_line_after_command
-      && t != ET_empty_spaces_after_command
-      && t != ET_empty_spaces_before_argument
-      && t != ET_empty_space_at_end_def_bracketed
-      && t != ET_empty_spaces_after_close_brace)
-    i = 0;
-
-  for (j = original->contents.number - 1; j >= 0; j--)
-    {
-      enum element_type t = original->contents.list[j]->type;
-      if (original->contents.list[j]->cmd != CM_c
-          && original->contents.list[j]->cmd != CM_comment
-          && t != ET_spaces_at_end
-          && t != ET_space_at_end_block_command)
-        break;
-    }
-  for (k = i; k <= j; k++)
-    {
-      add_to_contents_as_array (trimmed, original->contents.list[k]);
-    }
-
-  return trimmed;
-}
-
-
 /* 3491 */
 /* Add an "ET_empty_line_after_command" element containing the whitespace at 
    the beginning of the rest of the line.  This element can be later changed 
to 

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.h
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.h      2018-09-29 07:58:48 UTC (rev 
8243)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.h      2018-09-29 08:28:28 UTC (rev 
8244)
@@ -69,7 +69,6 @@
 ELEMENT *merge_text (ELEMENT *current, char *text);
 void start_empty_line_after_command (ELEMENT *current, char **line_inout,
                                      ELEMENT *command);
-ELEMENT *trim_spaces_comment_from_content (ELEMENT *original);
 ELEMENT *begin_paragraph (ELEMENT *current);
 int format_expanded_p (char *format);
 

Modified: trunk/tp/Texinfo/XS/parsetexi/tree.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/tree.c        2018-09-29 07:58:48 UTC (rev 
8243)
+++ trunk/tp/Texinfo/XS/parsetexi/tree.c        2018-09-29 08:28:28 UTC (rev 
8244)
@@ -113,23 +113,18 @@
             EXTRA_FLOAT_TYPE *eft = (EXTRA_FLOAT_TYPE *) e->extra[i].value;
             free (eft->normalized);
 
-            if (eft->content)
-              destroy_element (eft->content);
-            /* free_node_contents (eft->content); */
-            /* Big problem here.  If we call free_node_contents to look for
-               'route_not_in_tree' elements, the elements that *were* in
-               the tree may have already been freed via reset_parser.  I don't 
-               expect there to be 'route_not_in_tree' elements for 
-               EXTRA_FLOAT_TYPE; however, it's a potential problem for 
-               extra_node_spec above.  The best solution would seem to get rid 
-               of the need for any 'route_not_in_tree' elements. */
-
             free (eft);
             break;
           }
         case extra_misc_args:
-            /* Same problem as above. */
           //destroy_element_and_children (e->extra[i].value);
+            /* Big problem here.  If we call free_node_contents to look for
+               'route_not_in_tree' elements, the elements that *were* in
+               the tree may have already been freed via reset_parser.
+               Also a potential problem for extra_node_spec above.  The best 
+               solution would seem to get rid of the need for any 
+               'route_not_in_tree' elements. */
+
           break;
         case extra_def_info:
           free (e->extra[i].value);




reply via email to

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