[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Keep definfoenclose defined commands line numbers
From: |
Patrice Dumas |
Subject: |
branch master updated: Keep definfoenclose defined commands line numbers |
Date: |
Fri, 16 Sep 2022 17:36:35 -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 c5a793c65a Keep definfoenclose defined commands line numbers
c5a793c65a is described below
commit c5a793c65a6ff55ab6edb042dfad80b4299763e6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Sep 16 23:36:19 2022 +0200
Keep definfoenclose defined commands line numbers
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/api.c (element_to_perl_hash): keep
source info information for definfoenclose commands.
* tp/Texinfo/ParserNonXS.pm (%keep_line_nr_brace_commands):
remove.
* tp/Texinfo/ParserNonXS.pm (parser, simple_parser)
(_parse_line_command_args): add a dynamic 'brace_commands'
hash with brace commands and added definfoenclose commands.
---
ChangeLog | 15 ++++++
tp/Texinfo/ParserNonXS.pm | 59 +++++++++-------------
tp/Texinfo/XS/parsetexi/api.c | 3 +-
tp/t/results/macro/macro_in_misc_commands.pl | 15 ++++++
tp/t/results/misc_commands/definfoenclose.pl | 15 ++++++
.../misc_commands/definfoenclose_with_empty_arg.pl | 5 ++
tp/t/results/paragraph/paragraph_command.pl | 5 ++
tp/t/results/value/value_in_misc_commands.pl | 15 ++++++
.../results/xtable/definfoenclose_on_table_line.pl | 5 ++
9 files changed, 100 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e131647d6b..29965c240d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2022-09-16 Patrice Dumas <pertusus@free.fr>
+
+ Keep definfoenclose defined commands line numbers
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/api.c (element_to_perl_hash): keep
+ source info information for definfoenclose commands.
+
+ * tp/Texinfo/ParserNonXS.pm (%keep_line_nr_brace_commands):
+ remove.
+
+ * tp/Texinfo/ParserNonXS.pm (parser, simple_parser)
+ (_parse_line_command_args): add a dynamic 'brace_commands'
+ hash with brace commands and added definfoenclose commands.
+
2022-09-16 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_pop_context, _close_current)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 8464cc1ec7..6ef285c04b 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -305,15 +305,6 @@ my %set_flag_index_char_ignore = (
'txiindexhyphenignore' => '-',
);
-# keep line information for those commands.
-my %keep_line_nr_brace_commands = %context_brace_commands;
-foreach my $keep_line_nr_brace_command ('titlefont', 'anchor') {
- $keep_line_nr_brace_commands{$keep_line_nr_brace_command} = 1;
-}
-foreach my $brace_command (keys (%brace_commands)) {
- $keep_line_nr_brace_commands{$brace_command} = 1;
-}
-
my %type_with_paragraph;
foreach my $type ('before_item', 'before_node_section', 'document_root',
'brace_command_context') {
@@ -586,8 +577,9 @@ sub parser(;$$)
_setup_conf($parser, $conf);
# Initialize command hash that are dynamically modified, notably
- # those for index commands, and lists, based on defaults
+ # those for index commands, and definoenclose, based on defaults
$parser->{'line_commands'} = dclone(\%line_commands);
+ $parser->{'brace_commands'} = dclone(\%brace_commands);
$parser->{'valid_nestings'} = dclone(\%default_valid_nestings);
$parser->{'no_paragraph_commands'} = { %default_no_paragraph_commands };
$parser->{'index_names'} = dclone(\%index_names);
@@ -663,6 +655,7 @@ sub parser(;$$)
# and shared among simple parsers. It is used in gdt() and this has a sizable
# effect on performance.
my $simple_parser_line_commands = dclone(\%line_commands);
+my $simple_parser_brace_commands = dclone(\%brace_commands);
my $simple_parser_valid_nestings = dclone(\%default_valid_nestings);
my $simple_parser_no_paragraph_commands = { %default_no_paragraph_commands };
my $simple_parser_index_names = dclone(\%index_names);
@@ -679,6 +672,7 @@ sub simple_parser(;$)
_setup_conf($parser, $conf);
$parser->{'line_commands'} = $simple_parser_line_commands;
+ $parser->{'brace_commands'} = $simple_parser_brace_commands;
$parser->{'valid_nestings'} = $simple_parser_valid_nestings;
$parser->{'no_paragraph_commands'} = $simple_parser_no_paragraph_commands;
$parser->{'index_names'} = $simple_parser_index_names;
@@ -1417,7 +1411,7 @@ sub _close_all_style_commands($$$;$$)
$interrupting_command) = @_;
while ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
- and exists $brace_commands{$current->{'parent'}->{'cmdname'}}
+ and exists
$self->{'brace_commands'}->{$current->{'parent'}->{'cmdname'}}
and !exists
$context_brace_commands{$current->{'parent'}->{'cmdname'}}) {
print STDERR "CLOSING(_close_all_style_commands)
\@$current->{'parent'}->{'cmdname'}\n"
if ($self->{'DEBUG'});
@@ -1761,7 +1755,7 @@ sub _close_current($$$;$$)
if ($current->{'cmdname'}) {
print STDERR "CLOSING(_close_current) \@$current->{'cmdname'}\n"
if ($self->{'DEBUG'});
- if (exists($brace_commands{$current->{'cmdname'}})) {
+ if (exists($self->{'brace_commands'}->{$current->{'cmdname'}})) {
if (exists $context_brace_commands{$current->{'cmdname'}}) {
my $expected_context;
if ($math_commands{$current->{'cmdname'}}) {
@@ -3114,7 +3108,8 @@ sub _end_line($$$)
$self->_command_error($current, $source_info,
__("%s requires an argument: the formatter for %citem"),
$current->{'cmdname'}, ord('@'));
- } elsif
(!$brace_commands{$current->{'extra'}->{'command_as_argument'}->{'cmdname'}}) {
+ } elsif (!$self->{'brace_commands'}->{
+ $current->{'extra'}->{'command_as_argument'}->{'cmdname'}}) {
$self->_command_error($current, $source_info,
__("command \@%s not accepting argument in brace should not be
on \@%s line"),
$current->{'extra'}->{'command_as_argument'}->{'cmdname'},
@@ -4177,7 +4172,7 @@ sub _process_remaining_on_line($$$$)
# Need to be done as early as possible such that no other condition
# prevail and lead to a missed command
if ($current->{'cmdname'}
- and defined($brace_commands{$current->{'cmdname'}})
+ and defined($self->{'brace_commands'}->{$current->{'cmdname'}})
and !$open_brace
and _command_with_command_as_argument($current->{'parent'})) {
print STDERR "FOR PARENT \@$current->{'parent'}->{'parent'}->{'cmdname'} ".
@@ -4203,7 +4198,7 @@ sub _process_remaining_on_line($$$$)
# or argument for accent commands.
if ($command
and $current->{'cmdname'}
- and defined($brace_commands{$current->{'cmdname'}})) {
+ and defined($self->{'brace_commands'}->{$current->{'cmdname'}})) {
$self->_line_error(sprintf(__("\@%s expected braces"),
$current->{'cmdname'}), $source_info);
$current = $current->{'parent'};
@@ -4235,7 +4230,7 @@ sub _process_remaining_on_line($$$$)
# otherwise the current element is in the 'args' and not right in the
# command container.
if ($current->{'cmdname'}
- and defined($brace_commands{$current->{'cmdname'}})
+ and defined($self->{'brace_commands'}->{$current->{'cmdname'}})
and !$open_brace) {
print STDERR "BRACE CMD: no brace after \@$current->{'cmdname'}: $line"
if $self->{'DEBUG'};
@@ -5092,13 +5087,11 @@ sub _process_remaining_on_line($$$$)
_register_global_command($self, $block, $source_info);
$line = _start_empty_line_after_command($line, $current, $block);
}
- } elsif (defined($brace_commands{$command})) {
+ } elsif (defined($self->{'brace_commands'}->{$command})) {
push @{$current->{'contents'}}, { 'cmdname' => $command,
'parent' => $current,
'contents' => [] };
- $current->{'contents'}->[-1]->{'source_info'} = $source_info
- if ($keep_line_nr_brace_commands{$command}
- and !$self->{'definfoenclose'}->{$command});
+ $current->{'contents'}->[-1]->{'source_info'} = $source_info;
if ($in_index_commands{$command}
and !_is_index_element($self, $current->{'parent'})) {
$self->_line_warn(
@@ -5145,7 +5138,7 @@ sub _process_remaining_on_line($$$$)
} elsif ($separator eq '{') {
_abort_empty_line($self, $current);
if ($current->{'cmdname'}
- and defined($brace_commands{$current->{'cmdname'}})) {
+ and defined($self->{'brace_commands'}->{$current->{'cmdname'}})) {
my $command = $current->{'cmdname'};
$current->{'args'} = [ { 'parent' => $current,
'contents' => [] } ];
@@ -5280,7 +5273,7 @@ sub _process_remaining_on_line($$$$)
# a paragraph withing the footnote
} elsif ($current->{'parent'}
and $current->{'parent'}->{'cmdname'}
- and exists $brace_commands{$current->{'parent'}->{'cmdname'}}) {
+ and exists
$self->{'brace_commands'}->{$current->{'parent'}->{'cmdname'}}) {
# for math and footnote out of paragraph
if ($context_brace_commands{$current->{'parent'}->{'cmdname'}}) {
my $command_context = 'ct_brace_command';
@@ -5938,20 +5931,16 @@ sub _parse_line_command_args($$$)
# FIXME not clear if non ascii spaces are ok in the args
if ($line =~
s/^([[:alnum:]][[:alnum:]\-]*)\s*,\s*([^\s,]*)\s*,\s*([^\s,]*)$//) {
$args = [$1, $2, $3 ];
- $self->{'definfoenclose'}->{$1} = [ $2, $3 ];
- print STDERR "DEFINFOENCLOSE \@$1: $2, $3\n" if ($self->{'DEBUG'});
-
- # FIXME it is not propagated outside of the Parser. It is not
- # reinitialized between calls of the converter. It is not
- # put in %in_full_text_commands.
- $brace_commands{$1} = 'style_other';
-
- # Warning: there is a risk of mixing of data between a built-in
- # command and a user command defined with @definfoenclose.
- # %keep_line_nr_brace_commands is one example of this.
+ my ($cmd_name, $begin, $end) = ($1, $2, $3);
+ $self->{'definfoenclose'}->{$cmd_name} = [ $begin, $end ];
+ print STDERR "DEFINFOENCLOSE \@$cmd_name: $begin, $end\n"
+ if ($self->{'DEBUG'});
+ $self->{'brace_commands'}->{$cmd_name} = 'definfoenclose';
+ # note that a built-in command previously in a hash classifying the
+ # @-command will remain there, possibly having specific effects.
} else {
- $self->_line_error(sprintf(
- __("bad argument to \@%s"), $command),
$source_info);
+ $self->_line_error(sprintf(__("bad argument to \@%s"), $command),
+ $source_info);
}
} elsif ($command eq 'columnfractions') {
my @possible_fractions = split (/\s+/, $line);
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index d3779ad86f..c2cab59d0e 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -603,8 +603,7 @@ element_to_perl_hash (ELEMENT *e)
newRV_inc((SV *)extra), 0);
}
- if (e->source_info.line_nr
- && !(command_flags(e) & CF_INFOENCLOSE))
+ if (e->source_info.line_nr)
{
#define STORE(key, sv) hv_store (hv, key, strlen (key), sv, 0)
SOURCE_INFO *source_info = &e->source_info;
diff --git a/tp/t/results/macro/macro_in_misc_commands.pl
b/tp/t/results/macro/macro_in_misc_commands.pl
index 453ee20c34..d25d1fb3a3 100644
--- a/tp/t/results/macro/macro_in_misc_commands.pl
+++ b/tp/t/results/macro/macro_in_misc_commands.pl
@@ -1081,6 +1081,11 @@ $result_trees{'macro_in_misc_commands'} = {
'end' => '\\\\'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 60,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
@@ -1216,6 +1221,11 @@ $result_trees{'macro_in_misc_commands'} = {
'end' => ':'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 67,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
@@ -1453,6 +1463,11 @@ $result_trees{'macro_in_misc_commands'} = {
'end' => ':)'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 80,
+ 'macro' => 'strongmacro'
+ },
'type' => 'definfoenclose_command'
},
{
diff --git a/tp/t/results/misc_commands/definfoenclose.pl
b/tp/t/results/misc_commands/definfoenclose.pl
index c155d8cf5e..ff3919039e 100644
--- a/tp/t/results/misc_commands/definfoenclose.pl
+++ b/tp/t/results/misc_commands/definfoenclose.pl
@@ -86,6 +86,11 @@ $result_trees{'definfoenclose'} = {
'end' => '\\'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
@@ -174,6 +179,11 @@ $result_trees{'definfoenclose'} = {
'end' => ':'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 8,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
@@ -291,6 +301,11 @@ $result_trees{'definfoenclose'} = {
'end' => ':)'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 14,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
diff --git a/tp/t/results/misc_commands/definfoenclose_with_empty_arg.pl
b/tp/t/results/misc_commands/definfoenclose_with_empty_arg.pl
index baaf5f7d73..9fc94812a0 100644
--- a/tp/t/results/misc_commands/definfoenclose_with_empty_arg.pl
+++ b/tp/t/results/misc_commands/definfoenclose_with_empty_arg.pl
@@ -80,6 +80,11 @@ $result_trees{'definfoenclose_with_empty_arg'} = {
'end' => ':'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
diff --git a/tp/t/results/paragraph/paragraph_command.pl
b/tp/t/results/paragraph/paragraph_command.pl
index 25a6938e44..7183f2e7e7 100644
--- a/tp/t/results/paragraph/paragraph_command.pl
+++ b/tp/t/results/paragraph/paragraph_command.pl
@@ -245,6 +245,11 @@ $result_trees{'paragraph_command'} = {
'end' => '//'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 12,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
diff --git a/tp/t/results/value/value_in_misc_commands.pl
b/tp/t/results/value/value_in_misc_commands.pl
index 36673bd7e2..164acf4a2d 100644
--- a/tp/t/results/value/value_in_misc_commands.pl
+++ b/tp/t/results/value/value_in_misc_commands.pl
@@ -616,6 +616,11 @@ $result_trees{'value_in_misc_commands'} = {
'end' => '\\\\'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 36,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
@@ -718,6 +723,11 @@ $result_trees{'value_in_misc_commands'} = {
'end' => ':'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 42,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
@@ -889,6 +899,11 @@ $result_trees{'value_in_misc_commands'} = {
'end' => ':)'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 51,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
},
{
diff --git a/tp/t/results/xtable/definfoenclose_on_table_line.pl
b/tp/t/results/xtable/definfoenclose_on_table_line.pl
index ed10ee4a46..db52b09dd4 100644
--- a/tp/t/results/xtable/definfoenclose_on_table_line.pl
+++ b/tp/t/results/xtable/definfoenclose_on_table_line.pl
@@ -60,6 +60,11 @@ $result_trees{'definfoenclose_on_table_line'} = {
'end' => ':'
},
'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => ''
+ },
'type' => 'definfoenclose_command'
}
],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Keep definfoenclose defined commands line numbers,
Patrice Dumas <=