[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_close_current), tp
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_close_current), tp/Texinfo/XS/parsetexi/close.c (close_current): use the current element returned by end_line_misc_line and end_line_starting_block, and get the parent/call close_container for each type. |
Date: |
Sun, 09 Jul 2023 17:34:45 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 864460fdd6 * tp/Texinfo/ParserNonXS.pm (_close_current),
tp/Texinfo/XS/parsetexi/close.c (close_current): use the current element
returned by end_line_misc_line and end_line_starting_block, and get the
parent/call close_container for each type.
864460fdd6 is described below
commit 864460fdd6a60d703b9a21031d81dfd1ab08dc07
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jul 9 23:34:35 2023 +0200
* tp/Texinfo/ParserNonXS.pm (_close_current),
tp/Texinfo/XS/parsetexi/close.c (close_current): use the current
element returned by end_line_misc_line and end_line_starting_block,
and get the parent/call close_container for each type.
* tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): unset parent
field of linemacro_call container in source mark.
* tp/Texinfo/ParserNonXS.pm (_close_container),
tp/Texinfo/XS/parsetexi/close.c (close_container): output a debug
message even if there are source marks.
* tp/Texinfo/Structuring.pm (sectioning_structure): change in debug
message.
---
ChangeLog | 17 ++++++++++++++
tp/Texinfo/ParserNonXS.pm | 22 ++++++++---------
tp/Texinfo/Structuring.pm | 3 ++-
tp/Texinfo/XS/parsetexi/close.c | 30 ++++++++++++++----------
tp/Texinfo/XS/parsetexi/end_line.c | 1 +
tp/t/results/coverage/bye_on_end_command_line.pl | 9 -------
tp/t/results/raw/beginning_and_end_on_line.pl | 3 ---
7 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6a9ffc936e..cbfc06aaf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2023-07-09 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_close_current),
+ tp/Texinfo/XS/parsetexi/close.c (close_current): use the current
+ element returned by end_line_misc_line and end_line_starting_block,
+ and get the parent/call close_container for each type.
+
+ * tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): unset parent
+ field of linemacro_call container in source mark.
+
+ * tp/Texinfo/ParserNonXS.pm (_close_container),
+ tp/Texinfo/XS/parsetexi/close.c (close_container): output a debug
+ message even if there are source marks.
+
+ * tp/Texinfo/Structuring.pm (sectioning_structure): change in debug
+ message.
+
2023-07-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_remove_empty_content, _close_container),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 819f6ee031..0240e5375f 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1566,6 +1566,11 @@ sub _close_container($$)
# remove element without contents nor associated information
my $element_to_remove;
if (_is_container_empty($current)) {
+ print STDERR "CONTAINER EMPTY "
+ .Texinfo::Common::debug_print_element($current, 1)
+ .' ('.($current->{'source_marks'}
+ ? scalar(@{$current->{'source_marks'}}) : 0)." source marks)\n"
+ if ($self->{'DEBUG'});
if ($current->{'source_marks'}) {
# Keep the element to keep the source mark, but remove some types.
# Keep before_item in order not to add empty table definition in
@@ -1573,9 +1578,6 @@ sub _close_container($$)
delete $current->{'type'} if ($current->{'type'} ne 'before_item');
} else {
$element_to_remove = $current;
- print STDERR "CONTAINER EMPTY "
- .Texinfo::Common::debug_print_element($current, 1)."\n"
- if ($self->{'DEBUG'});
}
}
$current = $current->{'parent'};
@@ -2063,6 +2065,7 @@ sub _close_current($$$;$$)
# remove spaces element from tree and update extra values
_abort_empty_line($self, $current);
}
+ $current = $current->{'parent'};
} elsif ($current->{'type'} eq 'balanced_braces') {
# unclosed braces in contexts accepting lone braces
$self->_command_error($current, $source_info, __("misplaced {"));
@@ -2072,20 +2075,15 @@ sub _close_current($$$;$$)
#$current = _merge_text($self, $current, '}');
my $close_brace = {'text' => '}', 'parent' => $current};
push @{$current->{'contents'}}, $close_brace;
+ $current = $current->{'parent'};
} elsif ($current->{'type'} eq 'line_arg') {
- #$current = _end_line_misc_line($self, $current, $source_info);
- # We ignore the current returned $current, to be sure that
- # we close the command too.
- # TODO if returned $current is used, tests fails, should
- # investigate why, maybe because it is redundant
- # with _close_container below?
- _end_line_misc_line($self, $current, $source_info);
+ $current = _end_line_misc_line($self, $current, $source_info);
} elsif ($current->{'type'} eq 'block_line_arg') {
- _end_line_starting_block($self, $current, $source_info);
+ $current = _end_line_starting_block($self, $current, $source_info);
} else {
+ $current = _close_container($self, $current);
print STDERR "No need of type closing function\n" if ($self->{'DEBUG'});
}
- $current = _close_container($self, $current);
} else { # Should never go here.
$current = $current->{'parent'} if ($current->{'parent'});
$self->_bug_message("No type nor cmdname when closing",
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index b885ffda17..ccfb99e02a 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -146,7 +146,8 @@ sub sectioning_structure($$$)
$level = $content->{'structure'}->{'section_level'}
= Texinfo::Common::section_level($content);
if (!defined($level)) {
- warn "bug: level not defined for $content->{'cmdname'}\n";
+ warn "bug: level not defined for $content->{'cmdname'} "
+ .Texinfo::Common::debug_print_element($content)."\n";
$level = $content->{'structure'}->{'section_level'} = 0;
}
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index 1eb52c5dcc..a900397e96 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -144,6 +144,9 @@ close_container (ELEMENT *current)
/* remove element without contents nor associated information */
if (is_container_empty (current))
{
+ debug ("CONTAINER EMPTY %s (%d source marks)",
+ print_element_debug(current, 1),
+ current->source_mark_list.number);
if (current->source_mark_list.number > 0)
{
/* Keep the element to keep the source mark, but remove some types.
@@ -153,11 +156,7 @@ close_container (ELEMENT *current)
current->type = ET_NONE;
}
else
- {
- element_to_remove = current;
- debug ("CONTAINER EMPTY %s",
- print_element_debug(current, 1));
- }
+ element_to_remove = current;
}
current = current->parent;
@@ -438,6 +437,7 @@ close_current (ELEMENT *current,
/* current = merge_text (current, "}", 0); */
text_append (&close_brace->text, "}");
add_to_element_contents (current, close_brace);
+ current = current->parent;
break;
case ET_bracketed_arg:
command_error (current, "misplaced {");
@@ -448,19 +448,18 @@ close_current (ELEMENT *current,
/* remove spaces element from tree and update extra values */
abort_empty_line (¤t, 0);
}
+ current = current->parent;
break;
case ET_line_arg:
- /* We ignore the current returned, to be sure that
- we close the command too. */
- end_line_misc_line (current);
+ current = end_line_misc_line (current);
break;
case ET_block_line_arg:
- end_line_starting_block (current);
+ current = end_line_starting_block (current);
break;
default:
+ current = close_container (current);
break;
}
- current = close_container(current);
}
else
{
@@ -509,9 +508,16 @@ close_commands (ELEMENT *current, enum command_id
closed_block_command,
/* In ignored conditional. */
close_ignored_block_conditional (current);
}
- else if (closed_block_command)
+ else
{
- line_error ("unmatched `@end %s'", command_name(closed_block_command));
+ if (closed_block_command)
+ line_error ("unmatched `@end %s'", command_name(closed_block_command));
+ if (! ((current->cmd && command_flags(current) & CF_root)
+ || (current->type == ET_before_node_section)))
+ {
+ debug ("close_commands unexpectedly stopped %s",
+ print_element_debug (current, 1));
+ }
}
return current;
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 324f399433..137fba9790 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -791,6 +791,7 @@ end_line_def_line (ELEMENT *current)
/* remove the linemacro_call container from the main tree.
The container holds the arguments Texinfo elements tree */
popped = pop_element_from_contents (current);
+ popped->parent = 0;
register_source_mark (current, macro_source_mark);
set_input_source_mark (macro_source_mark);
diff --git a/tp/t/results/coverage/bye_on_end_command_line.pl
b/tp/t/results/coverage/bye_on_end_command_line.pl
index c9e6fdb894..ecb441cf3f 100644
--- a/tp/t/results/coverage/bye_on_end_command_line.pl
+++ b/tp/t/results/coverage/bye_on_end_command_line.pl
@@ -109,15 +109,6 @@ $result_errors{'bye_on_end_command_line'} = [
'macro' => '',
'text' => '@bye should not appear in @end',
'type' => 'warning'
- },
- {
- 'error_line' => '@bye seen before @end cartouche
-',
- 'file_name' => '',
- 'line_nr' => 3,
- 'macro' => '',
- 'text' => '@bye seen before @end cartouche',
- 'type' => 'error'
}
];
diff --git a/tp/t/results/raw/beginning_and_end_on_line.pl
b/tp/t/results/raw/beginning_and_end_on_line.pl
index 912a93b017..07ef36ba3c 100644
--- a/tp/t/results/raw/beginning_and_end_on_line.pl
+++ b/tp/t/results/raw/beginning_and_end_on_line.pl
@@ -32,9 +32,6 @@ $result_trees{'beginning_and_end_on_line'} = {
],
'cmdname' => 'tex',
'contents' => [
- {
- 'type' => 'rawpreformatted'
- },
{
'args' => [
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_close_current), tp/Texinfo/XS/parsetexi/close.c (close_current): use the current element returned by end_line_misc_line and end_line_starting_block, and get the parent/call close_container for each type.,
Patrice Dumas <=