[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/parser.c (raw_block_stack_top) (process_remaining_on_line): use the stack of raw block commands to determine the matching end of nested raw block command. |
Date: |
Mon, 02 Jan 2023 14:58:17 -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 b0ba570552 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/parser.c (raw_block_stack_top)
(process_remaining_on_line): use the stack of raw block commands to determine
the matching end of nested raw block command.
b0ba570552 is described below
commit b0ba570552213c485f407faa92d782bb2d82493d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jan 2 20:58:00 2023 +0100
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/parser.c (raw_block_stack_top)
(process_remaining_on_line): use the stack of raw block commands to
determine the matching end of nested raw block command.
* tp/Makefile.tres, tp/t/60macro.t: add simple_imbricated_macro_rmacro
test.
* tp/t/input_files/glossary.texi: use empty braces for calls of macros
without arguments.
---
ChangeLog | 13 ++
tp/Makefile.tres | 1 +
tp/Texinfo/ParserNonXS.pm | 7 +-
tp/Texinfo/XS/parsetexi/parser.c | 131 ++++++++------
tp/t/60macro.t | 52 ++----
tp/t/input_files/glossary.texi | 4 +-
tp/t/results/formatting/glossary.pl | 12 +-
.../macro/simple_imbricated_macro_rmacro.pl | 196 +++++++++++++++++++++
8 files changed, 315 insertions(+), 101 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cd5eff9cc6..b31722ff55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-01-02 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/parser.c (raw_block_stack_top)
+ (process_remaining_on_line): use the stack of raw block commands to
+ determine the matching end of nested raw block command.
+
+ * tp/Makefile.tres, tp/t/60macro.t: add simple_imbricated_macro_rmacro
+ test.
+
+ * tp/t/input_files/glossary.texi: use empty braces for calls of macros
+ without arguments.
+
2023-01-02 Patrice Dumas <pertusus@free.fr>
* tp/Makefile.am (test_files), tp/Makefile.tres,
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 69d7ba50ac..73977312b5 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1485,6 +1485,7 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/macro/recursive_call_in_macro.pl \
t/results/macro/redefine_texinfo_macro.pl \
t/results/macro/simple_imbricated_macro.pl \
+ t/results/macro/simple_imbricated_macro_rmacro.pl \
t/results/macro/space_macro_after_end.pl \
t/results/macro/space_macro_after_end_verbatim.pl \
t/results/macro/text_before_after.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 153e1254bc..d3e5484fc5 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4141,10 +4141,13 @@ sub _process_remaining_on_line($$$$)
or ($current->{'cmdname'} eq 'ignore'
and $line =~ /^\s*\@(ignore)(\@|\s+)/)) {
push @{$self->{'raw_block_stack'}}, $1;
- print STDERR "RAW SECOND LEVEL \@$current->{'cmdname'}\n"
+ print STDERR "RAW SECOND LEVEL $1 in \@$current->{'cmdname'}\n"
if ($self->{'DEBUG'});
} elsif ($line =~ /^(\s*?)\@end\s+([a-zA-Z][\w-]*)/
- and ($2 eq $current->{'cmdname'})) {
+ and ((scalar(@{$self->{'raw_block_stack'}}) > 0
+ and $2 eq $self->{'raw_block_stack'}->[-1])
+ or (scalar(@{$self->{'raw_block_stack'}}) == 0
+ and $2 eq $current->{'cmdname'}))) {
if (scalar(@{$self->{'raw_block_stack'}}) == 0) {
if ($line =~ s/^(\s+)//) {
push @{$current->{'contents'}},
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index b69b958e45..3e2e534717 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -192,6 +192,15 @@ pop_raw_block_stack (void)
return CM_NONE;
return raw_block_stack[--raw_block_number];
}
+
+enum command_id
+raw_block_stack_top (void)
+{
+ if (raw_block_number == 0)
+ return CM_NONE;
+ return raw_block_stack[raw_block_number-1];
+}
+
/* Counters */
COUNTER count_remaining_args;
@@ -1186,75 +1195,89 @@ process_remaining_on_line (ELEMENT **current_inout,
char **line_inout)
push_raw_block_stack (cmd);
}
/* Else check if line is "@end ..." for current command. */
- else if (is_end_current_command (current, &p, &end_cmd))
+ else
{
- if (raw_block_number == 0)
+ ELEMENT *top_stack_raw_element;
+ enum command_id top_stack_cmd = raw_block_stack_top ();
+ if (top_stack_cmd == CM_NONE)
{
- ELEMENT *e;
-
- if (strchr (whitespace_chars, *line))
+ top_stack_raw_element = current;
+ }
+ else
+ {
+ top_stack_raw_element = new_element (ET_NONE);
+ top_stack_raw_element->cmd = top_stack_cmd;
+ }
+ if (is_end_current_command (top_stack_raw_element, &p, &end_cmd))
+ {
+ if (raw_block_number == 0)
{
ELEMENT *e;
- int n = strspn (line, whitespace_chars);
- e = new_element (ET_raw);
- text_append_n (&e->text, line, n);
- add_to_element_contents (current, e);
- line += n;
- line_warn ("@end %s should only appear at the "
- "beginning of a line", command_name(end_cmd));
- }
- /* For macros, define a new macro. */
- if (end_cmd == CM_macro || end_cmd == CM_rmacro)
- {
- char *name;
- enum command_id existing;
- if (current->args.number > 0)
+ if (strchr (whitespace_chars, *line))
{
- name = element_text (args_child_by_index (current, 0));
-
- existing = lookup_command (name);
- if (existing)
+ ELEMENT *e;
+ int n = strspn (line, whitespace_chars);
+ e = new_element (ET_raw);
+ text_append_n (&e->text, line, n);
+ add_to_element_contents (current, e);
+ line += n;
+ line_warn ("@end %s should only appear at the "
+ "beginning of a line", command_name(end_cmd));
+ }
+ /* For macros, define a new macro. */
+ if (end_cmd == CM_macro || end_cmd == CM_rmacro)
+ {
+ char *name;
+ enum command_id existing;
+ if (current->args.number > 0)
{
- MACRO *macro;
- macro = lookup_macro (existing);
- if (macro)
+ name = element_text (args_child_by_index (current,
0));
+
+ existing = lookup_command (name);
+ if (existing)
{
- line_error_ext (1, ¤t->source_info,
- "macro `%s' previously defined", name);
- line_error_ext (1, ¯o->element->source_info,
- "here is the previous definition of `%s'",
name);
+ MACRO *macro;
+ macro = lookup_macro (existing);
+ if (macro)
+ {
+ line_error_ext (1, ¤t->source_info,
+ "macro `%s' previously defined", name);
+ line_error_ext (1,
¯o->element->source_info,
+ "here is the previous definition of
`%s'", name);
+ }
+ else if (!(existing & USER_COMMAND_BIT))
+ {
+ line_error_ext (1, ¤t->source_info,
+ "redefining Texinfo language command: @%s",
+ name);
+ }
}
- else if (!(existing & USER_COMMAND_BIT))
+ if (!lookup_extra (current, "invalid_syntax"))
{
- line_error_ext (1, ¤t->source_info,
- "redefining Texinfo language command: @%s",
- name);
+ new_macro (name, current);
}
}
- if (!lookup_extra (current, "invalid_syntax"))
- {
- new_macro (name, current);
- }
}
- }
- debug ("CLOSED raw %s", command_name(end_cmd));
- /* start a new line for the @end line (without the first spaces on
- the line that have already been put in a raw container).
- This is normally done at the beginning of a line, but not here,
- as we directly got the line. As the @end is processed just
below,
- an empty line will not appear in the output, but it is needed
to
- avoid a duplicate warning on @end not appearing at the
beginning
- of the line */
- e = new_element (ET_empty_line);
- add_to_element_contents (current, e);
+ debug ("CLOSED raw %s", command_name(end_cmd));
+ /* start a new line for the @end line (without the first
spaces on
+ the line that have already been put in a raw container).
+ This is normally done at the beginning of a line, but not
here,
+ as we directly got the line. As the @end is processed
just below,
+ an empty line will not appear in the output, but it is
needed to
+ avoid a duplicate warning on @end not appearing at the
beginning
+ of the line */
+ e = new_element (ET_empty_line);
+ add_to_element_contents (current, e);
- closed_nested_raw = 1;
+ closed_nested_raw = 1;
+ }
+ else
+ pop_raw_block_stack();
}
- else
- pop_raw_block_stack();
+ if (top_stack_cmd != CM_NONE)
+ destroy_element (top_stack_raw_element);
}
-
/* save the line verbatim */
if (! closed_nested_raw)
{
@@ -1614,7 +1637,7 @@ superfluous_arg:
retval = STILL_MORE_TO_PROCESS;
goto funexit;
}
-
+
/* Brace commands not followed immediately by a brace
opening. In particular cases that may lead to "command closing"
or following character association with an @-command, for accent
diff --git a/tp/t/60macro.t b/tp/t/60macro.t
index b40d035342..7965ea8b42 100644
--- a/tp/t/60macro.t
+++ b/tp/t/60macro.t
@@ -434,6 +434,18 @@ bidule.
@truc{}
+@bidule{}
+'],
+['simple_imbricated_macro_rmacro',
+'@macro truc {}
+truc.
+@rmacro bidule {}
+bidule.
+@end rmacro
+@end macro
+
+@truc{}
+
@bidule{}
'],
['macro_in_macro_arg','
@@ -1019,44 +1031,10 @@ X\arg\X
@include inc_file.texi
'],
);
-
-my @todo =(
+my @todo = (
['glossary',
-'@macro glossarytext
-@table @asis
-@end macro
-
-@macro glossary
-@glossarytext{}
-@end table
-
-@end macro
-
-@macro gentry {id, name, text}
-@ifhtml
-@ref{\id\,\name\}
-@end ifhtml
-@ifnothtml
-\name\ (@pxref{\id\})
-@end ifnothtml
-@unmacro expandglossary
-@macro expandglossary{glossary}
-@unmacro glossarytext
-@macro glossarytext
-\\\\glossary\\\\
-@item \name\ @anchor{\id\}
-\text\
-@end macro
-@end macro
-@expandglossary {@glossarytext{}}
-
-@end macro
-
-The @gentry{id1, name1, text1\, arg1 } is used in many cases while
-@gentry{id2, name2, text2} is quite specific
-
-@glossary{}
-']
+undef, {'test_file' => 'glossary.texi'},
+],
);
diff --git a/tp/t/input_files/glossary.texi b/tp/t/input_files/glossary.texi
index 718c391867..fd3208655c 100644
--- a/tp/t/input_files/glossary.texi
+++ b/tp/t/input_files/glossary.texi
@@ -28,7 +28,7 @@
\text\
@end macro
@end macro
-@expandglossary {@glossarytext}
+@expandglossary {@glossarytext{}}
@end macro
@@ -44,5 +44,5 @@ The @gentry{id1, name1, text1\, arg1 } is used in many cases
while
@node glossary
@chapter glossary
-@glossary
+@glossary{}
diff --git a/tp/t/results/formatting/glossary.pl
b/tp/t/results/formatting/glossary.pl
index 84161fbe01..a19b6e5a19 100644
--- a/tp/t/results/formatting/glossary.pl
+++ b/tp/t/results/formatting/glossary.pl
@@ -287,7 +287,7 @@ $result_trees{'glossary'} = {
'type' => 'raw'
},
{
- 'text' => '@expandglossary {@glossarytext}
+ 'text' => '@expandglossary {@glossarytext{}}
',
'type' => 'raw'
},
@@ -679,7 +679,7 @@ $result_trees{'glossary'} = {
'cmdname' => 'macro',
'contents' => [
{
- 'text' => '@glossarytext
+ 'text' => '@glossarytext{}
',
'type' => 'raw'
},
@@ -926,7 +926,7 @@ $result_trees{'glossary'} = {
'cmdname' => 'macro',
'contents' => [
{
- 'text' => '@glossarytext
+ 'text' => '@glossarytext{}
',
'type' => 'raw'
},
@@ -1150,7 +1150,7 @@ $result_texis{'glossary'} = '\\input texinfo.tex
\\text\\
@end macro
@end macro
-@expandglossary {@glossarytext}
+@expandglossary {@glossarytext{}}
@end macro
@@ -1173,7 +1173,7 @@ text1, arg1
@end macro
@unmacro glossarytext
@macro glossarytext
-@glossarytext
+@glossarytext{}
@item name1 @anchor{id1}
text1, arg1
@end macro
@@ -1190,7 +1190,7 @@ text2
@end macro
@unmacro glossarytext
@macro glossarytext
-@glossarytext
+@glossarytext{}
@item name2 @anchor{id2}
text2
@end macro
diff --git a/tp/t/results/macro/simple_imbricated_macro_rmacro.pl
b/tp/t/results/macro/simple_imbricated_macro_rmacro.pl
new file mode 100644
index 0000000000..284adaeaea
--- /dev/null
+++ b/tp/t/results/macro/simple_imbricated_macro_rmacro.pl
@@ -0,0 +1,196 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'simple_imbricated_macro_rmacro'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'text' => 'truc',
+ 'type' => 'macro_name'
+ }
+ ],
+ 'cmdname' => 'macro',
+ 'contents' => [
+ {
+ 'text' => 'truc.
+',
+ 'type' => 'raw'
+ },
+ {
+ 'text' => '@rmacro bidule {}
+',
+ 'type' => 'raw'
+ },
+ {
+ 'text' => 'bidule.
+',
+ 'type' => 'raw'
+ },
+ {
+ 'text' => '@end rmacro
+',
+ 'type' => 'raw'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'macro'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'end',
+ 'extra' => {
+ 'text_arg' => 'macro'
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'info' => {
+ 'arg_line' => ' truc {}
+'
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'truc.
+'
+ },
+ {
+ 'args' => [
+ {
+ 'text' => 'bidule',
+ 'type' => 'macro_name'
+ }
+ ],
+ 'cmdname' => 'rmacro',
+ 'contents' => [
+ {
+ 'text' => 'bidule.
+',
+ 'type' => 'raw'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'rmacro'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'end',
+ 'extra' => {
+ 'text_arg' => 'rmacro'
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 8,
+ 'macro' => 'truc'
+ }
+ }
+ ],
+ 'info' => {
+ 'arg_line' => ' bidule {}
+'
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 8,
+ 'macro' => 'truc'
+ }
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'bidule.
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'simple_imbricated_macro_rmacro'} = '@macro truc {}
+truc.
+@rmacro bidule {}
+bidule.
+@end rmacro
+@end macro
+
+truc.
+@rmacro bidule {}
+bidule.
+@end rmacro
+
+bidule.
+';
+
+
+$result_texts{'simple_imbricated_macro_rmacro'} = '
+truc.
+
+bidule.
+';
+
+$result_errors{'simple_imbricated_macro_rmacro'} = [];
+
+
+$result_floats{'simple_imbricated_macro_rmacro'} = {};
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/parser.c (raw_block_stack_top) (process_remaining_on_line): use the stack of raw block commands to determine the matching end of nested raw block command.,
Patrice Dumas <=