[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_ar
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments), tp/Texinfo/XS/parsetexi/macro.c (expand_linemacro_arguments): a comment on a linemacro defined command invokation (not in braces) is not part of the arguments, and is left after the expansion as agreed with Gavin. |
Date: |
Tue, 25 Jul 2023 13:52:46 -0400 |
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 62ac81d1dc * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments),
tp/Texinfo/XS/parsetexi/macro.c (expand_linemacro_arguments): a comment on a
linemacro defined command invokation (not in braces) is not part of the
arguments, and is left after the expansion as agreed with Gavin.
62ac81d1dc is described below
commit 62ac81d1dca18687ceae5987597aad3e3e011d91
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jul 25 19:52:34 2023 +0200
* tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments),
tp/Texinfo/XS/parsetexi/macro.c (expand_linemacro_arguments):
a comment on a linemacro defined command invokation (not in braces) is
not part of the arguments, and is left after the expansion as
agreed with Gavin.
* tp/Makefile.tres, tp/t/65linemacro.t
(comment_on_linemacro_call_out_of_braces)
(comment_on_linemacro_call_macro_expansion): more tests of comments on
linemacro call lines.
---
ChangeLog | 13 ++++++++++
tp/Makefile.tres | 2 ++
tp/Texinfo/ParserNonXS.pm | 10 +++++++-
tp/Texinfo/XS/parsetexi/macro.c | 12 ++++++++-
tp/t/65linemacro.t | 30 +++++++++++++++++++++-
.../linemacro/comment_at_end_of_linemacro_call.pl | 2 +-
6 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 413085cc85..26adfe982d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-07-25 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments),
+ tp/Texinfo/XS/parsetexi/macro.c (expand_linemacro_arguments):
+ a comment on a linemacro defined command invokation (not in braces) is
+ not part of the arguments, and is left after the expansion as
+ agreed with Gavin.
+
+ * tp/Makefile.tres, tp/t/65linemacro.t
+ (comment_on_linemacro_call_out_of_braces)
+ (comment_on_linemacro_call_macro_expansion): more tests of comments on
+ linemacro call lines.
+
2023-07-25 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/ParagraphNonXS.pm (new): rename 'last_char'
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index af1ff2b78c..e9d931cd85 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1230,6 +1230,8 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/linemacro/comment_at_end_of_linemacro_call.pl \
t/results/linemacro/comment_in_linemacro_call.pl \
t/results/linemacro/comment_in_one_argument_linemacro_call.pl \
+ t/results/linemacro/comment_on_linemacro_call_macro_expansion.pl \
+ t/results/linemacro/comment_on_linemacro_call_out_of_braces.pl \
t/results/linemacro/empty_last_argument.pl \
t/results/linemacro/end_conditional_in_linemacro.pl \
t/results/linemacro/last_argument_with_braces.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 99d2b87353..cbab8ae95a 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2677,9 +2677,15 @@ sub _expand_linemacro_arguments($$$$$)
my $separator = $2;
$argument_content->{'text'} .= $1;
if ($separator eq '@') {
- $argument_content->{'text'} .= '@';
my ($cmdname, $is_single_letter) = _parse_command_name($line);
if (defined($cmdname)) {
+ # a comment is not part of the arguments
+ if ($braces_level <= 0
+ and ($cmdname eq 'c' or $cmdname eq 'comment')) {
+ $line = $separator.$line;
+ last;
+ }
+ $argument_content->{'text'} .= '@';
$argument_content->{'text'} .= $cmdname;
substr($line, 0, length($cmdname)) = '';
if ((defined($self->{'brace_commands'}->{$cmdname})
@@ -2688,6 +2694,8 @@ sub _expand_linemacro_arguments($$$$$)
$line =~ s/^(\s*)//;
$argument_content->{'text'} .= $1;
}
+ } else {
+ $argument_content->{'text'} .= '@';
}
} elsif ($separator eq '}') {
$braces_level--;
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index d6107d395a..d27e39c6f3 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -541,12 +541,18 @@ expand_linemacro_arguments (ELEMENT *macro, char
**line_inout,
enum command_id cmd;
int whitespaces_len;
case '@':
- text_append_n (arg, sep, 1);
pline = sep + 1;
command = parse_command_name (&pline, &single_char);
if (command)
{
enum command_id cmd = lookup_command (command);
+ if (braces_level <= 0 && cmd
+ && (cmd == CM_comment || cmd == CM_c))
+ {
+ line = sep;
+ goto funexit;
+ }
+ text_append_n (arg, sep, 1);
text_append (arg, command);
if (cmd && (command_data(cmd).flags & CF_brace)
&& strchr (whitespace_chars, *pline)
@@ -558,6 +564,10 @@ expand_linemacro_arguments (ELEMENT *macro, char
**line_inout,
pline += whitespaces_len;
}
}
+ else
+ {
+ text_append_n (arg, sep, 1);
+ }
break;
case '{':
braces_level++;
diff --git a/tp/t/65linemacro.t b/tp/t/65linemacro.t
index d879bdd24b..d78b89ad0e 100644
--- a/tp/t/65linemacro.t
+++ b/tp/t/65linemacro.t
@@ -470,7 +470,35 @@ c \a\ d
}
after
-']
+'],
+['comment_on_linemacro_call_out_of_braces',
+'@linemacro lm {a, b, c}
+first |\a\|
+second |\b\|
+third |\c\|
+@end linemacro
+
+@lm {something protected} @c comment {in braces}
+
+@lm@c comment early n l m
+
+@lm {aaa
+ } rest @comment on second {line comment}
+'],
+['comment_on_linemacro_call_macro_expansion',
+'@linemacro lm {a, b}
+first |\a\|
+second |\b\|
+@end linemacro
+
+@macro mymacro {a}
+macro \a\ text
+after arg
+@end macro
+
+@mymacro {
+@lm {a} @c in comment}
+'],
);
diff --git a/tp/t/results/linemacro/comment_at_end_of_linemacro_call.pl
b/tp/t/results/linemacro/comment_at_end_of_linemacro_call.pl
index 7cefe9a612..a67c845457 100644
--- a/tp/t/results/linemacro/comment_at_end_of_linemacro_call.pl
+++ b/tp/t/results/linemacro/comment_at_end_of_linemacro_call.pl
@@ -112,7 +112,7 @@ $result_trees{'comment_at_end_of_linemacro_call'} = {
{
'contents' => [
{
- 'text' => 'something @c comment }'
+ 'text' => 'something '
}
],
'info' => {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments), tp/Texinfo/XS/parsetexi/macro.c (expand_linemacro_arguments): a comment on a linemacro defined command invokation (not in braces) is not part of the arguments, and is left after the expansion as agreed with Gavin.,
Patrice Dumas <=