[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 6 Dec 2022 18:17:21 -0500 (EST) |
branch: master
commit 0009e775915d40a85ad56f1e7cb20278ae3a3aa1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Dec 7 00:13:55 2022 +0100
* tp/Texinfo/ParserNonXS.pm (_merge_text): use explicitely scalar()
for clearer code.
(_isolate_last_space, _end_line_def_line): better debugging output.
---
ChangeLog | 7 +++++++
tp/Texinfo/ParserNonXS.pm | 46 +++++++++++++++++++++++++++++++++-------------
2 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 69320633dc..e99d3b5bde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-12-06 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_merge_text): use explicitely scalar()
+ for clearer code.
+
+ (_isolate_last_space, _end_line_def_line): better debugging output.
+
2022-12-06 Patrice Dumas <pertusus@free.fr>
* tp/t/01use.t: update tree. Do not use 'use vars'.
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 847325b31c..097f55690a 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2029,7 +2029,7 @@ sub _merge_text {
if ($text =~ /^(\s+)/) {
$leading_spaces = $1;
}
- if ($current->{'contents'} and @{$current->{'contents'}}
+ if ($current->{'contents'} and scalar(@{$current->{'contents'}})
and $current->{'contents'}->[-1]->{'type'}
and ($current->{'contents'}->[-1]->{'type'} eq
'ignorable_spaces_after_command'
or $current->{'contents'}->[-1]->{'type'} eq
'internal_spaces_after_command'
@@ -2046,17 +2046,12 @@ sub _merge_text {
}
if (!defined($current->{'contents'})) {
- # this can happen for preformatted since they do not have an initialized
- # contents to match better the XS parser
- #$self->_bug_message("No contents in _merge_text",
- # undef, $current);
- #cluck;
- #die;
+ # this can happen at least for preformatted.
$current->{'contents'} = [];
}
if (!$no_merge_with_following_text
- and @{$current->{'contents'}}
+ and scalar(@{$current->{'contents'}})
and exists($current->{'contents'}->[-1]->{'text'})
and $current->{'contents'}->[-1]->{'text'} !~ /\n/) {
$current->{'contents'}->[-1]->{'text'} .= $text;
@@ -2503,14 +2498,36 @@ sub _isolate_last_space
# as this would be difficult to implement properly in TeX.
}
- return if !$current->{'contents'}
+ my $debug_str;
+ if ($self->{'DEBUG'}) {
+ $debug_str = 'p: '
+ .Texinfo::Common::debug_print_element_short($current)."; c ";
+ if (scalar(@{$current->{'contents'}})) {
+ if ($current->{'contents'}->[-1]->{'type'}) {
+ $debug_str .= "($current->{'contents'}->[-1]->{'type'})";
+ }
+ if (defined($current->{'contents'}->[-1]->{'text'})) {
+ $debug_str .= "[T: $current->{'contents'}->[-1]->{'text'}]";
+ }
+ }
+ $debug_str .= "\n";
+ }
+
+ if (!$current->{'contents'}
or !scalar(@{$current->{'contents'}})
or !defined($current->{'contents'}->[-1]->{'text'})
or ($current->{'contents'}->[-1]->{'type'}
and (!$current->{'type'}
or ($current->{'type'} ne 'line_arg'
and $current->{'type'} ne 'block_line_arg')))
- or $current->{'contents'}->[-1]->{'text'} !~ /\s+$/;
+ or $current->{'contents'}->[-1]->{'text'} !~ /\s+$/) {
+ print STDERR "NOT ISOLATING ".$debug_str
+ if ($self->{'DEBUG'});
+ return;
+ }
+
+ print STDERR "ISOLATE SPACE ".$debug_str
+ if ($self->{'DEBUG'});
if ($current->{'type'} and $current->{'type'} eq 'menu_entry_node') {
_isolate_trailing_space($current, 'space_at_end_menu_node');
@@ -3269,11 +3286,14 @@ sub _end_line_def_line($$$)
$self->_pop_context(['ct_def'], $source_info, $current);
my $def_command = $current->{'parent'}->{'extra'}->{'def_command'};
- print STDERR "END DEF LINE: $def_command\n"
- if ($self->{'DEBUG'});
- # in case there are no arguments at all, it needs to be called here.
+
+ print STDERR "END DEF LINE $def_command; current: "
+ .Texinfo::Common::debug_print_element_short($current)."\n"
+ if ($self->{'DEBUG'});
+
_abort_empty_line($self, $current);
_isolate_last_space($self, $current);
+
my $arguments = _parse_def($self, $def_command, $current);
if (scalar(@$arguments)) {
#$current->{'parent'}->{'extra'}->{'def_args'} = $arguments;