texinfo-commits
[Top][All Lists]
Advanced

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

[6819] parsetexi update (line numbers)


From: Gavin D. Smith
Subject: [6819] parsetexi update (line numbers)
Date: Tue, 01 Dec 2015 11:30:19 +0000

Revision: 6819
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6819
Author:   gavin
Date:     2015-12-01 11:30:16 +0000 (Tue, 01 Dec 2015)
Log Message:
-----------
parsetexi update (line numbers)

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/api.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/handle_commands.c
    trunk/parsetexi/input.c
    trunk/parsetexi/input.h

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2015-11-30 18:43:06 UTC (rev 6818)
+++ trunk/parsetexi/ChangeLog   2015-12-01 11:30:16 UTC (rev 6819)
@@ -1,3 +1,8 @@
+2015-12-01  Gavin Smith  <address@hidden>
+
+       * api.c (parse_text): Use new function input_push_text_with_line_nos
+       to keep track of line numbers (for tests).
+
 2015-11-30  Gavin Smith  <address@hidden>
  
        * Parsetexi/lib/Parsetexi.pm (parser): Set conf keys on parser 

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-11-30 18:43:06 UTC (rev 6818)
+++ trunk/parsetexi/api.c       2015-12-01 11:30:16 UTC (rev 6819)
@@ -69,7 +69,7 @@
   ELEMENT *root;
   init_index_commands (); /* FIXME - probably not necessary */
   root = new_element (ET_text_root);
-  input_push_text (strdup (string));
+  input_push_text_with_line_nos (strdup (string));
   Root = parse_texi (root);
 }
 
@@ -449,6 +449,8 @@
         {
           STORE("file_name", newSVpv (line_nr->file_name, 0));
         }
+      else
+        STORE("file_name", newSVpv ("", 0));
 
       if (line_nr->line_nr)
         {

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-11-30 18:43:06 UTC (rev 6818)
+++ trunk/parsetexi/end_line.c  2015-12-01 11:30:16 UTC (rev 6819)
@@ -762,13 +762,9 @@
 end_line_starting_block (ELEMENT *current)
 {
   enum context c;
-  // pop and check context_stack
   c = pop_context ();
   if (c != ct_line)
-    {
-      // bug
-      abort ();
-    }
+    abort ();
 
   // 2881
   if (current->parent->cmd == CM_multitable)
@@ -844,6 +840,14 @@
 
   if (current->parent->cmd == CM_float) // 2943
     {
+      current->parent->line_nr = line_nr;
+      if (current->parent->args.number > 0)
+        {
+          if (current->parent->args.number > 1)
+            {
+              // TODO 2950
+            }
+        }
     }
   current = current->parent; //2965
   //counter_pop (&count_remaining_args);

Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c   2015-11-30 18:43:06 UTC (rev 6818)
+++ trunk/parsetexi/handle_commands.c   2015-12-01 11:30:16 UTC (rev 6819)
@@ -534,9 +534,11 @@
           push_context (ct_def);
           block = new_element (ET_NONE);
           block->cmd = cmd;
+          block->line_nr = line_nr;
           add_to_element_contents (current, block);
           current = block;
           def_line = new_element (ET_def_line);
+          def_line->line_nr = line_nr;
           add_to_element_contents (current, def_line);
           current = def_line;
           add_extra_string (current, "def_command", command_name(cmd));
@@ -549,6 +551,7 @@
           ELEMENT *block = new_element (ET_NONE);
 
           block->cmd = cmd;
+          block->line_nr = line_nr;
           add_to_element_contents (current, block);
           current = block;
         }

Modified: trunk/parsetexi/input.c
===================================================================
--- trunk/parsetexi/input.c     2015-11-30 18:43:06 UTC (rev 6818)
+++ trunk/parsetexi/input.c     2015-12-01 11:30:16 UTC (rev 6819)
@@ -111,6 +111,9 @@
           else
             i->ptext = p; /* The next time, we will pop the input source. */
           return new;
+
+          if (line_nr.line_nr != 0)
+              line_nr.line_nr++;
           // what if it doesn't end in a newline ?
 
           break;
@@ -207,6 +210,16 @@
      a macro expansion, or was pushed back when reading the file preamble. */
 }
 
+/* Used in tests - like input_push_text, but the lines from the text have
+   line numbers. */
+void
+input_push_text_with_line_nos (char *text)
+{
+  input_push_text (text);
+  line_nr.line_nr = 1;
+  line_nr.file_name = 0;
+}
+
 
 static char **include_dirs;
 static size_t include_dirs_number;

Modified: trunk/parsetexi/input.h
===================================================================
--- trunk/parsetexi/input.h     2015-11-30 18:43:06 UTC (rev 6818)
+++ trunk/parsetexi/input.h     2015-12-01 11:30:16 UTC (rev 6819)
@@ -4,6 +4,7 @@
 char *next_text (void);
 
 void input_push_text (char *line);
+void input_push_text_with_line_nos (char *text);
 void input_push_file (char *filename);
 
 extern LINE_NR line_nr;




reply via email to

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