[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 1 Apr 2023 13:07:48 -0400 (EDT) |
branch: master
commit b01d2986f89d1299d8b24e37b220fd8181dcf6c7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Apr 1 19:06:09 2023 +0200
* tp/Texinfo/ParserNonXS.pm (_parse_texi),
tp/Texinfo/XS/parsetexi/context_stack.c (in_context),
tp/Texinfo/XS/parsetexi/parser.c (parse_texi): if in a linemacro
command expansion at the end of input, call end_line to get new input
corresponding to the linemacro command expansion.
---
ChangeLog | 8 ++++++++
tp/Texinfo/ParserNonXS.pm | 15 +++++++++++++--
tp/Texinfo/XS/parsetexi/context_stack.c | 31 +++++++++++++++++++++++--------
tp/Texinfo/XS/parsetexi/context_stack.h | 3 ++-
tp/Texinfo/XS/parsetexi/parser.c | 16 ++++++++++++++--
tp/t/65linemacro.t | 28 ++++++++++++++++++++++++++++
6 files changed, 88 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bb50a63c70..48f6abd187 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-04-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_parse_texi),
+ tp/Texinfo/XS/parsetexi/context_stack.c (in_context),
+ tp/Texinfo/XS/parsetexi/parser.c (parse_texi): if in a linemacro
+ command expansion at the end of input, call end_line to get new input
+ corresponding to the linemacro command expansion.
+
2023-03-28 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_end_line),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 07a9e03fae..b5bc490685 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -7055,10 +7055,20 @@ sub _parse_texi($$$)
($line, $source_info) = _next_text($self, $current);
if (!defined($line)) {
print STDERR "NEXT_LINE NO MORE\n" if ($self->{'DEBUG'});
+ # if we are in a linemacro command expansion and at the end
+ # of input, there may actually be more input after the expansion.
+ # So we call _end_line to trigger the expansion.
+ my @context_stack = $self->_get_context_stack;
+ foreach my $context (@context_stack) {
+ if ($context eq 'ct_linecommand') {
+ $current = _end_line($self, $current, $source_info);
+ next NEXT_LINE;
+ }
+ }
last;
}
-#print STDERR
"@{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}}|$line"
-#if ($self->{'nesting_context'} and
$self->{'nesting_context'}->{'basic_inline_stack_on_line'});
+ #print STDERR
"@{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}}|$line"
+ #if ($self->{'nesting_context'} and
$self->{'nesting_context'}->{'basic_inline_stack_on_line'});
if ($self->{'DEBUG'}) {
my $source_info_text = '';
@@ -7117,6 +7127,7 @@ sub _parse_texi($$$)
($current, $line, $source_info, $status)
= _process_remaining_on_line($self, $current, $line, $source_info);
if ($status == $GET_A_NEW_LINE) {
+ print STDERR "GET_A_NEW_LINE\n" if ($self->{'DEBUG'});
last;
} elsif ($status == $FINISHED_TOTALLY) {
print STDERR "FINISHED_TOTALLY\n" if ($self->{'DEBUG'});
diff --git a/tp/Texinfo/XS/parsetexi/context_stack.c
b/tp/Texinfo/XS/parsetexi/context_stack.c
index 0a7d07a8a2..dc5c87d883 100644
--- a/tp/Texinfo/XS/parsetexi/context_stack.c
+++ b/tp/Texinfo/XS/parsetexi/context_stack.c
@@ -71,6 +71,20 @@ top_command (COMMAND_STACK *stack)
return stack->stack[stack->top - 1];
}
+enum command_id
+current_context_command (void)
+{
+ int i;
+
+ if (top == 0)
+ return CM_NONE;
+ for (i = top -1; i >= 0; i--)
+ {
+ if (command_stack.stack[i] != CM_NONE)
+ return command_stack.stack[i];
+ }
+ return CM_NONE;
+}
/* Context stacks */
@@ -93,6 +107,7 @@ push_context (enum context c, enum command_id cmd)
: c == ct_line ? "line"
: c == ct_def ? "def"
: c == ct_brace_command ? "brace_command"
+ : c == ct_linecommand ? "linemacro_command"
: "", command_name(cmd));
context_stack[top] = c;
top++;
@@ -121,22 +136,22 @@ current_context (void)
return context_stack[top - 1];
}
-enum command_id
-current_context_command (void)
+int
+in_context (enum context context)
{
int i;
if (top == 0)
- return CM_NONE;
- for (i = top -1; i >= 0; i--)
+ return 0;
+
+ for (i = 0; i < top; i++)
{
- if (command_stack.stack[i] != CM_NONE)
- return command_stack.stack[i];
+ if (context_stack[i] == context)
+ return 1;
}
- return CM_NONE;
+ return 0;
}
-
/* Command nesting context. */
diff --git a/tp/Texinfo/XS/parsetexi/context_stack.h
b/tp/Texinfo/XS/parsetexi/context_stack.h
index e218483b5e..db111b2007 100644
--- a/tp/Texinfo/XS/parsetexi/context_stack.h
+++ b/tp/Texinfo/XS/parsetexi/context_stack.h
@@ -42,8 +42,8 @@ enum context {
void push_context (enum context c, enum command_id cmd);
enum context pop_context (void);
enum context current_context (void);
-enum command_id current_context_command (void);
void reset_context_stack (void);
+int in_context (enum context context);
@@ -58,6 +58,7 @@ void reset_command_stack (COMMAND_STACK *stack);
void push_command (COMMAND_STACK *stack, enum command_id cmd);
enum command_id pop_command (COMMAND_STACK *stack);
enum command_id top_command (COMMAND_STACK *stack);
+enum command_id current_context_command (void);
/* Used to check indirect nesting, e.g. @footnote{@emph{@footnote{...}}} */
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 7200a75686..bc2a9b6f91 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2435,7 +2435,19 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
free (allocated_line);
line = allocated_line = next_text (current);
if (!allocated_line)
- break; /* Out of input. */
+ {
+ if (in_context (ct_linecommand))
+ {
+ /*
+ if we are in a linemacro command expansion and at the end
+ of input, there may actually be more input after the expansion.
+ So we call end_line to trigger the expansion.
+ */
+ current = end_line (current);
+ continue;
+ }
+ break; /* Out of input. */
+ }
debug_nonl ("NEW LINE %s", line);
@@ -2560,7 +2572,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
fprintf (stderr, "BUG: at end, value_expansion_nr > 0: %d\n",
value_expansion_nr);
if (input_number > 0)
- fprintf (stderr, "BUG: at end, input_number > 0: %d", input_number);
+ fprintf (stderr, "BUG: at end, input_number > 0: %d\n", input_number);
return current;
}
diff --git a/tp/t/65linemacro.t b/tp/t/65linemacro.t
index 9566927cd2..5d020054ab 100644
--- a/tp/t/65linemacro.t
+++ b/tp/t/65linemacro.t
@@ -13,6 +13,34 @@ my @test_cases = (
@nospace X Y Z
'],
+['brace_command_not_closed',
+'@linemacro mycommand {a, b, c}
+\a\, \b\ \c\
+@end linemacro
+
+@mycommand @code{in code
+
+'],
+['verb_not_closed',
+'@linemacro mycommand {a, b, c}
+\a\, \b\ \c\
+@end linemacro
+
+@mycommand @verb{: in verb
+
+'],
+['paragraph_no_paragraph',
+'@linemacro mycommand {a, b, c}
+\a\, \b\ \c\
+@end linemacro
+
+@* @mycommand @anchor{aa} definite and @code{more}
+
+Some text @mycommand {a
+ protected} in @var{the
+ call}
+and after.
+'],
['missing_formal_arg',
'@linemacro mymacro {a, , b}
\a\ and \b\.