texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/Common.pm (parse_node_manual), tp/Te


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm, tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: do not modify the input argument, let it be done by the caller.
Date: Sat, 11 Sep 2021 15:09:01 -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 9d4ea4a  * tp/Texinfo/Common.pm (parse_node_manual), 
tp/Texinfo/ParserNonXS.pm, tp/Texinfo/Structuring.pm, 
tp/Texinfo/Transformations.pm: do not modify the input argument, let it be done 
by the caller.
9d4ea4a is described below

commit 9d4ea4a4ce6ad3434ab9551369caaf0cafcb18bd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Sep 11 21:08:52 2021 +0200

    * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm,
    tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: do not modify the
    input argument, let it be done by the caller.
---
 ChangeLog                     |  6 ++++++
 tp/Texinfo/Common.pm          | 37 +++++++++++++++++++++++--------------
 tp/Texinfo/ParserNonXS.pm     |  7 +++++--
 tp/Texinfo/Structuring.pm     |  4 +++-
 tp/Texinfo/Transformations.pm |  7 +++++--
 5 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d82ef17..5b6e540 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-09-11  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm,
+       tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: do not modify 
the
+       input argument, let it be done by the caller.
+
+2021-09-11  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Convert/DocBook.pm (_convert_argument_and_end_line):
        use $self->format_comment_or_return_end_line() to better collect
        comments.
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index aca116b..756b78a 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1390,18 +1390,28 @@ sub _count_opened_tree_braces($$)
   return $braces_count;
 }
 
-# $NODE->{'contents'} is the Texinfo for the specification of a node.
+# $LABEL_CONTENTS_CONTAINER->{'contents'} is the Texinfo for the specification
+# of a node.  It is relevant in any situation when a label is expected,
+# @node, menu entry, float, anchor...  For the @node command, for instance,
+# it is typically $node->{'args'}->[0].
+#
 # Returned object is a hash with two fields:
 #
 #     manual_content - Texinfo tree for a manual name extracted from the
 #                      node specification.
 #     node_content - Texinfo tree for the node name on its own
 #
+# A contents array where the manual_content and node_content
+# elements substituted the initial contents is also returned,
+# typically to replace $LABEL_CONTENTS_CONTAINER->{'contents'}
+# for consistency.
+#
 # retrieve a leading manual name in parentheses, if there is one.
 sub parse_node_manual($)
 {
-  my $node = shift;
-  my @contents = @{$node->{'contents'}};
+  my $label_contents_container = shift;
+
+  my @contents = @{$label_contents_container->{'contents'}};
 
   my $manual;
   my $result;
@@ -1449,30 +1459,29 @@ sub parse_node_manual($)
     if ($braces_count == 0) {
       $result->{'manual_content'} = $manual if (defined($manual));
     } else {
-      @contents = ({ 'text' => '(', 'parent' => $node }, @$manual);
+      @contents = ({ 'text' => '(', 'parent' => $label_contents_container }, 
@$manual);
     }
   }
   if (@contents) {
     $result->{'node_content'} = \@contents;
   }
 
-  # Overwrite the contents array so that all the elements in 'manual_content'
-  # and 'node_content' are in the main tree.
+  # Return the contents array in which all the elements in 'manual_content'
+  # and 'node_content' have been put.
   my $new_contents = [];
   if (defined($result) and defined($result->{'manual_content'})) {
-    @$new_contents = ({ 'text' => '(', 'parent' => $node },
+    @$new_contents = ({ 'text' => '(', 'parent' => $label_contents_container },
                       @$manual);
-    push @$new_contents, {  'text' => ')', 'parent' => $node }
+    push @$new_contents, {  'text' => ')', 'parent' => 
$label_contents_container }
       if $end_paren;
-    push @$new_contents, { 'text' => $spaces_after, 'parent' => $node }
+    push @$new_contents, { 'text' => $spaces_after, 'parent' => 
$label_contents_container }
       if $spaces_after;
   }
   if (@contents) {
     @$new_contents = (@$new_contents, @contents);
   }
-  $node->{'contents'} = $new_contents;
 
-  return $result;
+  return $result, $new_contents;
 }
 
 # decompose a decimal number on a given base.
@@ -1605,11 +1614,11 @@ sub element_is_inline($;$)
 
 sub normalize_top_node_name($)
 {
-  my $node = shift;
-  if ($node =~ /^top$/i) {
+  my $node_name = shift;
+  if ($node_name =~ /^top$/i) {
     return 'Top';
   }
-  return $node;
+  return $node_name;
 }
 
 # Used in count_bytes
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 90ea802..d18bff1 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2225,8 +2225,11 @@ sub _isolate_last_space
 # retrieve a leading manual name in parentheses, if there is one.
 sub _parse_node_manual($)
 {
-  my $node = shift;
-  return Texinfo::Common::parse_node_manual ($node);
+  my $label_contents_container = shift;
+  my ($parsed_node_manual, $modified_node_content)
+    = Texinfo::Common::parse_node_manual($label_contents_container);
+  $label_contents_container->{'contents'} = $modified_node_content;
+  return $parsed_node_manual;
 }
 
 sub _parse_float_type($)
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index d2f5973..29c5510 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1489,8 +1489,10 @@ sub new_node_menu_entry
   }
   $entry->{'extra'}->{'menu_entry_name'} = $menu_entry_name;
 
-  $entry->{'extra'}->{'menu_entry_node'} =
+  my $modified_node_content;
+  ($entry->{'extra'}->{'menu_entry_node'}, $modified_node_content) =
     Texinfo::Common::parse_node_manual($menu_entry_node);
+  $menu_entry_node->{'contents'} = $modified_node_content;
   my $content = $entry->{'extra'}->{'menu_entry_node'}->{'node_content'};
   if ($content) {
     $entry->{'extra'}->{'menu_entry_node'}->{'normalized'}
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index dbbab95..5a282e9 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -244,12 +244,15 @@ sub _new_node($$$$)
     foreach my $content (@{$node_arg->{'contents'}}) {
       $content->{'parent'} = $node_arg;
     }
-    $parsed_node = Texinfo::Common::parse_node_manual($node_arg);
+    my $modified_node_content;
+    ($parsed_node, $modified_node_content)
+       = Texinfo::Common::parse_node_manual($node_arg);
     if ($parsed_node and $parsed_node->{'node_content'}) {
       $parsed_node->{'normalized'} =
-      Texinfo::Convert::NodeNameNormalization::normalize_node (
+       Texinfo::Convert::NodeNameNormalization::normalize_node(
         { 'contents' => $parsed_node->{'node_content'} });
     }
+    $node_arg->{'contents'} = $modified_node_content;
     if (!defined($parsed_node) or !$parsed_node->{'node_content'}
         or $parsed_node->{'normalized'} !~ /[^-]/) {
       if ($appended_number) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]