[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): add end of line if needed for nested @ignore with comment. |
Date: |
Tue, 27 Dec 2022 19:42:51 -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 b1c6f641a2 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line):
add end of line if needed for nested @ignore with comment.
b1c6f641a2 is described below
commit b1c6f641a259a90f7b189b8ee6c03052d7f6008c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Dec 28 01:42:41 2022 +0100
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): add end of
line if needed for nested @ignore with comment.
* tp/Texinfo/XS/parsetexi/parser.c (read_comment): fix offset with
@comment. Skip the @ in comment command name.
* tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line):
put the correct string in @ignore comment. Advance instead of exiting
when there is a @ that is not a comment.
* tp/Makefile.tres, tp/t/55conditionals.t: do not skip
nested_ignore_with_comments. Add comment without
argument in @ignore line examples. Add nested_ignore_comment_no_eol
to test a very specific case of no end of line after nested @ignore
and comment.
---
ChangeLog | 18 +++++
tp/Makefile.tres | 2 +
tp/Texinfo/ParserNonXS.pm | 3 +
tp/Texinfo/XS/parsetexi/parser.c | 10 +--
tp/t/55conditionals.t | 13 ++-
.../conditionals/ignore_spaces_and_comments.pl | 79 ++++++++++++++++++
.../conditionals/nested_ignore_comment_no_eol.pl | 94 ++++++++++++++++++++++
.../conditionals/nested_ignore_with_comments.pl | 79 +++++++++++++++++-
8 files changed, 288 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 48ca32f393..9571466ca8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2022-12-27 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): add end of
+ line if needed for nested @ignore with comment.
+
+ * tp/Texinfo/XS/parsetexi/parser.c (read_comment): fix offset with
+ @comment. Skip the @ in comment command name.
+
+ * tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line):
+ put the correct string in @ignore comment. Advance instead of exiting
+ when there is a @ that is not a comment.
+
+ * tp/Makefile.tres, tp/t/55conditionals.t: do not skip
+ nested_ignore_with_comments. Add comment without
+ argument in @ignore line examples. Add nested_ignore_comment_no_eol
+ to test a very specific case of no end of line after nested @ignore
+ and comment.
+
2022-12-27 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XSLoader.pm (init): show the DynaLoader error message
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index cf388f83eb..c8cc331abe 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -119,6 +119,8 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/conditionals/many_conditionals.pl \
t/results/conditionals/nested_ifset_ifclear.pl \
t/results/conditionals/nested_ignore.pl \
+ t/results/conditionals/nested_ignore_comment_no_eol.pl \
+ t/results/conditionals/nested_ignore_with_comments.pl \
t/results/conditionals/not_set.pl \
t/results/conditionals/plaintext_ifinfo.pl \
t/results/conditionals/plaintext_ifinfo_ifnotplaintext.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 4dfe53c5c0..b8ed384223 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4153,6 +4153,9 @@ sub _process_remaining_on_line($$$$)
if ($line =~ /\@(c|comment)((\@|\s+).*)?$/) {
my $comment_command = $1;
my $comment_text = $2;
+ chomp $comment_text;
+ my $has_end_of_line = chomp $line;
+ $comment_text .= "\n" if ($has_end_of_line);
if (not exists($current->{'args'})) {
$current->{'args'} = [
{'type' => 'block_line_arg', 'parent' => $current,
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 97ae19a46e..84263597bd 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -96,10 +96,10 @@ read_comment (char *line, char **comment_command)
{
p += 2;
if (memcmp (p, "omment", 6) == 0)
- p += 7;
+ p += 6;
if (*p && *p != '@' && !strchr (whitespace_chars, *p))
return 0; /* @c or @comment not terminated. */
- *comment_command = strndup(line, p - line);
+ *comment_command = strndup(line+1, p - (line+1));
}
else
return 0; /* Trailing characters on line. */
@@ -1199,11 +1199,11 @@ process_remaining_on_line (ELEMENT **current_inout,
char **line_inout)
args = new_element (ET_NONE);
e = new_element (ET_NONE);
- text_append (&e->text, p);
+ text_append (&e->text, comment_position);
add_to_element_contents (args, e);
misc_arg_e = new_element (ET_misc_arg);
- text_append (&misc_arg_e->text, p);
+ text_append (&misc_arg_e->text, comment_position);
comment_e = new_element (ET_NONE);
comment_e->cmd = lookup_command (cmd_name);
@@ -1214,7 +1214,7 @@ process_remaining_on_line (ELEMENT **current_inout, char
**line_inout)
"comment_at_end",
comment_e);
}
- break;
+ p += 1;
}
else
break;
diff --git a/tp/t/55conditionals.t b/tp/t/55conditionals.t
index 71ec2391bf..06a71d9580 100644
--- a/tp/t/55conditionals.t
+++ b/tp/t/55conditionals.t
@@ -51,6 +51,10 @@ Comment
@ignore @comment space comment
Space Comment
@end ignore
+
+@ignore @c
+Space Comment no argument
+@end ignore
'],
['nested_ignore',
'@ignore
@@ -82,6 +86,10 @@ Spaces no comment
Comment
@end ignore
+@ignore @c
+Comment no argument
+@end ignore
+
@ignore @c space comment
Space Comment
@end ignore
@@ -95,7 +103,10 @@ Command comment
@end ignore
@end ignore
-', {'skip' => 1}],
+'],
+['nested_ignore_comment_no_eol',
+'@ignore
+@ignore @c comment'],
['empty_set_in_ifset',
'@set a
diff --git a/tp/t/results/conditionals/ignore_spaces_and_comments.pl
b/tp/t/results/conditionals/ignore_spaces_and_comments.pl
index 2f8e627512..677ed93522 100644
--- a/tp/t/results/conditionals/ignore_spaces_and_comments.pl
+++ b/tp/t/results/conditionals/ignore_spaces_and_comments.pl
@@ -262,6 +262,80 @@ $result_trees{'ignore_spaces_and_comments'} = {
'line_nr' => 13,
'macro' => ''
}
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'info' => {
+ 'comment_at_end' => {
+ 'args' => [
+ {
+ 'text' => '
+',
+ 'type' => 'misc_arg'
+ }
+ ],
+ 'cmdname' => 'c',
+ 'extra' => {
+ 'misc_args' => [
+ '
+'
+ ]
+ }
+ }
+ },
+ 'type' => 'block_line_arg'
+ }
+ ],
+ 'cmdname' => 'ignore',
+ 'contents' => [
+ {
+ 'text' => 'Space Comment no argument
+',
+ 'type' => 'raw'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'ignore'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'end',
+ 'extra' => {
+ 'text_arg' => 'ignore'
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 19,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 17,
+ 'macro' => ''
+ }
}
],
'type' => 'before_node_section'
@@ -285,12 +359,17 @@ Comment
@ignore @comment space comment
Space Comment
@end ignore
+
+@ignore @c
+Space Comment no argument
+@end ignore
';
$result_texts{'ignore_spaces_and_comments'} = '
+
';
$result_errors{'ignore_spaces_and_comments'} = [];
diff --git a/tp/t/results/conditionals/nested_ignore_comment_no_eol.pl
b/tp/t/results/conditionals/nested_ignore_comment_no_eol.pl
new file mode 100644
index 0000000000..e0a638eed7
--- /dev/null
+++ b/tp/t/results/conditionals/nested_ignore_comment_no_eol.pl
@@ -0,0 +1,94 @@
+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{'nested_ignore_comment_no_eol'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'block_line_arg'
+ }
+ ],
+ 'cmdname' => 'ignore',
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'info' => {
+ 'comment_at_end' => {
+ 'args' => [
+ {
+ 'text' => ' comment',
+ 'type' => 'misc_arg'
+ }
+ ],
+ 'cmdname' => 'c',
+ 'extra' => {
+ 'misc_args' => [
+ ' comment'
+ ]
+ }
+ },
+ 'spaces_after_argument' => ' '
+ },
+ 'type' => 'block_line_arg'
+ }
+ ],
+ 'cmdname' => 'ignore'
+ }
+ ],
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'nested_ignore_comment_no_eol'} = '@ignore
+@ignore @c comment';
+
+
+$result_texts{'nested_ignore_comment_no_eol'} = '';
+
+$result_errors{'nested_ignore_comment_no_eol'} = [
+ {
+ 'error_line' => 'no matching `@end ignore\'
+',
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => '',
+ 'text' => 'no matching `@end ignore\'',
+ 'type' => 'error'
+ },
+ {
+ 'error_line' => 'no matching `@end ignore\'
+',
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => '',
+ 'text' => 'no matching `@end ignore\'',
+ 'type' => 'error'
+ }
+];
+
+
+$result_floats{'nested_ignore_comment_no_eol'} = {};
+
+
+1;
diff --git a/tp/t/results/conditionals/nested_ignore_with_comments.pl
b/tp/t/results/conditionals/nested_ignore_with_comments.pl
index b41f6ca029..fe7cec1d42 100644
--- a/tp/t/results/conditionals/nested_ignore_with_comments.pl
+++ b/tp/t/results/conditionals/nested_ignore_with_comments.pl
@@ -188,6 +188,73 @@ $result_trees{'nested_ignore_with_comments'} = {
},
{
'text' => '
+',
+ 'type' => 'raw'
+ },
+ {
+ 'args' => [
+ {
+ 'info' => {
+ 'comment_at_end' => {
+ 'args' => [
+ {
+ 'text' => '
+',
+ 'type' => 'misc_arg'
+ }
+ ],
+ 'cmdname' => 'c',
+ 'extra' => {
+ 'misc_args' => [
+ '
+'
+ ]
+ }
+ },
+ 'spaces_after_argument' => ' '
+ },
+ 'type' => 'block_line_arg'
+ }
+ ],
+ 'cmdname' => 'ignore',
+ 'contents' => [
+ {
+ 'text' => 'Comment no argument
+',
+ 'type' => 'raw'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'ignore'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => '
+'
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'end',
+ 'extra' => {
+ 'text_arg' => 'ignore'
+ },
+ 'info' => {
+ 'spaces_before_argument' => ' '
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 16,
+ 'macro' => ''
+ }
+ }
+ ]
+ },
+ {
+ 'text' => '
',
'type' => 'raw'
},
@@ -247,7 +314,7 @@ $result_trees{'nested_ignore_with_comments'} = {
},
'source_info' => {
'file_name' => '',
- 'line_nr' => 16,
+ 'line_nr' => 20,
'macro' => ''
}
}
@@ -314,7 +381,7 @@ $result_trees{'nested_ignore_with_comments'} = {
},
'source_info' => {
'file_name' => '',
- 'line_nr' => 20,
+ 'line_nr' => 24,
'macro' => ''
}
}
@@ -381,7 +448,7 @@ $result_trees{'nested_ignore_with_comments'} = {
},
'source_info' => {
'file_name' => '',
- 'line_nr' => 24,
+ 'line_nr' => 28,
'macro' => ''
}
}
@@ -416,7 +483,7 @@ $result_trees{'nested_ignore_with_comments'} = {
},
'source_info' => {
'file_name' => '',
- 'line_nr' => 26,
+ 'line_nr' => 30,
'macro' => ''
}
}
@@ -447,6 +514,10 @@ Spaces no comment
Comment
@end ignore
+@ignore @c
+Comment no argument
+@end ignore
+
@ignore @c space comment
Space Comment
@end ignore
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): add end of line if needed for nested @ignore with comment.,
Patrice Dumas <=