texinfo-commits
[Top][All Lists]
Advanced

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

[6859] parsetexi update


From: Gavin D. Smith
Subject: [6859] parsetexi update
Date: Tue, 15 Dec 2015 12:36:08 +0000

Revision: 6859
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6859
Author:   gavin
Date:     2015-12-15 12:35:32 +0000 (Tue, 15 Dec 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/api.c
    trunk/parsetexi/close.c
    trunk/parsetexi/def.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/handle_commands.c
    trunk/parsetexi/parser.h
    trunk/parsetexi/tree.c

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/api.c       2015-12-15 12:35:32 UTC (rev 6859)
@@ -420,7 +420,6 @@
               /* Value is an array of two-element arrays. */
               AV *av, *av2;
               HV *def_parsed_hash;
-              char *label;
               int j;
               DEF_ARGS_EXTRA *d = (DEF_ARGS_EXTRA *) f;
 
@@ -434,9 +433,10 @@
                         strlen ("def_parsed_hash"),
                         newRV_inc ((SV *)def_parsed_hash), 0);
 
-              for (j = 0; (label = d->labels[j]); j++)
+              for (j = 0; j < d->nelements; j++)
                 {
                   ELEMENT *elt = d->elements[j];
+                  char *label = d->labels[j];
                   av2 = newAV ();
                   av_push (av, newRV_inc ((SV *)av2));
                   av_push (av2, newSVpv (label, 0));

Modified: trunk/parsetexi/close.c
===================================================================
--- trunk/parsetexi/close.c     2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/close.c     2015-12-15 12:35:32 UTC (rev 6859)
@@ -236,7 +236,7 @@
 }
 
 /* 1642 */
-static ELEMENT *
+ELEMENT *
 close_current (ELEMENT *current,
                enum command_id closed_command,
                enum command_id interrupting_command)

Modified: trunk/parsetexi/def.c
===================================================================
--- trunk/parsetexi/def.c       2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/def.c       2015-12-15 12:35:32 UTC (rev 6859)
@@ -73,7 +73,8 @@
 /* Used for definition line parsing.  Return next unit on the line after
    a definition command like @deffn.  The contents of E is what is remaining
    in the argument line.  *SPACES_OUT is set to an element with spaces before 
-   the line. */
+   the line.  Both of the elements that are output have their `parent' field
+   nulled (because the parent element is eventually destroyed). */
 static ELEMENT *
 next_bracketed_or_word (ELEMENT *e, ELEMENT **spaces_out)
 {
@@ -325,8 +326,6 @@
   /* CATEGORY */
   arg = next_bracketed_or_word (arg_line, &spaces);
 
-  /* We need to null the parent because the parent element is
-     eventually destroyed. */
   if (spaces)
     add_to_def_args_extra (def_args, "spaces", spaces);
   add_to_def_args_extra (def_args, "category", arg);
@@ -420,6 +419,7 @@
     }
 
   destroy_element (arg_line);
+  add_to_def_args_extra (def_args, 0, 0);
   return def_args;
 
 #if 0

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/end_line.c  2015-12-15 12:35:32 UTC (rev 6859)
@@ -1423,6 +1423,8 @@
 ELEMENT *
 end_line (ELEMENT *current)
 {
+  ELEMENT *current_old = current; /* Used at very end of function */
+
   // 2621
   /* If empty line, start a new paragraph. */
   if (last_contents_child (current)
@@ -1614,17 +1616,20 @@
         }
     }
 
-  /* End of a definition line, like @deffn */ // 2778
+  /* End of a definition line, like @deffn */ // 2933
   else if (current->parent && current->parent->type == ET_def_line)
     {
       enum command_id def_command, original_def_command;
       DEF_ARGS_EXTRA *arguments = 0;
+      KEY_PAIR *k;
 
       if (pop_context () != ct_def)
         abort ();
 
-      /* current->parent is a ET_def_line, and current->parent->parent
-         the def command. */
+      k = lookup_extra_key (current->parent, "def_command");
+      if (k)
+        ; // TODO
+
       original_def_command = def_command = current->parent->parent->cmd;
       /* Strip an trailing x from the command, e.g. @deffnx -> @deffn */
       if (command_data(def_command).flags & CF_misc)
@@ -1648,8 +1653,9 @@
           add_extra_def_args (current->parent, "def_args", arguments);
 
           /* We use the keys "name" and "class" from the arguments. */
-          for (i = 0; (label = arguments->labels[i]); i++)
+          for (i = 0; i < arguments->nelements; i++)
             {
+              label = arguments->labels[i];
               if (!strcmp (label, "name"))
                 name = arguments->elements[i];
               else if (!strcmp (label, "class"))
@@ -1725,12 +1731,33 @@
       current = end_line_misc_line (current);
     }
 
+  /* 'line' or 'def' at top of "context stack" - this happens when
+     line commands are nested (always incorrectly?) */
+  if (current_context () == ct_line || current_context () == ct_def)
+    {
+      debug ("Still opened line command");
+      if (current_context () == ct_line)
+        {
+          while (current->parent && current->type != ET_def_line)
+            {
+              current = close_current (current, 0, 0);
+            }
+        }
+      else
+        {
+          while (current->parent
+                 && current->type != ET_block_line_arg
+                 && current->type != ET_misc_line_arg)
+            {
+              current = close_current (current, 0, 0);
+            }
+        }
 
-  // something to do with an empty line /* 3419 */
+      /* 2471 Check for infinite loop bugs */
+      if (current == current_old)
+        abort ();
 
-  //if () /* 'line' or 'def' at top of "context stack" */
-    {
-      /* Recurse. */
+      current = end_line (current);
     }
   return current;
 } /* end_line 3487 */

Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c   2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/handle_commands.c   2015-12-15 12:35:32 UTC (rev 6859)
@@ -420,6 +420,7 @@
                   line_error ("must be after @%s to use @%s",
                                command_name(base_command),
                                command_name(cmd));
+                  add_extra_string (misc, "not_after_command", "1");
                 }
             }
         } /* 4571 */

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/parser.h    2015-12-15 12:35:32 UTC (rev 6859)
@@ -17,6 +17,9 @@
 ELEMENT *close_all_style_commands (ELEMENT *current,
                                enum command_id closed_command,
                                enum command_id interrupting_command);
+ELEMENT *close_current (ELEMENT *current,
+                        enum command_id closed_command,
+                        enum command_id interrupting_command);
 
 /* In end_line.c */
 NODE_SPEC_EXTRA *parse_node_manual (ELEMENT *node);

Modified: trunk/parsetexi/tree.c
===================================================================
--- trunk/parsetexi/tree.c      2015-12-14 18:51:44 UTC (rev 6858)
+++ trunk/parsetexi/tree.c      2015-12-15 12:35:32 UTC (rev 6859)
@@ -55,6 +55,8 @@
   free (e->contents.list);
   free (e->args.list);
 
+  /* FIXME destroy extra values as well? */
+
   free (e);
 }
 




reply via email to

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