texinfo-commits
[Top][All Lists]
Advanced

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

[6349] parsetexi update


From: Gavin D. Smith
Subject: [6349] parsetexi update
Date: Sat, 20 Jun 2015 14:15:10 +0000

Revision: 6349
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6349
Author:   gavin
Date:     2015-06-20 14:15:09 +0000 (Sat, 20 Jun 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/api.c
    trunk/parsetexi/input.c
    trunk/parsetexi/parser.c

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-06-20 08:06:47 UTC (rev 6348)
+++ trunk/parsetexi/api.c       2015-06-20 14:15:09 UTC (rev 6349)
@@ -172,7 +172,15 @@
 
   if (e->type)
     {
-      sv = newSVpv (element_type_names[e->type], 0);
+      if (e->cmd != CM_verb)
+        {
+          sv = newSVpv (element_type_names[e->type], 0);
+        }
+      else
+        {
+          char c = (char) e->type;
+          sv = newSVpv (&c, 1);
+        }
       hv_store (e->hv, "type", strlen ("type"), sv, 0);
 
       /* TODO: Could precompute hash of "type", and also reuse

Modified: trunk/parsetexi/input.c
===================================================================
--- trunk/parsetexi/input.c     2015-06-20 08:06:47 UTC (rev 6348)
+++ trunk/parsetexi/input.c     2015-06-20 14:15:09 UTC (rev 6349)
@@ -126,11 +126,17 @@
               /* Strip off a comment. */
               comment = strchr (line, '\x7F');
               if (comment)
-                *comment = '\n';
+                {
+                  *comment = '\n';
+                  comment[1] = '\0';
+                }
 
               /* TODO: convert from @documentencoding to UTF-8, assuming we 
                  want to use UTF-8 internally. */
 
+              /* Could and check for malformed input: see
+                 <http://savannah.gnu.org/bugs/?42896>. */
+
               // 1920 CPP_LINE_DIRECTIVES
 
               line_nr.line_nr++;
@@ -186,8 +192,8 @@
 
   if (input_number == input_space)
     {
-      input_stack = realloc (input_stack,
-                             (input_space *= 1.5) * sizeof (INPUT));
+      input_space++; input_space *= 1.5;
+      input_stack = realloc (input_stack, input_space * sizeof (INPUT));
       if (!input_stack)
         abort ();
     }

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2015-06-20 08:06:47 UTC (rev 6348)
+++ trunk/parsetexi/parser.c    2015-06-20 14:15:09 UTC (rev 6349)
@@ -589,6 +589,8 @@
   return 1;
 }
 
+#define GET_A_NEW_LINE 0
+
 /* line 3725 */
 /* *LINEP is a pointer into the line being processed.  It is advanced past any
    bytes processed.  Return 0 when we need to read a new line. */
@@ -703,7 +705,7 @@
               add_to_element_contents (current, e);
             }
 
-          retval = 0; /* 3844 */
+          retval = GET_A_NEW_LINE; /* 3844 */
           goto funexit;
         }
     } /********* BLOCK_raw or (ignored) BLOCK_conditional 3897 *************/
@@ -713,26 +715,32 @@
     {
       char c;
       char *q;
+
       /* Save the deliminating character in 'type', if not already done.
-         This is a reuse of 'type' for a different purpose. */
+         This is a reuse of 'type' for a different purpose.
+         If we use 'text' instead, we can get extra text stuck on the end of 
it 
+         for some reason (probably from "merging text"). */
       if (!current->parent->type)
         {
           if (!*line)
             {
               line_error ("@verb without associated character");
+              // TODO: How should we recover from this?
+              retval = GET_A_NEW_LINE; goto funexit;
             }
           else
             current->parent->type = (enum element_type) *line++;
         }
 
       c = (char) current->parent->type;
+
       /* Look forward for the delimiter character followed by a close
          brace. */
       q = line;
       do
         {
           q = strchr (q, c);
-          if (q[1] == '}' || !q)
+          if (!q || q[1] == '}')
             break;
           q++;
         }
@@ -758,9 +766,9 @@
           text_append (&e->text, line);
           add_to_element_contents (current, e);
 
-          debug ("LINE VERB: %s", line);
+          debug_nonl ("LINE VERB: %s", line);
 
-          retval = 0; goto funexit;  /* Get next line. */
+          retval = GET_A_NEW_LINE; goto funexit;  /* Get next line. */
         }
     } /* CM_verb */
 
@@ -815,7 +823,7 @@
         {
           /* TODO: Can this only happen at end of file? */
           current = end_line (current);
-          retval = 0;
+          retval = GET_A_NEW_LINE;
         }
       goto funexit;
     }
@@ -1016,8 +1024,7 @@
             {
               /* For @macro, to get a new line.  This is done instead of
                  doing the EMPTY TEXT (3879) code on the next time round. */
-              retval = 0;
-              goto funexit;
+              retval = GET_A_NEW_LINE; goto funexit;
             }
         }
 
@@ -1104,7 +1111,7 @@
 
       /* '@end' is processed in here. */
       current = end_line (current); /* 5344 */
-      retval = 0;
+      retval = GET_A_NEW_LINE;
     }
 
 funexit:




reply via email to

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