[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8313] parsetexi close_command_cleanup
From: |
gavinsmith0123 |
Subject: |
[8313] parsetexi close_command_cleanup |
Date: |
Wed, 17 Oct 2018 09:11:07 -0400 (EDT) |
Revision: 8313
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8313
Author: gavin
Date: 2018-10-17 09:11:07 -0400 (Wed, 17 Oct 2018)
Log Message:
-----------
parsetexi close_command_cleanup
Modified Paths:
--------------
trunk/tp/Texinfo/XS/parsetexi/close.c
Modified: trunk/tp/Texinfo/XS/parsetexi/close.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/close.c 2018-10-17 12:35:54 UTC (rev
8312)
+++ trunk/tp/Texinfo/XS/parsetexi/close.c 2018-10-17 13:11:07 UTC (rev
8313)
@@ -80,7 +80,6 @@
return current;
}
-// 1512
void
close_command_cleanup (ELEMENT *current)
{
@@ -87,7 +86,6 @@
if (!current->cmd)
return;
- // 1520
if (current->cmd == CM_multitable)
{
int in_head_or_rows = -1, i;
@@ -158,7 +156,6 @@
gather_previous_item (current, 0);
}
- // 1570
/* Block commands that contain @item's - e.g. @multitable, @table,
@itemize. */
if (command_data(current->cmd).flags & CF_blockitem
@@ -166,7 +163,7 @@
{
int have_leading_spaces = 0;
ELEMENT *before_item;
- if (current->contents.number >= 0
+ if (current->contents.number >= 2
&& current->contents.list[0]->type == ET_empty_line_after_command
&& current->contents.list[1]->type == ET_before_item)
{
@@ -173,76 +170,72 @@
have_leading_spaces = 1;
before_item = current->contents.list[1];
}
- else
+ else if (current->contents.number >= 1
+ && current->contents.list[0]->type == ET_before_item)
{
before_item = current->contents.list[0];
- /* TODO: before_item is ELEMENT or ELEMENT * ? */
}
- /* Perl code here checks if before_item exists, but it already assumed
- that it existed by accessing 'type' key on it. */
-
- // 1585
- /* Reparent @end from a ET_before_item to the block command */
- {
- KEY_PAIR *k = lookup_extra (current, "end_command");
- ELEMENT *e = k ? k->value : 0;
- if (k && last_contents_child (before_item)
- && last_contents_child (before_item) == e)
+ if (before_item)
{
- add_to_element_contents (current,
- pop_element_from_contents (before_item));
- }
- }
+ /* Reparent @end from a ET_before_item to the block command */
+ KEY_PAIR *k = lookup_extra (current, "end_command");
+ ELEMENT *e = k ? k->value : 0;
+ if (k && last_contents_child (before_item)
+ && last_contents_child (before_item) == e)
+ {
+ add_to_element_contents (current,
+ pop_element_from_contents (before_item));
+ }
- /* Now if the ET_before_item is empty, remove it. */
- if (before_item->contents.number == 0)
- {
- destroy_element (remove_from_contents (current,
- have_leading_spaces ? 1 : 0));
- }
- else /* Non-empty ET_before_item */
- {
- int empty_before_item = 1, i;
- /* Check if contents consist soley of @comment's. */
- for (i = 0; i < before_item->contents.number; i++)
+ /* Now if the ET_before_item is empty, remove it. */
+ if (before_item->contents.number == 0)
{
- enum command_id c = before_item->contents.list[i]->cmd;
- if (c != CM_c && c != CM_comment)
+ destroy_element (remove_from_contents (current,
+ have_leading_spaces ? 1 : 0));
+ }
+ else /* Non-empty ET_before_item */
+ {
+ int empty_before_item = 1, i;
+ /* Check if contents consist soley of @comment's. */
+ for (i = 0; i < before_item->contents.number; i++)
{
- empty_before_item = 0;
+ enum command_id c = before_item->contents.list[i]->cmd;
+ if (c != CM_c && c != CM_comment)
+ {
+ empty_before_item = 0;
+ }
}
- }
- if (!empty_before_item)
- {
- int empty_format = 1;
- /* Check for an element that could represent an @item in the
- block. The type of this element will depend on the block
- command we are in. */
- for (i = 0; i < current->contents.number; i++)
+ if (!empty_before_item)
{
- ELEMENT *e = current->contents.list[i];
- if (e == before_item)
- continue;
- if (e->cmd != CM_NONE
- && (e->cmd != CM_c && e->cmd != CM_comment
- && e->cmd != CM_end)
- || e->type != CM_NONE
- && e->type != ET_empty_line_after_command)
+ int empty_format = 1;
+ /* Check for an element that could represent an @item in the
+ block. The type of this element will depend on the block
+ command we are in. */
+ for (i = 0; i < current->contents.number; i++)
{
- empty_format = 0;
- break;
+ ELEMENT *e = current->contents.list[i];
+ if (e == before_item)
+ continue;
+ if (e->cmd != CM_NONE
+ && (e->cmd != CM_c && e->cmd != CM_comment
+ && e->cmd != CM_end)
+ || e->type != CM_NONE
+ && e->type != ET_empty_line_after_command)
+ {
+ empty_format = 0;
+ break;
+ }
}
+
+ if (empty_format)
+ command_warn (current, "@%s has text but no @item",
+ command_name(current->cmd));
}
-
- if (empty_format)
- command_warn (current, "@%s has text but no @item",
- command_name(current->cmd));
}
}
-
- } // 1635
+ }
}
/* 1642 */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8313] parsetexi close_command_cleanup,
gavinsmith0123 <=