[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm (rearrange_tree_beginning)
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm (rearrange_tree_beginning), tp/Texinfo/ParserNonXS.pm (parse_texi_file), tp/Texinfo/XS/parsetexi/Parsetexi.pm (_maybe_ignore_before_setfilename, parse_texi_file): move code from _maybe_ignore_before_setfilename to Texinfo::Common renamed as rearrange_tree_beginning and remove similar code from ParserNonXS.pm and call that function there too. |
Date: |
Sat, 01 Jan 2022 11:04:22 -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 82bb861165 * tp/Texinfo/Common.pm (rearrange_tree_beginning),
tp/Texinfo/ParserNonXS.pm (parse_texi_file),
tp/Texinfo/XS/parsetexi/Parsetexi.pm (_maybe_ignore_before_setfilename,
parse_texi_file): move code from _maybe_ignore_before_setfilename to
Texinfo::Common renamed as rearrange_tree_beginning and remove similar code
from ParserNonXS.pm and call that function there too.
82bb861165 is described below
commit 82bb861165b4b4b17d3259759bbc886bbd60293f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 1 17:04:12 2022 +0100
* tp/Texinfo/Common.pm (rearrange_tree_beginning),
tp/Texinfo/ParserNonXS.pm (parse_texi_file),
tp/Texinfo/XS/parsetexi/Parsetexi.pm
(_maybe_ignore_before_setfilename, parse_texi_file):
move code from _maybe_ignore_before_setfilename to
Texinfo::Common renamed as rearrange_tree_beginning
and remove similar code from ParserNonXS.pm and call
that function there too.
---
ChangeLog | 11 +++++++++++
tp/Texinfo/Common.pm | 26 ++++++++++++++++++++++++++
tp/Texinfo/ParserNonXS.pm | 20 +-------------------
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 25 +------------------------
4 files changed, 39 insertions(+), 43 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 05b1464612..2ac1af73e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-01-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (rearrange_tree_beginning),
+ tp/Texinfo/ParserNonXS.pm (parse_texi_file),
+ tp/Texinfo/XS/parsetexi/Parsetexi.pm
+ (_maybe_ignore_before_setfilename, parse_texi_file):
+ move code from _maybe_ignore_before_setfilename to
+ Texinfo::Common renamed as rearrange_tree_beginning
+ and remove similar code from ParserNonXS.pm and call
+ that function there too.
+
2022-01-01 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm (%document_settable_unique_at_commands),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index a22967e4f9..30db0a3b35 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1227,6 +1227,32 @@ sub output_files_unclosed_files($)
# functions used in main program, parser and structuring.
# Not supposed to be called in user-defined code.
+# Called both in NonXS and XS parsers
+sub rearrange_tree_beginning($$)
+{
+ my $self = shift;
+ my $before_node_section = shift;
+
+ # Put everything before @setfilename in a special type. This allows to
+ # ignore everything before @setfilename.
+ if ($self->global_commands_information()->{'setfilename'}
+ and $self->global_commands_information()->{'setfilename'}->{'parent'}
+ eq $before_node_section) {
+ my $before_setfilename = {'type' => 'preamble_before_setfilename',
+ 'parent' => $before_node_section,
+ 'contents' => []};
+ while (@{$before_node_section->{'contents'}}
+ and (!$before_node_section->{'contents'}->[0]->{'cmdname'}
+ or $before_node_section->{'contents'}->[0]->{'cmdname'} ne
'setfilename')) {
+ my $content = shift @{$before_node_section->{'contents'}};
+ $content->{'parent'} = $before_setfilename;
+ push @{$before_setfilename->{'contents'}}, $content;
+ }
+ unshift (@{$before_node_section->{'contents'}}, $before_setfilename)
+ if (@{$before_setfilename->{'contents'}});
+ }
+}
+
sub warn_unknown_language($) {
my $lang = shift;
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index f3f2dfff51..65810662b9 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -849,7 +849,6 @@ sub _complete_line_nr($$;$$$)
# entry point for text fragments.
# Used in tests.
-# It has no specific root type, the default set in _parse_texi is used
sub parse_texi_text($$;$$$$)
{
my ($self, $text, $lines_nr, $file, $macro, $fixed_line_number) = @_;
@@ -979,24 +978,7 @@ sub parse_texi_file($$)
my $tree = $self->_parse_texi($document_root, $before_node_section);
- # Put everything before @setfilename in a special type. This allows to
- # ignore everything before @setfilename.
- if ($self->global_commands_information()->{'setfilename'}
- and $self->global_commands_information()->{'setfilename'}->{'parent'}
- eq $before_node_section) {
- my $before_setfilename = {'type' => 'preamble_before_setfilename',
- 'parent' => $before_node_section,
- 'contents' => []};
- while (@{$before_node_section->{'contents'}}
- and (!$before_node_section->{'contents'}->[0]->{'cmdname'}
- or $before_node_section->{'contents'}->[0]->{'cmdname'} ne
'setfilename')) {
- my $content = shift @{$before_node_section->{'contents'}};
- $content->{'parent'} = $before_setfilename;
- push @{$before_setfilename->{'contents'}}, $content;
- }
- unshift (@{$before_node_section->{'contents'}}, $before_setfilename)
- if (@{$before_setfilename->{'contents'}});
- }
+ Texinfo::Common::rearrange_tree_beginning($self, $before_node_section);
$self->_set_global_informations();
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 2d0a616840..d3a7b46c15 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -207,29 +207,6 @@ sub get_parser_info {
use File::Basename; # for fileparse
-# Put everything before @setfilename in a special type. This allows
-# ignoring everything before @setfilename.
-sub _maybe_ignore_before_setfilename {
- my ($self, $before_node_section) = @_;
-
- if ($self->global_commands_information()->{'setfilename'}
- and $self->global_commands_information()->{'setfilename'}->{'parent'}
- eq $before_node_section) {
- my $before_setfilename = {'type' => 'preamble_before_setfilename',
- 'parent' => $before_node_section,
- 'contents' => []};
- while (@{$before_node_section->{'contents'}}
- and (!$before_node_section->{'contents'}->[0]->{'cmdname'}
- or $before_node_section->{'contents'}->[0]->{'cmdname'} ne
'setfilename')) {
- my $content = shift @{$before_node_section->{'contents'}};
- $content->{'parent'} = $before_setfilename;
- push @{$before_setfilename->{'contents'}}, $content;
- }
- unshift (@{$before_node_section->{'contents'}}, $before_setfilename)
- if (@{$before_setfilename->{'contents'}});
- }
-}
-
# Replacement for Texinfo::Parser::parse_texi_file
sub parse_texi_file ($$)
{
@@ -252,7 +229,7 @@ sub parse_texi_file ($$)
my $before_node_section = $TREE->{'contents'}->[0];
- _maybe_ignore_before_setfilename($self, $before_node_section);
+ Texinfo::Common::rearrange_tree_beginning($self, $before_node_section);
############################################################
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm (rearrange_tree_beginning), tp/Texinfo/ParserNonXS.pm (parse_texi_file), tp/Texinfo/XS/parsetexi/Parsetexi.pm (_maybe_ignore_before_setfilename, parse_texi_file): move code from _maybe_ignore_before_setfilename to Texinfo::Common renamed as rearrange_tree_beginning and remove similar code from ParserNonXS.pm and call that function there too.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/Common.pm (%document_settable_unique_at_commands), tp/Texinfo/Convert/LaTeX.pm (@informative_global_commands) (_convert), tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/parser.c (register_global_command), tp/Texinfo/XS/parsetexi/parser.h (GLOBAL_INFO): set @afourpaper, @afourlatex, @afourwide, @afivepaper, @bsixpaper and @smallbook as global unique @-commands.
- Next by Date:
branch master updated: * tp/Texinfo/Common.pm (%line_commands), * tp/Texinfo/XS/parsetexi/command_data.txt: Put page size commands together.
- Previous by thread:
branch master updated: * tp/Texinfo/Common.pm (%document_settable_unique_at_commands), tp/Texinfo/Convert/LaTeX.pm (@informative_global_commands) (_convert), tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/parser.c (register_global_command), tp/Texinfo/XS/parsetexi/parser.h (GLOBAL_INFO): set @afourpaper, @afourlatex, @afourwide, @afivepaper, @bsixpaper and @smallbook as global unique @-commands.
- Next by thread:
branch master updated: * tp/Texinfo/Common.pm (%line_commands), * tp/Texinfo/XS/parsetexi/command_data.txt: Put page size commands together.
- Index(es):