[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_b
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_body): content in argument may be missing for the last argument which removal is attempted in expand_macro_arguments. Gavin report. |
Date: |
Mon, 13 Feb 2023 15:29:52 -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 606f3c9420 * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_body):
content in argument may be missing for the last argument which removal is
attempted in expand_macro_arguments. Gavin report.
606f3c9420 is described below
commit 606f3c94201213524b0f1a776b559126dfc973c9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Feb 13 21:29:40 2023 +0100
* tp/Texinfo/XS/parsetexi/macro.c (expand_macro_body): content in
argument may be missing for the last argument which removal is
attempted in expand_macro_arguments. Gavin report.
* tp/Makefile.tres, tp/t/60macro.t: add macro_call_empty_two_arg
with diverse possibilities of spaces and empty args for a two
arguments macro call.
---
ChangeLog | 12 +-
tp/Makefile.tres | 1 +
tp/Texinfo/XS/parsetexi/macro.c | 13 +-
tp/t/60macro.t | 29 +
tp/t/results/macro/macro_call_empty_two_arg.pl | 798 +++++++++++++++++++++++++
5 files changed, 847 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8341aa3fb9..51847379e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
-2023-02-12 Patrice Dumas <pertusus@free.fr>
+2023-02-13 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_body): content in
+ argument may be missing for the last argument which removal is
+ attempted in expand_macro_arguments. Gavin report.
+
+ * tp/Makefile.tres, tp/t/60macro.t: add macro_call_empty_two_arg
+ with diverse possibilities of spaces and empty args for a two
+ arguments macro call.
+
+2023-02-13 Patrice Dumas <pertusus@free.fr>
Use pre-set keys for index sorting
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 94a31e3d2d..aa1def3b0a 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1202,6 +1202,7 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/macro/macro_after_paragraph.pl \
t/results/macro/macro_before_specific_line_command_args.pl \
t/results/macro/macro_call_empty_middle_arg.pl \
+ t/results/macro/macro_call_empty_two_arg.pl \
t/results/macro/macro_call_in_ignored_inlinefmtifelse.pl \
t/results/macro/macro_call_in_inlinefmtifelse_format.pl \
t/results/macro/macro_end_call_in_ignored_inlinefmt.pl \
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index fb6992dd1c..de559bfc81 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -364,9 +364,10 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout,
enum command_id cmd,
else if (arg->end == 0)
/* It is possible to remove the last argument if empty
since not being expanded is the same as being expanded
- as an empty string. */
+ as an empty string.
+ Note that if there are source marks or info, the argument
+ may not have content anymore but still be there. */
remove_empty_arg (argument);
-
}
else
{
@@ -458,9 +459,11 @@ expand_macro_body (MACRO *macro_record, ELEMENT
*arguments, TEXT *expanded)
{
if (arguments && pos < arguments->args.number)
{
- text_append (expanded,
- last_contents_child (
- args_child_by_index (arguments, pos))->text.text);
+ ELEMENT *argument = args_child_by_index (arguments, pos);
+ if (argument->contents.number > 0)
+ text_append (expanded,
+ last_contents_child (
+ args_child_by_index (arguments, pos))->text.text);
}
}
*bs = '\\';
diff --git a/tp/t/60macro.t b/tp/t/60macro.t
index f8394a2be1..6156323b00 100644
--- a/tp/t/60macro.t
+++ b/tp/t/60macro.t
@@ -239,6 +239,35 @@ third \cc\,
@threea{m, , n}
@threea{o,,p}
+'],
+['macro_call_empty_two_arg',
+'@macro twoa {aa, bb}
+first \aa\,
+second \bb\,
+@end macro
+
+@twoa{}
+
+@twoa{ }
+
+@twoa{, }
+
+@twoa{ ,}
+
+@twoa{ , }
+
+@twoa{g, }
+
+@twoa{h,}
+
+@twoa{, i}
+
+@twoa{ , j}
+
+@twoa{,k}
+
+@twoa{ ,l}
+
'],
['protect_in_body',
'@macro macroone { arg1 , arg2 }
diff --git a/tp/t/results/macro/macro_call_empty_two_arg.pl
b/tp/t/results/macro/macro_call_empty_two_arg.pl
new file mode 100644
index 0000000000..b90a2f7f44
--- /dev/null
+++ b/tp/t/results/macro/macro_call_empty_two_arg.pl
@@ -0,0 +1,798 @@
+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{'macro_call_empty_two_arg'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'text' => 'twoa',
+ 'type' => 'macro_name'
+ },
+ {
+ 'text' => 'aa',
+ 'type' => 'macro_arg'
+ },
+ {
+ 'text' => 'bb',
+ 'type' => 'macro_arg'
+ }
+ ],
+ 'cmdname' => 'macro',
+ 'contents' => [
+ {
+ 'text' => 'first \\aa\\,
+',
+ 'type' => 'raw'
+ },
+ {
+ 'text' => 'second \\bb\\,
+',
+ 'type' => 'raw'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'macro'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'end',
+ 'extra' => {
+ 'text_arg' => 'macro'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'info' => {
+ 'arg_line' => ' twoa {aa, bb}
+'
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 1,
+ 'element' => {
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 1,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 2,
+ 'element' => {
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 2,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 3,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 3,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 4,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 4,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 5,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 5,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 6,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'g'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first g,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 6,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 7,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'h'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first h,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 7,
+ 'position' => 8,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second ,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 8,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'i'
+ }
+ ],
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 8,
+ 'position' => 9,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second i,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 9,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'j'
+ }
+ ],
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 9,
+ 'position' => 9,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second j,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 10,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'k'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 10,
+ 'position' => 9,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second k,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 11,
+ 'element' => {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => ''
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'l'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'extra' => {
+ 'name' => 'twoa'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'type' => 'macro_call'
+ },
+ 'position' => 1,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'start'
+ }
+ ],
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'first ,
+'
+ },
+ {
+ 'source_marks' => [
+ {
+ 'counter' => 11,
+ 'position' => 9,
+ 'sourcemark_type' => 'macro_expansion',
+ 'status' => 'end'
+ }
+ ],
+ 'text' => 'second l,
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'macro_call_empty_two_arg'} = '@macro twoa {aa, bb}
+first \\aa\\,
+second \\bb\\,
+@end macro
+
+first ,
+second ,
+
+first ,
+second ,
+
+first ,
+second ,
+
+first ,
+second ,
+
+first ,
+second ,
+
+first g,
+second ,
+
+first h,
+second ,
+
+first ,
+second i,
+
+first ,
+second j,
+
+first ,
+second k,
+
+first ,
+second l,
+
+';
+
+
+$result_texts{'macro_call_empty_two_arg'} = '
+first ,
+second ,
+
+first ,
+second ,
+
+first ,
+second ,
+
+first ,
+second ,
+
+first ,
+second ,
+
+first g,
+second ,
+
+first h,
+second ,
+
+first ,
+second i,
+
+first ,
+second j,
+
+first ,
+second k,
+
+first ,
+second l,
+
+';
+
+$result_errors{'macro_call_empty_two_arg'} = [];
+
+
+$result_floats{'macro_call_empty_two_arg'} = {};
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_body): content in argument may be missing for the last argument which removal is attempted in expand_macro_arguments. Gavin report.,
Patrice Dumas <=