[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_expand_macro_argume
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments, _handle_macro), tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments) (handle_macro): pass the leading brace and possible spaces following the leading brace to expand_macro_arguments instead of handling them in handle_macro. Add space before brace to "spaces_after_cmd_before_arg" info key as an element for macros call elements. |
Date: |
Sun, 23 Jul 2023 08:03:04 -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 8ed2d8895d * tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments,
_handle_macro), tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments)
(handle_macro): pass the leading brace and possible spaces following the
leading brace to expand_macro_arguments instead of handling them in
handle_macro. Add space before brace to "spaces_after_cmd_before_arg" info key
as an element for macros call elements.
8ed2d8895d is described below
commit 8ed2d8895d87c988d2b618129ad19476c3602e8e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jul 23 14:02:54 2023 +0200
* tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments, _handle_macro),
tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments)
(handle_macro): pass the leading brace and possible spaces following
the leading brace to expand_macro_arguments instead of handling them
in handle_macro. Add space before brace to
"spaces_after_cmd_before_arg" info key as an element for macros call
elements.
---
ChangeLog | 10 ++++++++
tp/Texinfo/ParserNonXS.pm | 18 ++++++++++---
tp/Texinfo/XS/parsetexi/macro.c | 30 +++++++++++++++-------
tp/t/results/macro/expand_two_same.pl | 6 +++++
tp/t/results/macro/form_feeds.pl | 3 +++
tp/t/results/macro/glossary.pl | 10 ++++++++
tp/t/results/macro/macro_expansion.pl | 5 ++++
tp/t/results/macro/protect_in_body.pl | 3 +++
tp/t/results/macro/protect_in_body_one_arg.pl | 3 +++
tp/t/results/macro/two_macros_on_a_line.pl | 5 ++++
.../results/macro/verb_with_brace_in_macro_call.pl | 5 ++++
.../value_and_macro/comma_value_in_macro_arg.pl | 3 +++
12 files changed, 88 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 799e35b904..51a6bf8f38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-07-23 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments, _handle_macro),
+ tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments)
+ (handle_macro): pass the leading brace and possible spaces following
+ the leading brace to expand_macro_arguments instead of handling them
+ in handle_macro. Add space before brace to
+ "spaces_after_cmd_before_arg" info key as an element for macros call
+ elements.
+
2023-07-23 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_new_value_element)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 1688bbb42c..e7839cd46e 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2547,6 +2547,7 @@ sub _expand_macro_arguments($$$$$)
my ($self, $macro, $line, $source_info, $current) = @_;
my $braces_level = 1;
+
my $argument = {'type' => 'brace_command_arg',
'contents' => [],
'parent' => $current};
@@ -2554,11 +2555,18 @@ sub _expand_macro_arguments($$$$$)
my $argument_content = {'text' => '',
'parent' => $argument};
push @{$argument->{'contents'}}, $argument_content;
+
my $args_total = scalar(@{$macro->{'args'}}) -1;
my $name = $macro->{'args'}->[0]->{'text'};
my $source_info_orig = $source_info;
+ $line =~ s/^{(\s*)//;
+ if ($1 ne '') {
+ $current->{'info'} = {} if (!$current->{'info'});
+ $current->{'info'}->{'spaces_before_argument'} = {'text' => $1};
+ }
+
while (1) {
if ($line =~ s/([^\\{},]*)([\\{},])//) {
my $separator = $2;
@@ -4935,10 +4943,12 @@ sub _handle_macro($$$$$)
$macro_call_element);
} else {
my $args_number = scalar(@{$expanded_macro->{'args'}}) -1;
- if ($line =~ s/^\s*{(\s*)//) { # } macro with args
- if ($1 ne '') {
- $macro_call_element->{'info'}
- = {'spaces_before_argument' => {'text' => $1}};
+ if ($line =~ /^\s*{/) { # } macro with args
+ if ($line =~ s/^(\s+)//) {
+ my $spaces_element = {'text' => $1};
+ $macro_call_element->{'info'} = {} if (!$macro_call_element->{'info'});
+ $macro_call_element->{'info'}->{'spaces_after_cmd_before_arg'}
+ = $spaces_element;
}
($line, $source_info)
= _expand_macro_arguments($self, $expanded_macro, $line, $source_info,
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 1c78264ebb..82062e5a5c 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -291,9 +291,9 @@ remove_empty_arg (ELEMENT *argument)
return current;
}
-/* LINE points the first non-whitespace character after the opening brace in a
- macro invocation. CMD is the command identifier of the macro command.
- Return array of the arguments. Return value to be freed by caller. */
+/* LINE points the opening brace in a macro invocation. CMD is the command
+ identifier of the macro command. Return array of the arguments. Return
+ value to be freed by caller. */
void
expand_macro_arguments (ELEMENT *macro, char **line_inout, enum command_id cmd,
ELEMENT *current)
@@ -303,6 +303,7 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout,
enum command_id cmd,
TEXT *arg;
int braces_level = 1;
int args_total;
+ int whitespaces_len;
ELEMENT *argument = new_element (ET_brace_command_arg);
ELEMENT *argument_content = new_element (ET_NONE);
@@ -313,6 +314,18 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout,
enum command_id cmd,
args_total = macro->args.number - 1;
+ /* *pline is '{', advance past the open brace, start at braces_level = 1 */
+ pline++;
+ whitespaces_len = strspn (pline, whitespace_chars);
+ if (whitespaces_len > 0)
+ {
+ ELEMENT *spaces_element = new_element (ET_NONE);
+ text_append_n (&spaces_element->text, pline, whitespaces_len);
+ add_info_element_oot (current, "spaces_before_argument",
+ spaces_element);
+ pline += whitespaces_len;
+ }
+
while (braces_level > 0)
{
/* At the beginning of this loop pline is at the start
@@ -834,16 +847,15 @@ handle_macro (ELEMENT *current, char **line_inout, enum
command_id cmd)
p = line + strspn (line, whitespace_chars);
if (*p == '{')
{
- p++;
- line = p;
- line += strspn (line, whitespace_chars);
- if (line - p)
+ if (p - line > 0)
{
ELEMENT *spaces_element = new_element (ET_NONE);
- text_append_n (&spaces_element->text, p, line - p);
- add_info_element_oot (macro_call_element,
"spaces_before_argument",
+ text_append_n (&spaces_element->text, line, p - line);
+ add_info_element_oot (macro_call_element,
"spaces_after_cmd_before_arg",
spaces_element);
+
}
+ line = p;
expand_macro_arguments (macro, &line, cmd, macro_call_element);
}
/* Warning depending on the number of arguments this macro
diff --git a/tp/t/results/macro/expand_two_same.pl
b/tp/t/results/macro/expand_two_same.pl
index a709f70854..3df27b746b 100644
--- a/tp/t/results/macro/expand_two_same.pl
+++ b/tp/t/results/macro/expand_two_same.pl
@@ -98,6 +98,9 @@ arg}
'name' => 'macrotwo'
},
'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ },
'spaces_before_argument' => {
'text' => ' '
}
@@ -212,6 +215,9 @@ arg}
'name' => 'macrotwo'
},
'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ },
'spaces_before_argument' => {
'text' => ' '
}
diff --git a/tp/t/results/macro/form_feeds.pl b/tp/t/results/macro/form_feeds.pl
index 0cf3eb3dde..24f6cf0893 100644
--- a/tp/t/results/macro/form_feeds.pl
+++ b/tp/t/results/macro/form_feeds.pl
@@ -172,6 +172,9 @@ $result_trees{'form_feeds'} = {
'name' => 'mymacro'
},
'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ },
'spaces_before_argument' => {
'text' => ' '
}
diff --git a/tp/t/results/macro/glossary.pl b/tp/t/results/macro/glossary.pl
index 244a279876..0dc44fce3a 100644
--- a/tp/t/results/macro/glossary.pl
+++ b/tp/t/results/macro/glossary.pl
@@ -856,6 +856,11 @@ $result_trees{'glossary'} = {
'extra' => {
'name' => 'expandglossary'
},
+ 'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ }
+ },
'type' => 'macro_call'
},
'sourcemark_type' => 'macro_expansion',
@@ -1291,6 +1296,11 @@ $result_trees{'glossary'} = {
'extra' => {
'name' => 'expandglossary'
},
+ 'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ }
+ },
'type' => 'macro_call'
},
'sourcemark_type' => 'macro_expansion',
diff --git a/tp/t/results/macro/macro_expansion.pl
b/tp/t/results/macro/macro_expansion.pl
index 1e5d1e488b..beac32b318 100644
--- a/tp/t/results/macro/macro_expansion.pl
+++ b/tp/t/results/macro/macro_expansion.pl
@@ -132,6 +132,11 @@ $result_trees{'macro_expansion'} = {
'extra' => {
'name' => 'macroone'
},
+ 'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ }
+ },
'type' => 'macro_call'
},
'position' => 15,
diff --git a/tp/t/results/macro/protect_in_body.pl
b/tp/t/results/macro/protect_in_body.pl
index 8f8c044e00..e7fa352157 100644
--- a/tp/t/results/macro/protect_in_body.pl
+++ b/tp/t/results/macro/protect_in_body.pl
@@ -113,6 +113,9 @@ $result_trees{'protect_in_body'} = {
'name' => 'macroone'
},
'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ },
'spaces_before_argument' => {
'text' => ' '
}
diff --git a/tp/t/results/macro/protect_in_body_one_arg.pl
b/tp/t/results/macro/protect_in_body_one_arg.pl
index 13b75199da..9013b0dbab 100644
--- a/tp/t/results/macro/protect_in_body_one_arg.pl
+++ b/tp/t/results/macro/protect_in_body_one_arg.pl
@@ -93,6 +93,9 @@ $result_trees{'protect_in_body_one_arg'} = {
'name' => 'macroone'
},
'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ },
'spaces_before_argument' => {
'text' => ' '
}
diff --git a/tp/t/results/macro/two_macros_on_a_line.pl
b/tp/t/results/macro/two_macros_on_a_line.pl
index e69c934880..23a7d8ebc4 100644
--- a/tp/t/results/macro/two_macros_on_a_line.pl
+++ b/tp/t/results/macro/two_macros_on_a_line.pl
@@ -432,6 +432,11 @@ in macro'
'extra' => {
'name' => 'mymacrowithargs'
},
+ 'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ }
+ },
'type' => 'macro_call'
},
'position' => 10,
diff --git a/tp/t/results/macro/verb_with_brace_in_macro_call.pl
b/tp/t/results/macro/verb_with_brace_in_macro_call.pl
index ff3e1b2db2..1edeb8a006 100644
--- a/tp/t/results/macro/verb_with_brace_in_macro_call.pl
+++ b/tp/t/results/macro/verb_with_brace_in_macro_call.pl
@@ -114,6 +114,11 @@ $result_trees{'verb_with_brace_in_macro_call'} = {
'extra' => {
'name' => 'mycommand'
},
+ 'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ }
+ },
'type' => 'macro_call'
},
'position' => 1,
diff --git a/tp/t/results/value_and_macro/comma_value_in_macro_arg.pl
b/tp/t/results/value_and_macro/comma_value_in_macro_arg.pl
index a57a17cd0f..4cac212a35 100644
--- a/tp/t/results/value_and_macro/comma_value_in_macro_arg.pl
+++ b/tp/t/results/value_and_macro/comma_value_in_macro_arg.pl
@@ -115,6 +115,9 @@ $result_trees{'comma_value_in_macro_arg'} = {
'name' => 'macro1'
},
'info' => {
+ 'spaces_after_cmd_before_arg' => {
+ 'text' => ' '
+ },
'spaces_before_argument' => {
'text' => ' '
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments, _handle_macro), tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments) (handle_macro): pass the leading brace and possible spaces following the leading brace to expand_macro_arguments instead of handling them in handle_macro. Add space before brace to "spaces_after_cmd_before_arg" info key as an element for macros call elements.,
Patrice Dumas <=