[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_o
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/separator.c (handle_comma): do not open a brace command container if the second argument if inlinefmtifelse does not exist. |
Date: |
Thu, 16 Feb 2023 04:40:28 -0500 |
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 dc8f221f63 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/separator.c (handle_comma): do not open a brace command
container if the second argument if inlinefmtifelse does not exist.
dc8f221f63 is described below
commit dc8f221f63d9ae4003aff23126478361a5f3bbc3
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Feb 16 10:40:20 2023 +0100
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/separator.c (handle_comma): do not open
a brace command container if the second argument if inlinefmtifelse
does not exist.
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): comments,
more similar code to XS parser.
---
ChangeLog | 10 +++++++
tp/Texinfo/ParserNonXS.pm | 34 +++++++++++++++-------
tp/Texinfo/XS/parsetexi/separator.c | 4 ++-
tp/t/results/converters_tests/inlinefmtifelse.pl | 5 +---
.../macro/macro_call_in_ignored_inlinefmtifelse.pl | 5 +---
5 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f9e36abac4..f43f1eb7c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-02-16 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/separator.c (handle_comma): do not open
+ a brace command container if the second argument if inlinefmtifelse
+ does not exist.
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): comments,
+ more similar code to XS parser.
+
2023-02-15 Patrice Dumas <pertusus@free.fr>
* tp/t/input_files/delcomment_followed_by_cpp_line.texi: remove
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 97df5c2b4c..c9c27604d6 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1515,6 +1515,9 @@ sub _close_brace_command($$$;$$$)
or $current->{'cmdname'} eq 'shortcaption');
}
+ # args are always set
+ #die ("$current->{'cmdname'} no args\n") if (!$current->{'args'});
+
pop @{$self->{'nesting_context'}->{'basic_inline_stack'}}
if ($self->{'basic_inline_commands'}
and $self->{'basic_inline_commands'}->{$current->{'cmdname'}});
@@ -6121,11 +6124,11 @@ sub _process_remaining_on_line($$$$)
# not followed by anything.
$self->_line_error(__("unexpected \@"), $source_info);
} elsif ($separator eq '{') {
+ # handle_open_brace in XS parser
_abort_empty_line($self, $current);
if ($current->{'cmdname'}
and defined($self->{'brace_commands'}->{$current->{'cmdname'}})) {
my $command = $current->{'cmdname'};
- $current->{'args'} = [ { 'parent' => $current } ];
if (defined($commands_args_number{$command})
and $commands_args_number{$command} > 1) {
@@ -6133,7 +6136,9 @@ sub _process_remaining_on_line($$$$)
= $commands_args_number{$command} - 1;
}
- $current = $current->{'args'}->[-1];
+ my $arg = {'parent' => $current};
+ $current->{'args'} = [$arg];
+ $current = $arg;
push @{$self->{'nesting_context'}->{'basic_inline_stack'}}, $command
if ($self->{'basic_inline_commands'}
and $self->{'basic_inline_commands'}->{$command});
@@ -6494,9 +6499,15 @@ sub _process_remaining_on_line($$$$)
} elsif ($separator eq ','
and $current->{'parent'}
and $current->{'parent'}->{'remaining_args'}) {
- _abort_empty_line ($self, $current);
+ # handle_comma in XS parser
+ _abort_empty_line($self, $current);
_isolate_last_space($self, $current);
+ # type corresponds to three possible containers: in brace commands,
+ # line of block command (float or example) or line (node).
my $type = $current->{'type'};
+ #die ("type: $type\n") if ($type ne 'brace_command_arg'
+ # and $type ne 'block_line_arg'
+ # and $type ne 'line_arg');
$current = $current->{'parent'};
if ($brace_commands{$current->{'cmdname'}}
and $brace_commands{$current->{'cmdname'}} eq 'inline') {
@@ -6506,11 +6517,11 @@ sub _process_remaining_on_line($$$$)
my $inline_type;
if (defined $current->{'args'}->[0]
and $current->{'args'}->[0]->{'contents'}
- and @{$current->{'args'}->[0]->{'contents'}}) {
+ and scalar(@{$current->{'args'}->[0]->{'contents'}})) {
$inline_type =
$current->{'args'}->[0]->{'contents'}->[0]->{'text'};
}
- if (!$inline_type) {
+ if (!defined($inline_type) or $inline_type eq '') {
# condition is missing for some reason
print STDERR "INLINE COND MISSING\n"
if ($self->{'DEBUG'});
@@ -6577,8 +6588,11 @@ sub _process_remaining_on_line($$$$)
}
}
if ($brace_count == 0) {
- # second arg missing
+ # Second argument is missing.
+ $current = $current->{'args'}->[-1];
$line = '}' . $line;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
} else {
$current->{'remaining_args'}--;
}
@@ -6589,7 +6603,7 @@ sub _process_remaining_on_line($$$$)
# Discard second argument.
$expandp = 0;
}
- # If this command is not being expanded, add a dummy argument,
+ # If this command is not being expanded, add an elided argument,
# and scan forward to the closing brace.
if (!$expandp) {
my $elided_arg_elt = {'type' => 'elided_brace_command_arg',
@@ -6635,9 +6649,9 @@ sub _process_remaining_on_line($$$$)
}
}
$current->{'remaining_args'}--;
- push @{$current->{'args'}},
- { 'type' => $type, 'parent' => $current, 'contents' => [] };
- $current = $current->{'args'}->[-1];
+ my $new_arg = { 'type' => $type, 'parent' => $current, 'contents' => []
};
+ push @{$current->{'args'}}, $new_arg;
+ $current = $new_arg;
# internal_spaces_before_argument is a transient internal type,
# which should end up in info spaces_before_argument.
push @{$current->{'contents'}},
diff --git a/tp/Texinfo/XS/parsetexi/separator.c
b/tp/Texinfo/XS/parsetexi/separator.c
index 7e6881b42d..5544d8ee9d 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -648,10 +648,12 @@ handle_comma (ELEMENT *current, char **line_inout)
line++;
}
inlinefmtifelse_done:
- /* Check if the second argument is missing. */
+ /* Second argument is missing. */
if (brace_count == 0)
{
+ current = last_args_child (current);
line--; /* on '}' */
+ goto funexit;
}
else
counter_dec (&count_remaining_args);
diff --git a/tp/t/results/converters_tests/inlinefmtifelse.pl
b/tp/t/results/converters_tests/inlinefmtifelse.pl
index 48e4213c76..d8566c9503 100644
--- a/tp/t/results/converters_tests/inlinefmtifelse.pl
+++ b/tp/t/results/converters_tests/inlinefmtifelse.pl
@@ -125,9 +125,6 @@ $result_trees{'inlinefmtifelse'} = {
}
],
'type' => 'elided_brace_command_arg'
- },
- {
- 'type' => 'brace_command_arg'
}
],
'cmdname' => 'inlinefmtifelse',
@@ -540,7 +537,7 @@ $result_trees{'inlinefmtifelse'} = {
$result_texis{'inlinefmtifelse'} = '@inlinefmtifelse{html,,else html no if}.
@inlinefmtifelse{html,if html,else html}.
-@inlinefmtifelse{plaintext,if plaintext no second arg,}.
+@inlinefmtifelse{plaintext,if plaintext no second arg}.
@inlinefmtifelse{plaintext,if plaintext,else plaintext}.
@inlinefmtifelse{xml,if xml empty second arg,}.
diff --git a/tp/t/results/macro/macro_call_in_ignored_inlinefmtifelse.pl
b/tp/t/results/macro/macro_call_in_ignored_inlinefmtifelse.pl
index c89d56cef7..73cb85e262 100644
--- a/tp/t/results/macro/macro_call_in_ignored_inlinefmtifelse.pl
+++ b/tp/t/results/macro/macro_call_in_ignored_inlinefmtifelse.pl
@@ -94,9 +94,6 @@ $result_trees{'macro_call_in_ignored_inlinefmtifelse'} = {
}
],
'type' => 'elided_brace_command_arg'
- },
- {
- 'type' => 'brace_command_arg'
}
],
'cmdname' => 'inlinefmtifelse',
@@ -128,7 +125,7 @@ $result_texis{'macro_call_in_ignored_inlinefmtifelse'} =
'@macro commafmt
before comma, after
@end macro
-Toto @inlinefmtifelse{tex, here @commafmt{} finish,} done.
+Toto @inlinefmtifelse{tex, here @commafmt{} finish} done.
';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/separator.c (handle_comma): do not open a brace command container if the second argument if inlinefmtifelse does not exist.,
Patrice Dumas <=