[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8047] split code out for duplicating parser
From: |
gavinsmith0123 |
Subject: |
[8047] split code out for duplicating parser |
Date: |
Sun, 12 Aug 2018 16:28:59 -0400 (EDT) |
Revision: 8047
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8047
Author: gavin
Date: 2018-08-12 16:28:59 -0400 (Sun, 12 Aug 2018)
Log Message:
-----------
split code out for duplicating parser
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Convert/HTML.pm
trunk/tp/Texinfo/Parser.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-08-12 19:40:47 UTC (rev 8046)
+++ trunk/ChangeLog 2018-08-12 20:28:59 UTC (rev 8047)
@@ -1,5 +1,12 @@
2018-08-12 Gavin Smith <address@hidden>
+ * tp/Texinfo/Parser.pm (parser, duplicate_parser): Move code out
+ for duplicating an existing parser to a new function.
+ * tp/Texinfo/Convert/HTML.pm (output) <renamed nodes>: Call
+ 'duplicate_parser'.
+
+2018-08-12 Gavin Smith <address@hidden>
+
* tp/Texinfo/Common.pm (%default_parser_state_configuration):
Remove 'gettext' and 'pgettext'.
* tp/texi2any.pl ($parser_default_options): Remove 'gettext' and
Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm 2018-08-12 19:40:47 UTC (rev 8046)
+++ trunk/tp/Texinfo/Convert/HTML.pm 2018-08-12 20:28:59 UTC (rev 8047)
@@ -7137,7 +7137,8 @@
# nodes incorrectly define anchors...
my $parser_for_renamed_nodes;
if ($self->{'parser'}) {
- $parser_for_renamed_nodes = $self->{'parser'}->parser();
+ $parser_for_renamed_nodes
+ = Texinfo::Parser::duplicate_parser($self->{'parser'});
}
my %warned_new_node;
foreach my $old_node_name (sort(keys(%{$self->{'renamed_nodes'}}))) {
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2018-08-12 19:40:47 UTC (rev 8046)
+++ trunk/tp/Texinfo/Parser.pm 2018-08-12 20:28:59 UTC (rev 8047)
@@ -579,6 +579,31 @@
}
}
+# Duplicate an existing parser.
+sub duplicate_parser {
+ my $old_parser = shift;
+
+ my $parser = dclone(\%parser_default_configuration);
+
+ foreach my $key (keys(%parser_default_configuration)) {
+ if ($tree_informations{$key}) {
+ if (defined($old_parser->{$key})) {
+ foreach my $info_key (keys(%{$old_parser->{$key}})) {
+ $parser->{$key}->{$info_key}
+ = $old_parser->{$key}->{$info_key};
+ }
+ }
+ } elsif(ref($old_parser->{$key})) {
+ $parser->{$key} = dclone($old_parser->{$key});
+ } else {
+ $parser->{$key} = $old_parser->{$key};
+ }
+ }
+ bless $parser, ref($old_parser);
+
+ return _setup_parser($parser, undef);
+}
+
# initialization entry point. Set up a parser.
# The last argument, optional, is a hash provided by the user to change
# the default values for what is present in %parser_default_configuration.
@@ -596,28 +621,6 @@
#print STDERR "Not oo\n"
$conf = $class;
bless $parser;
-
- } elsif (ref($class)) {
- # called on an existing parser, interpreted as a duplication
- my $old_parser = $class;
- $class = ref($class);
- foreach my $key (keys(%parser_default_configuration)) {
- if ($tree_informations{$key}) {
- if (defined($old_parser->{$key})) {
- foreach my $info_key (keys(%{$old_parser->{$key}})) {
- $parser->{$key}->{$info_key}
- = $old_parser->{$key}->{$info_key};
- }
- }
- } elsif(ref($old_parser->{$key})) {
- $parser->{$key} = dclone($old_parser->{$key});
- } else {
- $parser->{$key} = $old_parser->{$key};
- }
- }
- bless $parser, $class;
- $conf = shift;
-
} elsif (defined($class)) {
bless $parser, $class;
$conf = shift;
@@ -625,7 +628,12 @@
bless $parser;
$conf = shift;
}
+ return _setup_parser($parser, $conf);
+}
+sub _setup_parser {
+ my ($parser, $conf) = @_;
+
_setup_conf($parser, $conf, "Texinfo::Parser::parser");
# Now initialize command hash that are dynamically modified, notably
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8047] split code out for duplicating parser,
gavinsmith0123 <=