texinfo-commits
[Top][All Lists]
Advanced

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

[7127] parsetexi check_no_text


From: Gavin D. Smith
Subject: [7127] parsetexi check_no_text
Date: Sun, 24 Apr 2016 11:14:31 +0000

Revision: 7127
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7127
Author:   gavin
Date:     2016-04-24 11:14:30 +0000 (Sun, 24 Apr 2016)
Log Message:
-----------
parsetexi check_no_text

Modified Paths:
--------------
    trunk/tp/parsetexi/handle_commands.c
    trunk/tp/parsetexi/multitable.c

Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c        2016-04-24 10:30:48 UTC (rev 
7126)
+++ trunk/tp/parsetexi/handle_commands.c        2016-04-24 11:14:30 UTC (rev 
7127)
@@ -41,6 +41,48 @@
   return 0;
 }
 
+// 1352
+/* Check that there are no text holding environments (currently
+   checking only paragraphs and preformatted) in contents. */
+static int
+check_no_text (ELEMENT *current)
+{
+  int after_paragraph = 0;
+  int i, j;
+  for (i = 0; i < current->contents.number; i++)
+    {
+      enum element_type t;
+      ELEMENT *f;
+      f = current->contents.list[i];
+      t = f->type;
+      if (t == ET_paragraph)
+        {
+          after_paragraph = 1;
+          break;
+        }
+      else if (t == ET_preformatted
+               || t == ET_rawpreformatted)
+        {
+          for (j = 0; j < f->contents.number; j++)
+            {
+              ELEMENT *g = f->contents.list[j];
+              if ((g->text.end > 0
+                   && g->text.text[strspn (g->text.text, whitespace_chars)])
+                  || (g->cmd && g->cmd != CM_c
+                      && g->cmd != CM_comment
+                      && g->type != ET_index_entry_command))
+                {
+                  after_paragraph = 1;
+                  break;
+                }
+            }
+          if (after_paragraph)
+            break;
+        }
+    }
+  return after_paragraph;
+}
+
 // 1056
 /* Record the information from a command of global effect. */
 static int
@@ -395,6 +437,7 @@
               enum command_id base_command;
               char *base_name;
               int base_len;
+              int after_paragraph;
 
               /* Find the command with "x" stripped from the end, e.g.
                  deffnx -> deffn. */
@@ -411,7 +454,7 @@
                 abort ();
               add_extra_string (misc, "def_command", base_name);
 
-              //check_no_text ();
+              after_paragraph = check_no_text (current);
               push_context (ct_def);
               misc->type = ET_def_line; // 4553
               if (current->cmd == base_command)
@@ -422,10 +465,10 @@
                   gather_def_item (current, cmd);
                   add_to_element_contents (current, e);
                 }
-              else
+              if (current->cmd != base_command || after_paragraph)
                 {
                   // error - deffnx not after deffn
-                  line_error ("must be after @%s to use @%s",
+                  line_error ("must be after address@hidden' to use 
address@hidden'",
                                command_name(base_command),
                                command_name(cmd));
                   add_extra_string (misc, "not_after_command", "1");

Modified: trunk/tp/parsetexi/multitable.c
===================================================================
--- trunk/tp/parsetexi/multitable.c     2016-04-24 10:30:48 UTC (rev 7126)
+++ trunk/tp/parsetexi/multitable.c     2016-04-24 11:14:30 UTC (rev 7127)
@@ -127,12 +127,10 @@
     }
   else /* Gathering ET_inter_item between @item and @itemx */ // 1457
     {
-      /* TODO
-      // Text between @item and @itemx is only allowed in a few cases:
-      // comments, empty lines, or index entries
+      /* Text between @item and @itemx is only allowed in a few cases:
+         comments, empty lines, or index entries. */
       if (check_no_text (gathered))
         line_error ("@itemx must follow @item");
-      */
 
       if (gathered->contents.number > 0)
         add_to_element_contents (current, gathered);




reply via email to

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